GetObjectRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
__NOTOC__
{{Server client function}}
{{Server client function}}
{{DeprecatedWithAlt|getElementRotation|}}
{{Deprecated|getElementRotation|}}
__NOTOC__
 
Object rotation can be retrieved from objects in mapfiles or objects that are created in scripts.  
Object rotation can be retrieved from objects in mapfiles or objects that are created in scripts.  


Line 25: Line 26:
     end
     end
end
end
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted )
addEventHandler ( "onPlayerTarget", root, onPlayerTargeted )
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
Line 36: Line 37:
     end
     end
end
end
addEventHandler ( "onClientPlayerTarget", getRootElement(), onPlayerTargeted )
addEventHandler ( "onClientPlayerTarget", root, onPlayerTargeted )
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Latest revision as of 08:06, 4 November 2020

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use getElementRotation instead.


Object rotation can be retrieved from objects in mapfiles or objects that are created in scripts.

Syntax

float float float getObjectRotation ( object theObject )       

Required Arguments

  • theObject: The object whose rotation will be retrieved

Returns

Returns three floats if object exists, false in the first variable and nil in the other two if it's invalid.

Example

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

Click to collapse [-]
Server
function onPlayerTargeted ( targetElem )
    if ( isElement(targetElem) and getElementType(targetElem) == "object" ) then
        local x,y,z = getObjectRotation ( targetElem )
        outputChatBox ( "Object rotation: " .. x .. " " .. y .. " " .. z, source )
    end
end
addEventHandler ( "onPlayerTarget", root, onPlayerTargeted )
Click to expand [+]
Client

See Also