OnVehicleExit: Difference between revisions
Jump to navigation
Jump to search
m (→Example) |
Uc.Setlings (talk | contribs) |
||
Line 31: | Line 31: | ||
end | end | ||
addEventHandler ( "onVehicleExit", getRootElement(), removeHelmetOnExit ) | addEventHandler ( "onVehicleExit", getRootElement(), removeHelmetOnExit ) | ||
</syntaxhighlight> | |||
==Example 2== | |||
When you exit the car the engine turns off. | |||
<syntaxhighlight lang="lua"> | |||
addEventHandler ( "onPlayerVehicleExit", getRootElement(), function(theVehicle, leftSeat, jackerPlayer) | |||
if leftSeat == 0 and not jackerPlayer then | |||
setVehicleEngineState( theVehicle, false) | |||
end | |||
end) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Vehicle events}} | {{See also/Server event|Vehicle events}} |
Revision as of 03:27, 12 March 2016
This event is triggered when a player leaves a vehicle.
Parameters
player thePlayer, int seat, player jacker
- thePlayer: A player element representing the player who exited the vehicle
- seat: An integer representing the seat in which the player exited from
- jacker: A player element representing the player who jacked the driver
Source
The source of this event is the vehicle that was exited.
Example
This example adds a 'moto' helmet to a player when he gets on a nrg bike, and removes it when he gets off.
function addHelmetOnEnter ( thePlayer, seat, jacked ) if ( getElementModel ( source ) == 522 ) then -- if its a nrg addPedClothes ( thePlayer, "moto", "moto", 16 ) -- add the helmet end end addEventHandler ( "onVehicleEnter", getRootElement(), addHelmetOnEnter ) function removeHelmetOnExit ( thePlayer, seat, jacked ) if ( getElementModel ( source ) == 522 ) then -- if its a nrg removePedClothes ( thePlayer, 16 ) -- remove the helmet end end addEventHandler ( "onVehicleExit", getRootElement(), removeHelmetOnExit )
Example 2
When you exit the car the engine turns off.
addEventHandler ( "onPlayerVehicleExit", getRootElement(), function(theVehicle, leftSeat, jackerPlayer) if leftSeat == 0 and not jackerPlayer then setVehicleEngineState( theVehicle, false) end end)
See Also
Vehicle events
- onTrailerAttach
- onTrailerDetach
- onVehicleDamage
- onVehicleEnter
- onVehicleExit
- onVehicleExplode
- onVehicleRespawn
- onVehicleStartEnter
- onVehicleStartExit
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled