onPlayerVehicleExit | Multi Theft Auto: Wiki Skip to content

onPlayerVehicleExit

Client-side
Server-side
Shared

This event is triggered when a player leaves a vehicle, for whatever reason.

Parameters

vehicle theVehicle, int seat, ped jacker, bool forcedByScript
  • theVehicle: a vehicle element representing the vehicle in which the player exited from.
  • seat: an int representing the seat in which the player was before exiting.
  • jacker: a player or ped element representing who jacked the driver.
  • forcedByScript: a boolean representing whether the exit was forced using removePedFromVehicle or by the player.

Source

element: The source of this event is the player that left the vehicle.

Code Examples

server

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 ( vehicle, seat, jacked )
if ( getVehicleID ( vehicle ) == 522 ) then -- if its a nrg
addPedClothes ( source, "moto", "moto", 16 ) -- add the helmet
end
end
addEventHandler ( "onPlayerVehicleEnter", root, addHelmetOnEnter )
function removeHelmetOnExit ( vehicle, seat, jacked )
if ( getVehicleID ( vehicle ) == 522 ) then -- if its a nrg
removePedClothes ( source, 16 ) -- remove the helmet
end
end
addEventHandler ( "onPlayerVehicleExit", root, removeHelmetOnExit )

See Also