OnClientVehicleEnter: Difference between revisions
Jump to navigation
Jump to search
m (See Also for client vehicle events) |
Zangomangu (talk | contribs) mNo edit summary |
||
(7 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{Client event}} | {{Client event}} | ||
__NOTOC__ | __NOTOC__ | ||
This event gets fired when a player enters a vehicle. | This event gets fired when a [[player]] or [[ped]] enters a vehicle. | ||
==Parameters== | ==Parameters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
ped thePed, int seat | |||
</syntaxhighlight> | </syntaxhighlight> | ||
*''' | *'''thePed:''' the [[player]] or [[ped]] that entered the vehicle | ||
*'''seat:''' the number of the seat that the | *'''seat:''' the number of the seat that the ped is now sitting on. 0 = driver, higher numbers are passenger seats. | ||
==Source== | ==Source== | ||
The source of the event is the vehicle that the | The [[event system#Event source|source]] of the event is the [[vehicle]] that the ped entered. | ||
==Example== | ==Example== | ||
Line 25: | Line 24: | ||
end | end | ||
) | ) | ||
addEventHandler(" | addEventHandler("onClientVehicleExit", getRootElement(), | ||
function(thePlayer, seat) | function(thePlayer, seat) | ||
if thePlayer == getLocalPlayer() then | if thePlayer == getLocalPlayer() then | ||
Line 32: | Line 31: | ||
end | end | ||
) | ) | ||
</syntaxhighlight> | |||
This example disables helikills & blade collisions upon entering a heli | |||
<syntaxhighlight lang="lua"> | |||
function onHeliEnter() | |||
if getVehicleType(source) == "Helicopter" then | |||
setHeliBladeCollisionsEnabled (source, false) | |||
end | |||
end | |||
addEventHandler ("onClientVehicleEnter", root, onHeliEnter) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 39: | Line 48: | ||
===Client event functions=== | ===Client event functions=== | ||
{{Client_event_functions}} | {{Client_event_functions}} | ||
[[es:onClientVehicleEnter]] |
Latest revision as of 12:55, 29 November 2020
This event gets fired when a player or ped enters a vehicle.
Parameters
ped thePed, int seat
- thePed: the player or ped that entered the vehicle
- seat: the number of the seat that the ped is now sitting on. 0 = driver, higher numbers are passenger seats.
Source
The source of the event is the vehicle that the ped entered.
Example
This code updates a GUI label with the name of the vehicle the local player is in.
lblVehicle = guiCreateLabel(10, 200, 150, 20, "Currently on foot", false) addEventHandler("onClientVehicleEnter", getRootElement(), function(thePlayer, seat) if thePlayer == getLocalPlayer() then guiSetText(lblVehicle, "Currently in a " .. getVehicleName(source)) end end ) addEventHandler("onClientVehicleExit", getRootElement(), function(thePlayer, seat) if thePlayer == getLocalPlayer() then guiSetText(lblVehicle, "Currently on foot") end end )
This example disables helikills & blade collisions upon entering a heli
function onHeliEnter() if getVehicleType(source) == "Helicopter" then setHeliBladeCollisionsEnabled (source, false) end end addEventHandler ("onClientVehicleEnter", root, onHeliEnter)
See Also
Client vehicle events
- onClientTrailerAttach
- onClientTrailerDetach
- onClientVehicleCollision
- onClientVehicleDamage
- onClientVehicleEnter
- onClientVehicleExit
- onClientVehicleExplode
- onClientVehicleNitroStateChange
- onClientVehicleRespawn
- onClientVehicleStartEnter
- onClientVehicleStartExit
- onClientVehicleWeaponHit