KiffShark Posted November 20, 2012 Share Posted November 20, 2012 (edited) Hi I want that the button of a panel turn off/on the vehicle's engine... it works BUT I use a fuel resource that turn off the engine when there is no fuel... this button allows you to turn it on again... -__- The fuel resource have got the command "engine" that works only if there is fuel in the vehicle so I want that this button executes this command.. This is what I've done: (but it doesn't work) function engines() local theVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if (theVehicle) then local state = getVehicleEngineState ( theVehicle ) if (state == true) then executeCommandHandler ( "engine" ) --This command is from other resource -- setVehicleEngineState(theVehicle,false) --with this it works, but the command works only if there's fuel in the car outputChatBox("*Motor apagado*",255,0,0) else executeCommandHandler ( "engine" ) --This command is from other resource -- setVehicleEngineState(theVehicle,true) --with this it works, but the command works only if there's fuel in the car outputChatBox("*Motor arrancado*",255,0,0) end end end Maybe I can't execute commands from other resources?? thanks! Edited November 20, 2012 by Guest Link to comment
Baseplate Posted November 20, 2012 Share Posted November 20, 2012 function engines() local theVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if (theVehicle) then local state = getVehicleEngineState ( theVehicle ) if (state == true) then setVehicleEngineState(theVehicle, false) elseif (state == false) then setVehicleEngineState(theVehicle, true) end end end addCommandHandler("engine", engines) Link to comment
TAPL Posted November 20, 2012 Share Posted November 20, 2012 I guess that because client side executeCommandHandler works with client side commands and your other resource have the command "engine" server side. Link to comment
KiffShark Posted November 20, 2012 Author Share Posted November 20, 2012 I have done: server side function engex( ) executeCommandHandler ( "engine",source ) end addEvent("ex",true); addEventHandler("ex",getRootElement(),engex) client side function engines() local theVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if (theVehicle) then local state = getVehicleEngineState ( theVehicle ) if (state == true) then triggerServerEvent("ex",localPlayer) outputChatBox("*Motor apagado*",255,0,0) else triggerServerEvent("ex",localPlayer) outputChatBox("*Motor arrancado*",255,0,0) end end end ERROR console: access denied @ 'executeCommandHandler' Link to comment
TAPL Posted November 20, 2012 Share Posted November 20, 2012 You need to add the resource to Admin group in ACL. Link to comment
KiffShark Posted November 20, 2012 Author Share Posted November 20, 2012 wiii :3 solved! 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