GetObjectRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:
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.  


==Syntax==  
==Syntax==
<section name="Server" class="server">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float float float getObjectRotation ( object theObject )       
float float float getObjectRotation ( object theObject )       
Line 12: Line 13:
===Returns===
===Returns===
Returns three ''float'' if object exists, ''false'' in the first variable and ''nil'' in the other two if it's invalid.
Returns three ''float'' if object exists, ''false'' in the first variable and ''nil'' in the other two if it's invalid.
</section>
<section name="Client" class="client">
<syntaxhighlight lang="lua">
float float float getObjectRotation ( object theObject )     
</syntaxhighlight>
===Required Arguments===
*'''theObject:''' The object whose rotation will be retrieved
===Returns===
Returns three ''float'' if object exists, ''false'' in the first variable and ''nil'' in the other two if it's invalid.
</section>


==Example==  
==Example==  
If a player points at an object with a gun, it will output it's rotation to the player.
If a player points at an object with a gun, it will output it's rotation to the player.
<section name="Server" class="server">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function onPlayerTargeted ( element )
function onPlayerTargeted ( element )
Line 24: Line 38:
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted )
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted )
</syntaxhighlight>
</syntaxhighlight>
</section>
<section name="Client" class="client">
function onPlayerTargeted ( element )
    if ( isElement(element) and getElementType ( element ) == "object") then
local x,y,z = getObjectRotation(element)
        outputChatBox("Object rotation: "..x.." "..y.." "..z,source)
    end
end
addEventHandler ( "onClientPlayerTarget", getRootElement(), onPlayerTargeted )
</section>


==See Also==
==See Also==
{{Object functions}}
{{Object functions}}

Revision as of 12:37, 3 August 2007

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

Syntax

Click to expand [+]
Server
Click to expand [+]
Client

Example

If a player points at an object with a gun, it will output it's rotation to the player.

Click to expand [+]
Server
Click to expand [+]
Client

See Also

Shared