GetVehicleGravity: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 13: Line 13:
Returns the x, y and z components of the gravity vector if successful, ''false'' otherwise.
Returns the x, y and z components of the gravity vector if successful, ''false'' otherwise.


==Example
==Example==
This command will get gravity of your vehicle using the /grav command
This command will get gravity of your vehicle using the /grav command
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">

Revision as of 11:39, 12 July 2017

Retrieves the current gravity vector of a vehicle. This is the direction in which the vehicle falls, also the cameras of any passengers will be rotated to match it.

Syntax

float float float getVehicleGravity ( vehicle theVehicle )

Required Arguments

  • theVehicle: the vehicle to retrieve the gravity vector of.

Returns

Returns the x, y and z components of the gravity vector if successful, false otherwise.

Example

This command will get gravity of your vehicle using the /grav command

addCommandHandler("grav",function()
	local vehicle = getPedOccupiedVehicle(localPlayer)
	if (vehicle) then
		local x,y,z = getVehicleGravity(vehicle)
		outputChatBox("Your vehicle's gravity is: "..x.." "..y.." "..z,0,255,0)
	end
end)

See Also