OnPedWasted: Difference between revisions
Jump to navigation
Jump to search
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. | ||
= | <section name="Example 1" class="server" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function pedDied(totalAmmo, killer, killerWeapon) | function pedDied(totalAmmo, killer, killerWeapon) | ||
if ( getElementType("killer") == "player" ) and ( getElementType("source") == "player" ) then | if ( getElementType("killer") == "player" ) and ( getElementType("source") == "player" ) then -- if the killer is a player and the ped who died is then | ||
outputChatBox( getPlayerName(source) .. " was killed by " .. getPlayerName(killer) .. " with " .. killerWeapon .. ".") | outputChatBox( getPlayerName(source) .. " was killed by " .. getPlayerName(killer) .. " with " .. killerWeapon .. ".")--Say who killed who with what weapon | ||
end | end | ||
end | end | ||
addEventHandler("onPedWasted", getRootElement(), pedDied) | addEventHandler("onPedWasted", getRootElement(), pedDied) -- onPedWasted the function pedDied gets called | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Ped_events}} | {{Ped_events}} |
Revision as of 16:10, 27 March 2012
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 killer weapon or the death reason.
- 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.
Click to collapse [-]
Example 1function pedDied(totalAmmo, killer, killerWeapon) if ( getElementType("killer") == "player" ) and ( getElementType("source") == "player" ) then -- if the killer is a player and the ped who died is then outputChatBox( getPlayerName(source) .. " was killed by " .. getPlayerName(killer) .. " with " .. killerWeapon .. ".")--Say who killed who with what weapon end end addEventHandler("onPedWasted", getRootElement(), pedDied) -- onPedWasted the function pedDied gets called
See Also