OnVehicleStartEnter: 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 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. | ||
Line 8: | Line 6: | ||
void onVehicleStartEnter ( player player, int seat, player jacked ) | void onVehicleStartEnter ( player player, int seat, player jacked ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==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 | |||
==Example== | ==Example== | ||
This example | This example locks a police car if a player trying to enter is not a policeman | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | --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 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | |||
{{Event_functions}} |
Revision as of 14:48, 2 December 2006
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
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
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled