OnVehicleDamage: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
King Hjwalh (talk | contribs) |
||
Line 19: | Line 19: | ||
local thePlayer = getVehicleOccupant(source) | local thePlayer = getVehicleOccupant(source) | ||
if(thePlayer) then -- Check there is a player in the vehicle | if(thePlayer) then -- Check there is a player in the vehicle | ||
outputChatBox("Your vehicle just lost " .. tonumber(loss) .. " health.", thePlayer) -- Display the message | outputChatBox("Your vehicle just lost " .. tonumber(loss) .. " You Should Fix It health.", thePlayer) -- Display the message | ||
end | end | ||
end | end |
Revision as of 14:46, 27 March 2014
This event is triggered when a vehicle is damaged.
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
This example displays a message with the amount of health lost when a vehicle gets damaged.
function displayVehicleLoss(loss) local thePlayer = getVehicleOccupant(source) if(thePlayer) then -- Check there is a player in the vehicle outputChatBox("Your vehicle just lost " .. tonumber(loss) .. " You Should Fix It health.", thePlayer) -- Display the message 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