SetElementBonePosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 21: Line 21:


==Example==
==Example==
This example is a command where the player should input the bone ID and the XYZ coordinates to set one of his bones' position:
Este ejemplo muestra a un CJ sorprendido
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local bones = {
local bones = {
Line 36: Line 36:
     end
     end
end
end
addEventHandler ("onClientPedsProcessed", getRootElement(), updatePed)
addEventHandler("onClientPedsProcessed", root, updatePed)
</syntaxhighlight>
</syntaxhighlight>



Revision as of 06:50, 7 December 2021

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

[[{{{image}}}|link=|]] Tip: If you want to attach an element to a bone, see attachElementToBone.
[[{{{image}}}|link=|]] Note: You need to use this function together with onClientPedsProcessed.

Syntax

bool setElementBonePosition ( element theElement, int boneId, float x, float y, float z )

Required Arguments

  • theElement: the element to set the bone position on.
  • boneId: 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

Returns true if the function was successful, false otherwise.

Example

Este ejemplo muestra a un CJ sorprendido

local bones = {
    [4] = Vector3(0, 0, 0.15),
    [5] = Vector3(0, 0, 0.15),
    [6] = Vector3(0, 0, 0.13),
    [7] = Vector3(0, 0, 0.13),
    [8] = Vector3(0, 0, 0.1),
}
function updatePed()
    for bone,v in pairs(bones) do
        local pos = localPlayer:getBonePosition(bone)+v
        setElementBonePosition(localPlayer, bone, pos)
    end
end
addEventHandler("onClientPedsProcessed", root, updatePed)

Requirements

This template will be deleted.

See Also