OnVehicleStartExit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Using "ped" instead of "player" when parameter refers to both)
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server event}}
{{Server event}}
This event is triggered when a player starts to exit a vehicle. This event can be used to cancel exit, if necessary.
This event is triggered when a player or ped starts to exit a vehicle. This event can be used to cancel exit, if necessary.


==Parameters==  
==Parameters==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
player exitingPlayer, int seat, player jacked
ped exitingPed, int seat, ped jacked, int door
</syntaxhighlight>  
</syntaxhighlight>  


*'''enteringPlayer''': A player element representing the player who is starting to exit a vehicle
*'''exitingPed''': a [[player]] or [[ped]] element who is starting to exit a vehicle.
*'''seat''': An integer representing the seat in which the player is exiting from
*'''seat''': an [[int]] representing the seat in which the ped is exiting from.
*'''jacked''': A player element representing who is jacking
*'''jacked''': a [[player]] or [[ped]] element representing who is jacking.
*'''door''': an [[int]] representing the door that the ped is using to leave.


==Source==
==Source==
The [[event system#Event source|source]] of this event is the [[vehicle]] in which a player began to exit.
The [[event system#Event source|source]] of this event is the [[vehicle]] in which a ped began to exit.


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


==Example==  
==Example==  
This example locks a player inside a police vehicle if he is a policeman.
This example locks a player inside a police vehicle if he is a policeman.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
policeVehicles { [598]=true,[596]=true,[597]=true,[599]=true }
local policeVehicles = {[598] = true,[596] = true,[597] = true,[599] = true } -- Police vehicle IDs
policeSkins { [280]=true,[281]=true,[282]=true,[283]=true,[284]=true,[285]=true,[286]=true }
local policeSkins = {[280] = true,[281] = true,[282] = true,[283] = true,[284] = true,[285] = true,[286] = true } -- Police Skins
 
function exitVehicle ( player, seat, jacked ) --when a player enters a vehicle
function exitVehicle ( thePlayer, seat, jacked )  
    if ( policeVehicles[getVehicleID(source)] ) and ( policeSkins[getPlayerSkin(player)] ) then --if the vehicle is one of 4 police cars, and the skin is a police skin
  if (policeVehicles[getElementModel (source)]) and (policeSkins[getElementModel(thePlayer)]) then  
        cancelEvent()
      outputChatBox ( "You're the cop! Don't exit the car!", thePlayer ) 
        outputChatBox ( "You're the cop! Don't exit the car!", player ) --and tell the player why
      cancelEvent()
    end
  end
end
end
addEventHandler ( "onVehicleStartExit", getRootElement(), exitVehicle ) --add an event for onPlayerEnterVehicle
addEventHandler ( "onVehicleStartExit", getRootElement(), exitVehicle)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
{{See also/Server event|Vehicle events}}
{{Event_functions}}

Latest revision as of 18:54, 29 November 2020

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

Parameters

ped exitingPed, int seat, ped jacked, int door
  • exitingPed: a player or ped element who is starting to exit a vehicle.
  • seat: an int representing the seat in which the ped is exiting from.
  • jacked: a player or ped element representing who is jacking.
  • door: an int representing the door that the ped is using to leave.

Source

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

Canceling

If this event is canceled, the ped 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