SetElementBonePosition: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
This function sets the position of a bone to the specified coordinates. Currently the following element types are accepted: | |||
* [[Element/Player|Player]] | * [[Element/Player|Player]] | ||
* [[Element/Ped|Ped]] | * [[Element/Ped|Ped]] | ||
{{Tip|If you want to attach an element to a bone, see [[attachElementToBone]]}} | {{Tip|If you want to attach an element to a bone, see [[attachElementToBone]].}} | ||
{{Note|You need to use this function together with [[onClientPedsProcessed]].}} | {{Note|You need to use this function together with [[onClientPedsProcessed]].}} | ||
Line 15: | Line 15: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theElement:''' the element to set the bone position on. | *'''theElement:''' the element to set the bone position on. | ||
*'''bone:''' the ID of the bone to set the position of. See [[Bone IDs]] | *'''bone:''' 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 24: | Line 24: | ||
==Example== | ==Example== | ||
This example is a command where the player should input the bone ID | 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( | function setBonePosition (commandName, boneId, x, y, z) | ||
if (not | if (not boneId or not x or not y or not z) then | ||
outputChatBox("Syntax: | outputChatBox ("Syntax: /setbonepos boneID x y z", 255, 25, 25) | ||
return false | return false | ||
end | end | ||
if (not tonumber( | 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) | outputChatBox ("Command arguments should be numbers!", 255, 25, 25) | ||
return false | return false | ||
end | end | ||
setElementBonePosition(localPlayer, ID, x, y, z) | |||
outputChatBox("Bone position set successfully", 0, 255, 0) | setElementBonePosition (localPlayer, ID, x, y, z) | ||
outputChatBox ("Bone position set successfully!", 0, 255, 0) | |||
end | end | ||
addCommandHandler("setbonepos", setBonePosition) | |||
addCommandHandler ("setbonepos", setBonePosition) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Client_element_functions}} | {{Client_element_functions}} |
Revision as of 14:32, 19 September 2021
This function sets the position of a bone to the specified coordinates. Currently the following element types are accepted:
Tip: If you want to attach an element to a bone, see attachElementToBone. |
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
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)
See Also
- getElementBoneMatrix
- getElementBonePosition
- getElementBoneRotation
- getElementBoundingBox
- getElementDistanceFromCentreOfMassToBaseOfModel
- getElementLighting
- getElementRadius
- isElementCollidableWith
- isElementLocal
- isElementOnScreen
- isElementStreamable
- isElementStreamedIn
- isElementSyncer
- isElementWaitingForGroundToLoad
- setElementBoneMatrix
- setElementBonePosition
- setElementBoneRotation
- setElementCollidableWith
- setElementStreamable
- updateElementRpHAnim
- Shared
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement