OnVehicleDamage: Difference between revisions
Jump to navigation
Jump to search
m (See Also for server events) |
|||
Line 14: | Line 14: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function displayVehicleLoss(loss) | |||
local thePlayer = getVehicleOccupant(source) | |||
if(thePlayer) then | |||
outputChatBox("Your vehicle just lost " .. tonumber(loss) .. " health.", thePlayer) | |||
end | |||
end | |||
addEventHandler("onVehicleDamage", getRootElement(), displayVehicleLoss) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Vehicle events}} | {{See also/Server event|Vehicle events}} | ||
Revision as of 06:11, 11 May 2008
This event is triggered when a vehicle encounters damage.
Parameters
float loss
- loss: A float representing the amount of health the vehicle lost.
Source
The source of this event is the vehicle that got damaged.
Example
function displayVehicleLoss(loss) local thePlayer = getVehicleOccupant(source) if(thePlayer) then outputChatBox("Your vehicle just lost " .. tonumber(loss) .. " health.", thePlayer) end end addEventHandler("onVehicleDamage", getRootElement(), displayVehicleLoss)
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