Jump to content

How to find a car?


fairyoggy

Recommended Posts

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
  1. 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 by Spakye
  • Like 2
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...