fairyoggy Posted March 28, 2020 Share Posted March 28, 2020 As far as I understand, my function cannot find a car when i go out of it. How do I find him? function removeHelmetOnExit ( vehicle, seat, jacked ) local myCar = getPedOccupiedVehicle(source) local engine = getVehicleEngineState (myCar) if engine then setElementData(myCar,"engine",1) elseif not engine then setElementData(myCar,"engine",0) end end addEventHandler ( "onPlayerVehicleExit", getRootElement(), removeHelmetOnExit ) Link to comment
Spakye Posted March 28, 2020 Share Posted March 28, 2020 (edited) local myCar = getPedOccupiedVehicle(source) Source of this event is the player that left vehicle not the vehicle itself, also you can directly use the vehicle argument of your function function removeHelmetOnExit ( vehicle, seat, jacked ) local engine = getVehicleEngineState (vehicle) if engine then setElementData(vehicle,"engine",1) elseif not engine then setElementData(vehicle,"engine",0) end end addEventHandler ( "onPlayerVehicleExit", getRootElement(), removeHelmetOnExit ) Edited March 28, 2020 by Spakye 2 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