OnPlayerWasted
Jump to navigation
Jump to search
This event is triggered when a player dies.
Syntax
void onPlayerWasted ( int totalammo, player killer, int killerweapon, int bodypart )
Variables
- The source of this event refers to the player who died.
- totalammo: An integer representing the total ammo the player had when he died
- killer: A player element representing the player who was the killer. If there was no killer this returns false.
- killerweapon: An integer representing the weapon the killer used to kill the player
- bodypart: An integer representing the bodypart ID the player was hit on when he died.
- 3: Torso
- 4: Ass
- 5: Left Arm
- 6: Right Arm
- 7: Left Leg
- 8: Right Leg
- 9: Head
Example
This example prints the killer and body part to the chat on the wasted/kill event.
addEventHandler ( "onPlayerWasted", getElementRoot(), "onPlayerWasted" ) function onPlayerWasted ( ammo, attacker, weapon, bodypart ) if ( attacker ) then -- if we have an attacker if ( getElementType ( attacker ) == "player" ) then -- make sure the element that killed him was a player tempString = getClientName ( attacker ).." killed "..getClientName ( source ).." ("..getWeaponNameFromID ( weapon )..")" if ( bodypart == 9 ) then -- if he was shot in the head tempString = tempString.." (HEADSHOT!)" else tempString = tempString.." ("..getBodyPartName ( bodypart )..")" end chat ( tempString ) else chat ( getClientName ( source ).." died. ("..getWeaponNameFromID ( weapon )..") ("..getBodyPartName ( bodypart )..")" ) end else chat ( getClientName ( source ).." died. ("..getWeaponNameFromID ( weapon )..") ("..getBodyPartName ( bodypart )..")" ) end end