GetElementRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{Server client function}}
{{Server client function}}
__NOTOC__  
__NOTOC__
Retrieve the rotation of elements.
Retrieve the rotation of elements. '''Only clientside before 1.0.4'''
 
== Only clientside before 1.0.4 ==


==Syntax==
==Syntax==
Line 14: Line 12:


===Optional Arguments===  
===Optional Arguments===  
{{New feature|33.0110|1.1|
{{New feature/item|3.0110|1.1|
*'''rotOrder:''' A string representing the rotation order desired when returning the [http://en.wikipedia.org/wiki/Euler_angles euler angles]. If omitted, default value is ''"default"''. Allowed values are:
*'''rotOrder:''' A string representing the rotation order desired when returning the [http://en.wikipedia.org/wiki/Euler_angles 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
**''"default":'' default MTA behavior prior to 1.1, where rotation order depends on element type

Revision as of 08:10, 21 November 2011

Retrieve the rotation of elements. Only clientside before 1.0.4

Syntax

float float float getElementRotation ( element theElement [, string rotOrder = "default" ] )       

Required Arguments

  • theElement: The element whose rotation will be retrieved

Optional Arguments

{{{4}}}

Returns

  • rx, ry, rz: 3 floats representing the Euler rotation angles on the axis X, Y and Z (with the rotation order depending on the rotOrder argument) if element exists and is a valid element, false if it's invalid.

Example

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

Click to collapse [-]
Client
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", getRootElement(), onPlayerTargeted )

See Also