getElementBonePosition | Multi Theft Auto: Wiki Skip to content

getElementBonePosition

Client-side
Server-side
Shared

Pair: setElementBonePosition

Returns the 3D world coordinates of a specific bone of a given element. This can be a player or ped.

Tip

If you want to attach an element to a bone, see pAttach.

Syntax

float|false, ​float, ​float getElementBonePosition ( ​element theElement, ​int boneId )
Required Arguments
  • theElement: The element to get the bone position on.
  • boneId: The ID of the bone to get the position of. See Bone IDs.

Returns

  • float|false: x
  • float: y
  • float: z

Returns 3 floats, representing the X, Y, Z world position of the bone or false if invalid arguments were passed.

Code Examples

client

This example outputs the X, Y, Z world position of the local player bone specified through a command.

function getBonePosition(commandName, boneId)
if not tonumber(boneId) then
outputChatBox("You didn't insert an bone ID!", 255, 0, 0)
return false
end
local x, y, z = getElementBonePosition(localPlayer, boneId)
outputChatBox("The bone position is: " .. x .. ", " .. y .. ", " .. z)
end
addCommandHandler("getboneposition", getBonePosition)

See Also

Element Functions