mr.Extreme Posted January 19, 2014 Share Posted January 19, 2014 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
Castillo Posted January 19, 2014 Share Posted January 19, 2014 In the client side: triggerServerEvent( "doToggleEngine", root) Change "root" to "localPlayer" or getPedOccupiedVehicle ( localPlayer ). In the server side: function doToggleEngine ( source ) Remove "source" from there. Link to comment
mr.Extreme Posted January 19, 2014 Author Share Posted January 19, 2014 thank you very much and i am sorry for engine with function unlockVehicles Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now