OnVehicleRespawn: Difference between revisions
Jump to navigation
Jump to search
JonChappell (talk | contribs) No edit summary |
No edit summary |
||
(5 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
[[ | __NOTOC__ | ||
{{Server event}} | |||
This event is triggered when a vehicle is respawned due. See [[toggleVehicleRespawn]]. | |||
==Parameters== | |||
== | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool exploded | |||
</syntaxhighlight> | </syntaxhighlight> | ||
*'''exploded''': ''true'' if this vehicle respawned because it exploded, ''false'' if it respawned due to being deserted. | |||
==Source== | |||
The [[event system#Event source|source]] of this event is the [[vehicle]] that respawned. | |||
==Example== | ==Example== | ||
This example | This example shows a message in the chatbox, if it is respawned. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function onVehicleRespawn ( exploded ) | ||
-- Add this variable. It contains the vehicle name of the respawned vehicle | |||
local vehicleName = getVehicleName ( source ) | |||
-- If it is exploded, echo a custom message | |||
if ( exploded == true ) then | |||
outputChatBox("A " .. vehiclename .. " has been respawned, after an explosion") | |||
-- else echo a normal message | |||
else | |||
outputChatBox("A " .. vehiclename .. " has been respawned") | |||
end | |||
end | |||
-- Add the Event Handler | |||
addEventHandler ( "onVehicleRespawn", getRootElement(), onVehicleRespawn ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Vehicle events}} |
Latest revision as of 03:06, 27 September 2018
This event is triggered when a vehicle is respawned due. See toggleVehicleRespawn.
Parameters
bool exploded
- exploded: true if this vehicle respawned because it exploded, false if it respawned due to being deserted.
Source
The source of this event is the vehicle that respawned.
Example
This example shows a message in the chatbox, if it is respawned.
function onVehicleRespawn ( exploded ) -- Add this variable. It contains the vehicle name of the respawned vehicle local vehicleName = getVehicleName ( source ) -- If it is exploded, echo a custom message if ( exploded == true ) then outputChatBox("A " .. vehiclename .. " has been respawned, after an explosion") -- else echo a normal message else outputChatBox("A " .. vehiclename .. " has been respawned") end end -- Add the Event Handler addEventHandler ( "onVehicleRespawn", getRootElement(), onVehicleRespawn )
See Also
Vehicle events
- onTrailerAttach
- onTrailerDetach
- onVehicleDamage
- onVehicleEnter
- onVehicleExit
- onVehicleExplode
- onVehicleRespawn
- onVehicleStartEnter
- onVehicleStartExit
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled