onPlayerVehicleEnter | Multi Theft Auto: Wiki Skip to content

onPlayerVehicleEnter

Client-side
Server-side
Shared

This event is triggered when a player enters a vehicle.

Parameters

vehicle theVehicle, int seat, ped jacked
  • theVehicle: a vehicle element representing the vehicle that was entered.
  • seat: an int representing the seat in which the player is entering.
  • jacked: a player or ped element representing who has been jacked.

Source

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

Code Examples

server

Example 1:This example forces a player out of a police vehicle if he is not a policeman.

policeVehicles = { [598]=true, [596]=true, [597]=true, [599]=true }
policeSkins = { [280]=true, [281]=true, [282]=true, [283]=true, [284]=true, [285]=true, [286]=true }
function enterVehicle ( theVehicle, seat, jacked ) --when a player enters a vehicle
if ( policeVehicles[getElementModel ( theVehicle )] ) and ( not policeSkins[getElementModel ( source )] ) then -- if the vehicle is one of 4 police cars, and the skin is not a police skin
removePedFromVehicle ( source ) -- force the player out of the vehicle
outputChatBox ( "Only policeman can enter police cars!", source ) -- and tell the player why
end
end
addEventHandler ( "onPlayerVehicleEnter", root, enterVehicle ) -- add an event handler for onPlayerVehicleEnter

See Also