OnPedWasted: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Added onPedDamage event docs)
Line 4: Line 4:


==Parameters==
==Parameters==
<syntaxhighlight lang="lua">int totalAmmo, element killer, int killerWeapon, int bodypart, bool stealth
<syntaxhighlight lang="lua">float healthDelta</syntaxhighlight>
</syntaxhighlight>
 
*'''deltaHealth''': an [[int]] representing the delta between old ped health and new health (oldHealth - newHealth).


*'''totalAmmo''': an [[int]] representing the total ammo the victim had when he died.
*'''killer''': an [[element]] representing the player or vehicle who was the killer.  If there was no killer this is ''false''.
*'''killerWeapon''': an [[int]] representing the [[Weapons|killer weapon]] or the [[Damage Types|damage types]].
*'''bodypart''': an [[int]] representing the bodypart ID the victim was hit on when he died.
{{BodyParts}}
*'''stealth''': a [[boolean]] representing whether or not this was a stealth kill.


==Source==
==Source==
The [[event system#Event source|source]] of this event is the [[ped]] that died or got killed.
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 died()
function onDamaged(delta)
     outputConsole("Your Ped is dead now!")
     outputConsole("Your ped is damaged!")
    outputConsole("delta was: " .. tostring(delta)
end
end
addEventHandler("onPedWasted", ped1, died) --Add the Event when ped1 dies
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