GetElementBonePosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0160|1.5.8|20704|Returns the 3D world coordinates of a specific bone of a given element. Currently the following element...")
 
No edit summary
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{New feature/item|3.0160|1.5.8|20704|Returns the 3D world coordinates of a specific bone of a given [[element]]. Currently the following element types are accepted:
{{Added feature/item|1.5.9|1.5.8|20704|Returns the 3D world coordinates of a specific bone of a given [[element]]. Currently the [[Element/Player|Player]] and [[Element/Ped|Ped]] element types are accepted.}}
* [[Element/Player|Player]]
{{Tip|If you want to attach an element to a bone, see [[attachElementToBone]].}}
* [[Element/Ped|Ped]]
}}
{{Tip|If you want to attach an element to a bone, see [[attachElementToBone]]}}


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float, float, float getElementBonePosition ( element theElement, int bone )
float, float, float getElementBonePosition ( element theElement, int boneId )
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===
===Required Arguments===
*'''theElement:''' the element to get the bone position on.
*'''theElement:''' the [[element]] to get the bone position on.
*'''bone:''' the ID of the bone to get the position of. See [[Bone IDs]]
*'''boneId:''' the ID of the bone to get the position of. See [[Bone IDs]].


===Returns===
===Returns===
Returns the x, y, z world position of the bone.
Returns 3 [[Float|floats]], representing the X, Y, Z world position of the bone.


==Example==
==Example==
{{Needs Example}}
This example outputs the X, Y, Z world position of the local player bone specified through a command:
<syntaxhighlight lang="lua">
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)
</syntaxhighlight>
 
==Requirements==
{{Requirements|n/a|1.5.8-9.20704|}}


==See Also==
==See Also==
{{Client_element_functions}}
{{Client_element_functions}}

Latest revision as of 20:35, 23 September 2021

Returns the 3D world coordinates of a specific bone of a given element. Currently the Player and Ped element types are accepted.

[[{{{image}}}|link=|]] Tip: If you want to attach an element to a bone, see attachElementToBone.

Syntax

float, 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

Returns 3 floats, representing the X, Y, Z world position of the bone.

Example

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)

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

Shared