OnVehicleStartEnter: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 14: Line 14:


===Canceling===
===Canceling===
If this event is [[Events#Canceling|canceled]], the player will not enter the vehicle.
If this event is [[Event system #Canceling|canceled]], the player will not enter the vehicle.


==Example==  
==Example==  

Revision as of 22:36, 30 August 2007

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


Canceling

If this event is canceled, the player will not enter the vehicle.

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