getBodyPartName | Multi Theft Auto: Wiki Skip to content

getBodyPartName

Client-side
Server-side
Shared

This function is used to get the name of a body part on a player.

Syntax

string|false getBodyPartName ( int bodyPartID )
Required Arguments
  • bodyPartID: An integer 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

  • string|false: body part name

This function returns a string containing the body part name if the ID is valid, false otherwise.

Code Examples

server

This example prints the killer and body part to the chat on the wasted/kill event.

function deathMessageOnWasted(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 = getPlayerName(attacker) .. " killed " ..getPlayerName(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(getPlayerName(source) .. " died. (" ..getWeaponNameFromID(weapon) .. ") (" ..getBodyPartName(bodypart) .. ")")
end
else
outputChatBox(getPlayerName(source) .. " died. (" ..getWeaponNameFromID(weapon) .. ") (" ..getBodyPartName(bodypart) .. ")")
end
end
addEventHandler("onPlayerWasted", root, deathMessageOnWasted)