OnPlayerWasted: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 18: | Line 18: | ||
This example prints the killer and body part to the chat on the wasted/kill event. | This example prints the killer and body part to the chat on the wasted/kill event. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addEventHandler ( "onPlayerWasted", getElementRoot(), " | addEventHandler ( "onPlayerWasted", getElementRoot(), "player_Wasted" ) | ||
function | function player_Wasted ( ammo, attacker, weapon, bodypart ) | ||
if ( attacker ) then -- if we have an attacker | if ( attacker ) then -- if we have an attacker | ||
if ( getElementType ( attacker ) == "player" ) then -- make sure the element that killed him was a player | if ( getElementType ( attacker ) == "player" ) then -- make sure the element that killed him was a player |
Revision as of 18:35, 22 April 2007
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(), "player_Wasted" ) function player_Wasted ( 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