OnVehicleStartExit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Fixed some mistakes)
(Replaced getPlayerSkin(deprecated function) with getElementModel.)
Line 28: Line 28:
   
   
function exitVehicle ( thePlayer, seat, jacked )  
function exitVehicle ( thePlayer, seat, jacked )  
   if (policeVehicles[getElementModel (source)]) and (policeSkins[getPlayerSkin (thePlayer)]) then  
   if (policeVehicles[getElementModel (source)]) and (policeSkins[getElementModel(thePlayer)]) then  
       outputChatBox ( "You're the cop! Don't exit the car!", thePlayer )   
       outputChatBox ( "You're the cop! Don't exit the car!", thePlayer )   
       cancelEvent()
       cancelEvent()

Revision as of 21:10, 22 July 2016

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

Parameters

player exitingPlayer, int seat, player jacked, int door
  • exitingPlayer: A player element representing the player who is starting to exit a vehicle
  • seat: An integer representing the seat in which the player is exiting from
  • jacked: A player element representing who is jacking
  • door: An integer representing the door that the player is using to leave.

Source

The source of this event is the vehicle in which a player began to exit.

Canceling

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

Example

This example locks a player inside a police vehicle if he is a policeman.

local policeVehicles = {[598] = true,[596] = true,[597] = true,[599] = true } -- Police vehicle IDs
local policeSkins = {[280] = true,[281] = true,[282] = true,[283] = true,[284] = true,[285] = true,[286] = true } -- Police Skins
 
function exitVehicle ( thePlayer, seat, jacked ) 
   if (policeVehicles[getElementModel (source)]) and (policeSkins[getElementModel(thePlayer)]) then 
      outputChatBox ( "You're the cop! Don't exit the car!", thePlayer )  
      cancelEvent()
   end
end
addEventHandler ( "onVehicleStartExit", getRootElement(), exitVehicle)

See Also

Vehicle events


Event functions