Difference between revisions of "GetVehicleRotation"

From Multi Theft Auto: Wiki
Line 1: Line 1:
 +
{{Needs_Checking|Does the function really start with a capital G? [[User:Erorr404|Erorr404]]}}
 +
 
__NOTOC__
 
__NOTOC__
 
==Description==
 
==Description==
This function returns three floats containing the rotational position of the vehicle along the X, Y, and Z axes respectively as degrees. If this function does fail, it will return 'false'.
+
This function gets the rotation of a vehicle along the X, Y, and Z axes in degrees.
  
 
==Syntax==
 
==Syntax==
<syntaxhighlight lang="lua">GetVehicleRotation ( vehicle )</syntaxhighlight>
+
<syntaxhighlight lang="lua">float float float GetVehicleRotation ( vehicle )</syntaxhighlight>
  
This function also has three variants that allow you to retrieve data from just one of the three axis.
+
This function also has three variants that allow you to retrieve data from just one of the three axes.
  
<syntaxhighlight lang="lua">GetVehicleRotation|GetVehicleRotationX ( vehicle )</syntaxhighlight>
+
<syntaxhighlight lang="lua">float GetVehicleRotationX ( vehicle )</syntaxhighlight>
  
<syntaxhighlight lang="lua">GetVehicleRotation|GetVehicleRotationY ( vehicle )</syntaxhighlight>
+
<syntaxhighlight lang="lua">float GetVehicleRotationY ( vehicle )</syntaxhighlight>
  
<syntaxhighlight lang="lua">GetVehicleRotation|GetVehicleRotationZ ( vehicle )</syntaxhighlight>
+
<syntaxhighlight lang="lua">float GetVehicleRotationZ ( vehicle )</syntaxhighlight>
  
 
===Required Arguments===
 
===Required Arguments===
 
*'''vehicle''': The [[vehicle]] whose rotation you want to retrieve.
 
*'''vehicle''': The [[vehicle]] whose rotation you want to retrieve.
 +
 +
===Returns===
 +
Returns three ''floats'' indicating the X, Y, and Z rotations of the vehicle in degrees (one ''float'' for a variant function), or ''false'' if the specified vehicle does not exist.
  
 
==Example==
 
==Example==
<syntaxhighlight lang="lua">newcar = createVehicle ( 520, 1024, 1024, 1024 )
+
This example creates a vehicle and gets it's rotation:
x, y, z = GetVehicleRotation ( newcar )
+
<syntaxhighlight lang="lua">local newcar = createVehicle ( 520, 1024, 1024, 1024 ) -- create a Hydra
if (x)
+
local rx, ry, rz = GetVehicleRotation ( newcar ) -- get the vehicle's x, y, and z rotations and store them in rx, ry, and rz
outputChatBox ( "Current rotation: ", x, " ," ,y ," ," ,z , "." )
+
outputChatBox ( "Current rotation: " .. x .. " " .. y .. " " .. z ) -- output the rotations
end</syntaxhighlight>
+
</syntaxhighlight>
  
 
==See Also==
 
==See Also==
 
{{Vehicle functions}}
 
{{Vehicle functions}}

Revision as of 04:12, 17 September 2006

Dialog-information.png This article needs checking.

Reason(s): Does the function really start with a capital G? Erorr404


Description

This function gets the rotation of a vehicle along the X, Y, and Z axes in degrees.

Syntax

float float float GetVehicleRotation ( vehicle )

This function also has three variants that allow you to retrieve data from just one of the three axes.

float GetVehicleRotationX ( vehicle )
float GetVehicleRotationY ( vehicle )
float GetVehicleRotationZ ( vehicle )

Required Arguments

  • vehicle: The vehicle whose rotation you want to retrieve.

Returns

Returns three floats indicating the X, Y, and Z rotations of the vehicle in degrees (one float for a variant function), or false if the specified vehicle does not exist.

Example

This example creates a vehicle and gets it's rotation:

local newcar = createVehicle ( 520, 1024, 1024, 1024 ) -- create a Hydra
local rx, ry, rz = GetVehicleRotation ( newcar ) -- get the vehicle's x, y, and z rotations and store them in rx, ry, and rz
outputChatBox ( "Current rotation: " .. x .. " " .. y .. " " .. z ) -- output the rotations

See Also