GetBodyPartName: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 18: | Line 18: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onPlayerWasted ( ammo, attacker, weapon, bodypart ) | 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 | |||
outputChatBox ( tempString ) | |||
else | |||
outputChatBox ( getClientName ( source ) .. " died. (" .. getWeaponNameFromID ( weapon ) .. ") (" .. getBodyPartName ( bodypart ) .. ")" ) | |||
end | |||
else | |||
outputChatBox ( getClientName ( source ) .. " died. (" .. getWeaponNameFromID ( weapon ) .. ") (" .. getBodyPartName ( bodypart ) .. ")" ) | |||
end | |||
end | end | ||
addEventHandler ( "onPlayerWasted", getRootElement(), onPlayerWasted ) | addEventHandler ( "onPlayerWasted", getRootElement(), onPlayerWasted ) |
Revision as of 14:25, 15 August 2007
This function is used to get the name of a body part on a player.
Syntax
string getBodyPartName ( int bodyPartID )
Required Arguments
- bodyPartID: An interger representing the body part ID you wish to retrieve the name of.
- 3: Torso
- 4: Ass
- 5: Left Arm
- 6: Right Arm
- 7: Left Leg
- 8: Right Leg
- 9: Head
Returns
This function returns a string containing the body part name if the ID is valid, 'false' otherwise.
Example
This example prints the killer and body part to the chat on the wasted/kill event.
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 outputChatBox ( tempString ) else outputChatBox ( getClientName ( source ) .. " died. (" .. getWeaponNameFromID ( weapon ) .. ") (" .. getBodyPartName ( bodypart ) .. ")" ) end else outputChatBox ( getClientName ( source ) .. " died. (" .. getWeaponNameFromID ( weapon ) .. ") (" .. getBodyPartName ( bodypart ) .. ")" ) end end addEventHandler ( "onPlayerWasted", getRootElement(), onPlayerWasted )
See Also
- addPedClothes
- getBodyPartName
- getClothesByTypeIndex
- getClothesTypeName
- getPedClothes
- getTypeIndexFromClothes
- removePedClothes