OnPedDamage: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 16: | Line 16: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
ped1 = createPed(112, 0, 0, 0) --Create our Ped | ped1 = createPed(112, 0, 0, 0) --Create our Ped | ||
function onDamaged( | function onDamaged(deltaHealth) | ||
outputConsole("Your ped is damaged!") | outputConsole("Your ped is damaged!") | ||
outputConsole("delta was: " .. tostring( | outputConsole("delta was: " .. tostring(deltaHealth)) | ||
end | end | ||
addEventHandler("onPedDamage", ped1, onDamaged) --Add the Event when ped1 dies | addEventHandler("onPedDamage", ped1, onDamaged) --Add the Event when ped1 dies |
Revision as of 13:55, 19 August 2021
This event is triggered when a ped is killed or dies. It is not triggered for players.
Parameters
float deltaHealth
- deltaHealth: an int representing the delta between old ped health and new health (oldHealth - newHealth).
Source
The source of this event is the ped that got damaged.
Example
This example outputs to the console that the ped is now dead.
ped1 = createPed(112, 0, 0, 0) --Create our Ped function onDamaged(deltaHealth) outputConsole("Your ped is damaged!") outputConsole("delta was: " .. tostring(deltaHealth)) end addEventHandler("onPedDamage", ped1, onDamaged) --Add the Event when ped1 dies
See Also
Ped events
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled