OnVehicleStartEnter: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server event}} | |||
This event is triggered when a player starts to enter a vehicle. This event can be used to cancel entry, if necessary. | This event is triggered when a player starts to enter a vehicle. This event can be used to cancel entry, if necessary. | ||
== | ==Paramaters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
player enteringPlayer, int seat, player jacked | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==Variables== | ==Variables== | ||
*''' | *'''enteringPlayer''': 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 | *'''seat''': An integer representing the seat in which the player is entering | ||
*'''jacked''': A player element representing who is going to be jacked | *'''jacked''': A player element representing who is going to be jacked | ||
==Source== | |||
The [[event system#Event source|source]] of this event is the [[vehicle]] in which a player began to enter. | |||
===Canceling=== | ===Canceling=== | ||
Line 17: | Line 20: | ||
==Example== | ==Example== | ||
This example | This example blocks a player out of a police vehicle if he is not a policeman. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
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 | |||
if ( | function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle | ||
if ( policeVehicles[getVehicleID(source)] ) and ( not policeSkins[getPlayerSkin(player)] ) then --if the vehicle is one of 4 police cars, and the skin is not a police skin | |||
cancelEvent() | |||
outputChatBox ( "Only policeman can enter police cars!", player ) --and tell the player why | |||
end | |||
end | end | ||
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) --add an event for onPlayerEnterVehicle | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Event_functions}} | {{Event_functions}} |
Revision as of 14:45, 22 October 2007
This event is triggered when a player starts to enter a vehicle. This event can be used to cancel entry, if necessary.
Paramaters
player enteringPlayer, int seat, player jacked
Variables
- enteringPlayer: 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
Source
The source of this event is the vehicle in which a player began to enter.
Canceling
If this event is canceled, the player will not enter the vehicle.
Example
This example blocks 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 ( player, seat, jacked ) --when a player enters a vehicle if ( policeVehicles[getVehicleID(source)] ) and ( not policeSkins[getPlayerSkin(player)] ) then --if the vehicle is one of 4 police cars, and the skin is not a police skin cancelEvent() outputChatBox ( "Only policeman can enter police cars!", player ) --and tell the player why end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) --add an event for onPlayerEnterVehicle
See Also
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled