monstergnom Posted February 13, 2010 Share Posted February 13, 2010 Hey guys, im trying to turn on/off the engine if im sitting in car - as driver... here my code: function EngineOff ( theVehicle, command ) setVehicleEngineState ( theVehicle , false ) outputChatBox("Engine is now off" , thePlayer) end addCommandHandler ( "engineoff", EngineOff ) function EngineOn ( theVehicle, command ) setVehicleEngineState ( theVehicle , true ) outputChatBox("Engine is now on" , thePlayer) end addCommandHandler ( "engineon", EngineOn ) wont work need help Link to comment
Gamesnert Posted February 13, 2010 Share Posted February 13, 2010 Functions triggered by command handlers always have the player who typed the command as first argument server-side. No matter if you call it - thePlayer - theVehicle - theObject - theCake - wutage The content will always be a player. To get the vehicle that player is in, use getPedOccupiedVehicle Link to comment
monstergnom Posted February 13, 2010 Author Share Posted February 13, 2010 oh... okay now it works... tyvm Heres the working script: function EngineOff ( thePed ) local theVehicle = getPedOccupiedVehicle ( thePed ) setVehicleEngineState ( theVehicle , false ) outputChatBox("Engine is now off" , thePlayer) end addCommandHandler ( "engineoff", EngineOff ) function EngineOn ( thePed ) local theVehicle = getPedOccupiedVehicle ( thePed ) setVehicleEngineState ( theVehicle , true ) outputChatBox("Engine is now on" , thePlayer) end addCommandHandler ( "engineon", EngineOn ) 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