setElementBonePosition | Multi Theft Auto: Wiki Skip to content

setElementBonePosition

Client-side
Server-side
Shared

Pair: getElementBonePosition

This function sets the position of a bone to the specified coordinates. Currently the player and ped element types are accepted.

Note

You need to use this function together with onClientPedsProcessed.

Tip

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

Syntax

bool setElementBonePosition ( ​element theElement, ​int bone, ​float x, ​float y, ​float z )
Required Arguments
  • theElement: The element to set the bone position on.
  • bone: The ID of the bone to set the position of. See Bone IDs.
  • x: The X coordinate of the destination.
  • y: The Y coordinate of the destination.
  • z: The Z coordinate of the destination.

Returns

  • bool: result

Returns true if the function was successful, false otherwise.

Code Examples

client

This example shows a surprised CJ with a long neck.

local bones = {
[4] = {0, 0, 0.15},
[5] = {0, 0, 0.15},
[6] = {0, 0, 0.13},
[7] = {0, 0, 0.13},
[8] = {0, 0, 0.1},
}
function updatePed()
for bone, v in pairs(bones) do
local boneX, boneY, boneZ = getElementBonePosition(localPlayer, bone)
setElementBonePosition(localPlayer, bone, boneX + v[1], boneY + v[2], boneZ + v[3])
end
end
addEventHandler("onClientPedsProcessed", root, updatePed)

See Also

Element Functions