OnPedVehicleExit: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server event}} | {{Server event}} | ||
{{ | {{Added feature/item|3.0159|1.5.9|1.5.8|20740|This event is triggered when a [[ped]] leaves a [[vehicle]].}} | ||
==Parameters== | ==Parameters== | ||
Line 8: | Line 8: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
*'''theVehicle''': | *'''theVehicle''': A [[vehicle]] element representing the [[vehicle]] in which the [[ped]] exited from. | ||
*'''seat''': | *'''seat''': An [[int]] representing the seat in which the [[ped]] was before exiting. | ||
*'''jacker''': | *'''jacker''': A [[player]] or [[ped]] element representing who jacked the driver. | ||
*'''forcedByScript:''' | *'''forcedByScript:''' A [[boolean]] representing whether the exit was forced using [[removePedFromVehicle]] or by the [[ped]]. | ||
==Source== | ==Source== | ||
The [[event system#Event source|source]] of this event is the [[ped]] that left the vehicle. | The [[event system#Event source|source]] of this event is the [[ped]] that left the [[vehicle]]. | ||
==Example== | |||
Destroy the vehicle when ped has been jacked and kick the jacker if exists | Destroy the [[vehicle]] when [[ped]] has been jacked and kick the jacker if exists: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function destroyVehicle(theVehicle, seat, jacker, forcedByScript) | function destroyVehicle (theVehicle, seat, jacker, forcedByScript) | ||
if seat==0 then -- If ped was a driver | if seat == 0 then -- If ped was a driver | ||
if forcedByScript then | if forcedByScript then | ||
destroyElement(theVehicle) -- If the exit was forced using removePedFromVehicle then destroy the vehicle | destroyElement (theVehicle) -- If the exit was forced using removePedFromVehicle then destroy the vehicle | ||
elseif jacker then | elseif jacker then | ||
kickPlayer(jacker) | kickPlayer (jacker) | ||
destroyElement(theVehicle) | destroyElement (theVehicle) | ||
end | end | ||
end | end | ||
end | end | ||
addEventHandler("onPedVehicleExit", root, destroyVehicle) | |||
addEventHandler ("onPedVehicleExit", root, destroyVehicle) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==Requirements== | |||
{{Requirements|1.5.8-9.20740|n/a|}} | |||
{{See also/Server event|Ped events}} | {{See also/Server event|Ped events}} |
Revision as of 11:36, 20 September 2021
20740
Parameters
vehicle theVehicle, int seat, ped jacker, bool forcedByScript
- theVehicle: A vehicle element representing the vehicle in which the ped exited from.
- seat: An int representing the seat in which the ped was before exiting.
- jacker: A player or ped element representing who jacked the driver.
- forcedByScript: A boolean representing whether the exit was forced using removePedFromVehicle or by the ped.
Source
The source of this event is the ped that left the vehicle.
Example
Destroy the vehicle when ped has been jacked and kick the jacker if exists:
function destroyVehicle (theVehicle, seat, jacker, forcedByScript) if seat == 0 then -- If ped was a driver if forcedByScript then destroyElement (theVehicle) -- If the exit was forced using removePedFromVehicle then destroy the vehicle elseif jacker then kickPlayer (jacker) destroyElement (theVehicle) end end end addEventHandler ("onPedVehicleExit", root, destroyVehicle)
Requirements
This template will be deleted.
See Also
Ped events
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled