GetVehicleTurretPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 4: Line 4:


==Syntax==
==Syntax==
float float [[GetVehicleTurretPosition]] ( [[vehicle]] vehicle )
<syntaxhighlight lang="lua">GetVehicleTurretPosition ( vehicle )</syntaxhighlight>


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


float [[GetVehicleTurretPosition|GetVehicleTurretPositionX]] ( [[vehicle]] vehicle )
<syntaxhighlight lang="lua">GetVehicleTurretPosition|GetVehicleTurretPositionX ( vehicle )</syntaxhighlight>


float [[GetVehicleTurretPosition|GetVehicleTurretPositionY]] ( [[vehicle]] vehicle )
<syntaxhighlight lang="lua">GetVehicleTurretPosition|GetVehicleTurretPositionY ( vehicle )</syntaxhighlight>
{{UsingRadians}}
{{UsingRadians}}
===Required Arguments===
===Required Arguments===
*'''vehicle''': The [[vehicle]] whose rotation you want to retrieve.
*'''vehicle''': The vehicle whose rotation you want to retrieve.


==Example==
==Example==
 
<syntaxhighlight lang="lua">newcar = createVehicle ( 520, 1024, 1024, 1024 )
newcar = [[createVehicle]] ( 520, 1024, 1024, 1024 )
x, y = GetVehicleTurretPosition ( newcar )  
x, y = [[GetVehicleTurretPosition]] ( newcar )
if (x)
serverChat ( "Turret position: ",x,",",y,"." )
if (x)
end</syntaxhighlight>
  [[serverChat]] ( "Turret position: ",x,",",y,"." )
end

Revision as of 02:59, 18 May 2006

Description

This function returns two floats containing the rotational position of the vehicle's turret along the horizontal and vertical axes (X and Y) respectively. This function can fail if the player is not in a vehicle, or if the vehicle does not have a turret. Vehicles with turrets include tanks and fire trucks. If this function does fail, the first argument will be set to 'false'.

Syntax

GetVehicleTurretPosition ( vehicle )

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

GetVehicleTurretPosition|GetVehicleTurretPositionX ( vehicle )
GetVehicleTurretPosition|GetVehicleTurretPositionY ( vehicle )

Template:UsingRadians

Required Arguments

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

Example

newcar = createVehicle ( 520, 1024, 1024, 1024 )
x, y = GetVehicleTurretPosition ( newcar ) 
if (x)
 serverChat ( "Turret position: ",x,",",y,"." )
end