M MY Multiplayer: Wiki
Side
Kind

setElementBoneMatrix

Client

Sets the world matrix of a ped's or object's bone: position, orientation and scale at once. The change applies on this client only.

bool setElementBoneMatrix(ped|object element, int|string bone, table matrix)

Parameters

NameTypeDescription
elementped|objectThe ped, player or object. An object needs a model with a skeleton or a node tree.
boneint|stringThe bone. On a ped: an MTA bone id, a rig bone's tag or its name. On an object: a node's name or a bone's tag.
matrixtableThe world matrix, in the shape getElementBoneMatrix returns: four rows of four numbers.

Returns

true if it was set, false if the element is streamed out.

A ped's pose and an animated object's pose are rebuilt every frame: change them in onClientPedsProcessed, which fires once the frame's poses are built. An object without an animation keeps what was set. Whatever is attached to the bone follows it.

Example

addEventHandler("onClientPedsProcessed", root, function()
    local matrix = getElementBoneMatrix(localPlayer, 24)
    if matrix then
        matrix[4][3] = matrix[4][3] + 0.2
        setElementBoneMatrix(localPlayer, 24, matrix)
    end
end)
Coming from MTAIn MTA it works on peds only. Here it also takes objects and rig bones by tag or name.
NoteRaises an error if the element has no such bone. While the element is streamed out, it returns false.

See also