OnPedWasted: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 17: | Line 17: | ||
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 died or got killed. | ||
==Example== | ==Example== | ||
This example outputs a text to chatbox when somebody dies/get killed | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | addEventHandler("onPedWasted", getRootElement(), function(totalAmmo,killer,killerWeapon,bodypart) | ||
if (getElementType(source)=="player") then -- we are checking if player died (not ped [bot]) | |||
if (isElement(killer)) then -- if killer is element that means somebody killed player | |||
if (killer==source) then -- if killer is same as player who died - he killed himself | |||
outputChatBox(getPlayerName(source).." commited suicide") | |||
else -- if killer is different than player who died -- somebody killed him | |||
outputChatBox(getPlayerName(source).." got killed by "..getPlayerName(killer)) | |||
end | |||
else -- if killer is not element - player just died, without a "killer" | |||
outputChatBox(getPlayerName(source).." died") | |||
end | |||
end | |||
end) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Ped_events}} | {{Ped_events}} |
Revision as of 12:17, 16 August 2010
This event is triggered when a ped is killed or dies.
Parameters
int totalAmmo, element killer, int killerWeapon, int bodypart [, bool stealth ]
- totalAmmo: an integer 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 integer representing the weapon the killer used to kill the player.
- bodypart: an integer representing the bodypart ID the victim was hit on when he died.
- 3: Torso
- 4: Ass
- 5: Left Arm
- 6: Right Arm
- 7: Left Leg
- 8: Right Leg
- 9: Head
- stealth: boolean value representing whether or not this was a stealth kill
Source
The source of this event is the ped that died or got killed.
Example
This example outputs a text to chatbox when somebody dies/get killed
addEventHandler("onPedWasted", getRootElement(), function(totalAmmo,killer,killerWeapon,bodypart) if (getElementType(source)=="player") then -- we are checking if player died (not ped [bot]) if (isElement(killer)) then -- if killer is element that means somebody killed player if (killer==source) then -- if killer is same as player who died - he killed himself outputChatBox(getPlayerName(source).." commited suicide") else -- if killer is different than player who died -- somebody killed him outputChatBox(getPlayerName(source).." got killed by "..getPlayerName(killer)) end else -- if killer is not element - player just died, without a "killer" outputChatBox(getPlayerName(source).." died") end end end)
See Also