GetVehicleCurrentGear

From Multi Theft Auto: Wiki
Revision as of 13:31, 1 February 2022 by Cleopatradev (talk | contribs) (Add OOP definitions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Gets the specified vehicle's current gear.

Syntax

int getVehicleCurrentGear ( vehicle theVehicle )

OOP Syntax Help! I don't understand this!

Method: vehicle:getGear(...)
Counterpart: .gear


Required Arguments

  • theVehicle: the vehicle to get the gear of

Returns

Returns the gear if successful, false otherwise.

Example

Click to collapse [-]
Client

Example of a program that outputs the current gear to the lower, center of the screen

function makeGearGui( )
	local sx, sy = guiGetScreenSize()
	local wx = 50
	local wy = 50
	gearLabel = guiCreateLabel(((sx / 2) - wx), (sy - wy), wx, wy, "5", false)
end
makeGearGui()

function onRender()
	g_vehicle = getPedOccupiedVehicle(localPlayer)
	if g_vehicle then
		g_curGear = tostring(getVehicleCurrentGear(g_vehicle))
		guiSetText(gearLabel, g_curGear)
	else
		guiSetText(gearLabel, "")
	end
end
addEventHandler("onClientRender", root, onRender)

See Also