SetElementBonePosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setElementBonePosition ( element theElement, int bone, float x, float y, float z )
bool setElementBonePosition ( element theElement, int boneId, float x, float y, float z )
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===
===Required Arguments===
*'''theElement:''' the element to set the bone position on.
*'''theElement:''' the [[Element|element]] to set the bone position on.
*'''bone:''' the ID of the bone to set the position of. See [[Bone IDs]].
*'''boneId:''' the ID of the bone to set the position of. See [[Bone IDs]].
*'''x:''' The X coordinate of the destination.
*'''x:''' The X coordinate of the destination.
*'''y:''' The Y coordinate of the destination.
*'''y:''' The Y coordinate of the destination.
Line 22: Line 22:


==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.
This example is a command where the player should input the bone ID and the XYZ coordinates to set one of his bones' position:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function setBonePosition (commandName, boneId, x, y, z)
function setBonePosition (commandName, boneId, x, y, z)
     if (not boneId or not x or not y or not z) then
     if (not boneId or not x or not y or not z) then
         outputChatBox ("Syntax: /setbonepos boneID x y z", 255, 25, 25)
         outputChatBox ("Syntax: /setbonepos [boneID, x, y, z]", 255, 25, 25)
         return false
         return false
     end
     end

Revision as of 14:53, 19 September 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

This example is a command where the player should input the bone ID and the XYZ coordinates to set one of his bones' position:

function setBonePosition (commandName, boneId, x, y, z)
    if (not boneId or not x or not y or not z) then
        outputChatBox ("Syntax: /setbonepos [boneID, x, y, z]", 255, 25, 25)
        return false
    end
    if (not tonumber(id) or not tonumber(x) or not tonumber(y) or not tonumber(z)) then
        outputChatBox ("Command arguments should be numbers!", 255, 25, 25)
        return false
    end

    setElementBonePosition (localPlayer, ID, x, y, z)
    outputChatBox ("Bone position set successfully!", 0, 255, 0)
end

addCommandHandler ("setbonepos", setBonePosition)

Requirements

Minimum server version n/a
Minimum client version 1.5.8-9.20704

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.5.8-9.20704" />

See Also