GetVehicleCurrentGear: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with '__NOTOC__ {{Client function}} Gets the specified vehicle's current gear. ==Syntax== <syntaxhighlight lang="lua"> int getVehicleCurrentGear ( vehicle theVehicle ) </syntaxhighlight> ===Required Argume…')
 
No edit summary
Line 23: Line 23:
g_root = getRootElement()
g_root = getRootElement()


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


function onRender()
function onRender()

Revision as of 14:24, 3 July 2010

Gets the specified vehicle's current gear.

Syntax

int getVehicleCurrentGear ( vehicle theVehicle )

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


g_player = getLocalPlayer()
g_root = getRootElement()

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

function onRender()
	g_vehicle = getPedOccupiedVehicle(g_player)
	if g_vehicle then
		g_curGear = tostring(getVehicleCurrentGear(g_vehicle))
		guiSetText(gearLabel,g_curGear)
	else
		guiSetText(gearLabel,"")
	end
end

makeGearGui()
addEventHandler("onClientRender",g_root,onRender)

See Also