onVehicleExit | Multi Theft Auto: Wiki Skip to content

onVehicleExit

Client-side
Server-side
Shared

This event is triggered when a player or ped leaves a vehicle.

Parameters

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

Source

element: The source of this event is the vehicle that was exited.

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 ( 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 )

See Also

Vehicle Functions