OnVehicleStartEnter

From Multi Theft Auto: Wiki
Revision as of 14:48, 2 December 2006 by Talidan (talk | contribs)
Jump to navigation Jump to search

This event is triggered when a player starts to enter a vehicle. This event can be used to cancel entry, if necessary.

Syntax

void onVehicleStartEnter ( player player, int seat, player jacked ) 

Variables

  • player: A player element representing the player who is starting to enter a vehicle
  • seat: An integer representing the seat in which the player is entering
  • jacked: A player element representing who is going to be jacked

Example

This example locks a police car if a player trying to enter is not a policeman

--add an event for onVehicleStartEnter
addEventHandler ( "onVehicleStartEnter", getRootElement(), "playerStartEnter" )
function playerStartEnter ( player, seat, jacked ) --when a player starts entering a vehicle
if ( getVehicleName ( source ) == "police" ) and ( getPlayerSkin ( source ) > 279 ) then --if the vehicle is a police car, and the player's skin is higher than 279 i.e. a cop skin
     setVehicleLocked ( source, false ) --open the vehicle
else --if he's not a cop
     setVehicleLocked ( source, true ) --lock the vehicle
end

See Also