getElementRotation | Multi Theft Auto: Wiki Skip to content

getElementRotation

Client-side
Server-side
Shared

Pair: setElementRotation

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


Retrieve the rotation of elements.

OOP Syntax Help! I don't understand this!

  • Method:element:getRotation(...)
  • Variable: .rotation

Syntax

float,​ float,​ float getElementRotation ( element theElement, [ string rotOrder = "default" ] )
Required Arguments
  • theElement: The element whose rotation will be retrieved
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • rotOrder (default: "default"): A string representing the rotation order desired when returning the euler angles . If omitted, default value is "default" . Allowed values are: "default": default MTA behavior prior to 1.1, where rotation order depends on element type "ZXY": rotation about the Z axis ( up ), then about the resulting X axis ( right ) and finally about the resulting Y axis ( front ). This is the default rotation order for objects "ZYX": rotation about the Z axis ( up ), then about the resulting Y axis ( front ), and finally about the resulting X axis ( right ). This is the default rotation order for vehicles

Returns

  • float: x
  • float: y
  • float: z

If a player points at a player element with a gun, its rotation will appear in the chat box.

Code Examples

shared
function onPlayerTargeted ( targetElem )
if ( isElement(targetElem) and getElementType (targetElem) == "player" ) then
local x,y,z = getElementRotation ( targetElem )
outputChatBox ( "Target player rotation: " .. x .. " " .. y .. " " .. z )
end
end
addEventHandler ( "onClientPlayerTarget", root, onPlayerTargeted )

See Also

Element Functions