OnPedWasted: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Added onPedDamage event docs) |
||
Line 4: | Line 4: | ||
==Parameters== | ==Parameters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua">float healthDelta</syntaxhighlight> | ||
</syntaxhighlight> | |||
*'''deltaHealth''': an [[int]] representing the delta between old ped health and new health (oldHealth - newHealth). | |||
==Source== | ==Source== | ||
The [[event system#Event source|source]] of this event is the [[ped]] that | The [[event system#Event source|source]] of this event is the [[ped]] that got damaged. | ||
==Example== | ==Example== | ||
Line 21: | 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 | function onDamaged(delta) | ||
outputConsole("Your | outputConsole("Your ped is damaged!") | ||
outputConsole("delta was: " .. tostring(delta) | |||
end | end | ||
addEventHandler(" | addEventHandler("onPedDamage", ped1, onDamaged) --Add the Event when ped1 dies | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Ped events}} | {{See also/Server event|Ped events}} |
Revision as of 13:51, 19 August 2021
This event is triggered when a ped is killed or dies. It is not triggered for players.
Parameters
float healthDelta
- 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(delta) outputConsole("Your ped is damaged!") outputConsole("delta was: " .. tostring(delta) 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