Notice: Failed to invoke Pygments: [Called from MediaWiki\SyntaxHighlight\SyntaxHighlight::highlightInner in /home/pi/www/gtac/wiki/wiki/extensions/SyntaxHighlight_GeSHi/includes/SyntaxHighlight.php at line 334] in /home/pi/www/gtac/wiki/wiki/includes/debug/MWDebug.php on line 507
Set Wheel Status - GTA Connected

Set Wheel Status

Revision as of 19:43, 14 August 2018 by Mex (talk | contribs) (Created page with "{{DISPLAYTITLE:Set Wheel Status}} == Description == This code allows anyone who types the command "/wheel wheel status" whilst in a vehicle, to have the specified status appli...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

This code allows anyone who types the command "/wheel wheel status" whilst in a vehicle, to have the specified status applied to the specified wheel.

Code

Lua, Client-Side, GTAC versions 1.0.72 and newer:

addCommandHandler('wheel', function(cmd,args)
	args = split(args)
	local wheel = tonumber(args[1]) or 0
	local status = tonumber(args[2]) or 3
	localPlayer.vehicle:setWheelStatus(wheel, status)
end)

-- https://stackoverflow.com/questions/1426954/split-string-in-lua
function split(inputstr, sep)
	if sep == nil then
		sep = "%s"
	end
	local t={} ; i=1
	for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
		t[i] = str
		i = i + 1
	end
	return t
end