OnVehicleEnter: Difference between revisions
Jump to navigation
Jump to search
JonChappell (talk | contribs) No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This event is triggered when a player enters a vehicle. | This event is triggered when a player enters a vehicle. | ||
Line 8: | Line 6: | ||
void onVehicleEnter ( player player, int seat, player jacked ) | void onVehicleEnter ( player player, int seat, player jacked ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Variables== | |||
* The source of this event is the [[vehicle]] that is being entered by a ''player''. | |||
*'''player''': A player element representing the player who is entering the vehicle | |||
*'''seat''': An integer representing the seat in which the player is entering | |||
*'''jacked''': A player element representing a player who has been jacked | |||
==Example== | ==Example== | ||
This example | This example forces a player out of a police vehicle if he is not a policeman. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | addEventHandler ( "onVehicleEnter", getRootElement(), "vehicleEnter" ) --add an event for onPlayerEnterVehicle | ||
function vehicleEnter ( player, seat, jacked ) --when a player enters a vehicle | |||
-- | if ( source == 598 or 596 or 597 or 599 ) and ( getPlayerSkin ( player ) ~= 280 or 281 or 282 or 283 or 284 or 285 or 286 ) then --if the vehicle is one of 4 police cars, and the skin is not a police skin | ||
removePlayerFromVehicle ( player )--force the player out of the vehicle | |||
outputChatBox ( "Only policeman can enter police cars!", player ) --and tell the player why | |||
end | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | |||
{{Event_functions}} |
Revision as of 15:02, 2 December 2006
This event is triggered when a player enters a vehicle.
Syntax
void onVehicleEnter ( player player, int seat, player jacked )
Variables
- The source of this event is the vehicle that is being entered by a player.
- player: A player element representing the player who is entering the vehicle
- seat: An integer representing the seat in which the player is entering
- jacked: A player element representing a player who has been jacked
Example
This example forces a player out of a police vehicle if he is not a policeman.
addEventHandler ( "onVehicleEnter", getRootElement(), "vehicleEnter" ) --add an event for onPlayerEnterVehicle function vehicleEnter ( player, seat, jacked ) --when a player enters a vehicle if ( source == 598 or 596 or 597 or 599 ) and ( getPlayerSkin ( player ) ~= 280 or 281 or 282 or 283 or 284 or 285 or 286 ) then --if the vehicle is one of 4 police cars, and the skin is not a police skin removePlayerFromVehicle ( player )--force the player out of the vehicle outputChatBox ( "Only policeman can enter police cars!", player ) --and tell the player why end
See Also
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled