Jump to content

control panel for car


mr.Extreme

Recommended Posts

hello :)

I created a panel to control car through buttons

but did not work :(:(

here my code

client

  
GUIEditor.button[1] = guiCreateButton(10, 185, 77, 28, "Engine", false, GUIEditor.window[1]) 
function unlockVehicles () 
    triggerServerEvent( "doToggleEngine", root) 
end 
addEventHandler("onClientGUIClick", GUIEditor.button[1], unlockVehicles,false) 
  

server

  
function doToggleEngine ( source ) 
    local theVehicle 
    if ( getElementType(source) == "vehicle" ) then 
        theVehicle = source 
    end 
    if ( getElementType(source) == "player" ) then 
        theVehicle = getElementData ( source, "cl_ownedvehicle" ) 
    end 
    if ( theVehicle ) then 
        -- off or not set 
        local lights = getVehicleOverrideLights ( theVehicle ) 
        if ( getElementData( theVehicle, "cl_enginestate" ) == false )  then 
            setElementData( theVehicle, "cl_enginestate", true) 
            setVehicleEngineState( theVehicle, true ) 
        else -- on -- set to off 
            setElementData( theVehicle, "cl_enginestate", false ) 
            setVehicleEngineState( theVehicle, false ) 
        end 
        setVehicleOverrideLights ( theVehicle, lights ) 
    else 
        outputChatBox("You must have a vehicle to control the engine.", source, 255, 0, 0, true ) 
    end 
end 
addEvent("doToggleEngine", true) 
addEventHandler("doToggleEngine", root, doToggleEngine) 
  
  
  

and thanks for helping

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...