<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=NOki</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=NOki"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/NOki"/>
	<updated>2026-04-05T14:14:54Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetVehicleHandling&amp;diff=72997</id>
		<title>SetVehicleHandling</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetVehicleHandling&amp;diff=72997"/>
		<updated>2021-11-02T09:08:11Z</updated>

		<summary type="html">&lt;p&gt;NOki: Added reference to helicopters and other aircraft as per #2426&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function is used to change the handling data of a vehicle.&lt;br /&gt;
&lt;br /&gt;
{{New feature/item|3.0156|1.5.5|12009|Implemented also for client-sided vehicles.}}&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setVehicleHandling(element theVehicle, string property, var value) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Syntaxes for reset configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setVehicleHandling(element theVehicle, string property, nil, false)  -- Reset one property to model handling value&lt;br /&gt;
bool setVehicleHandling(element theVehicle, string property, nil, true)   -- Reset one property to GTA default value&lt;br /&gt;
bool setVehicleHandling(element theVehicle, false)                        -- Reset all properties to model handling value&lt;br /&gt;
bool setVehicleHandling(element theVehicle, true)                         -- Reset all properties to GTA default value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theVehicle:''' The vehicle you wish to set the handling of.&lt;br /&gt;
*'''property:''' The property you wish to set the handling of the vehicle to.&lt;br /&gt;
&lt;br /&gt;
{{Note|For functionality reasons, suspension modification is disabled on monster trucks, trains, boats and trailers.&lt;br /&gt;
Additionally, helicopters are not affected by custom handling. The vehicle-on-wheels handling does not affect planes when they are on the ground either.}}&lt;br /&gt;
{{Warning|To change handling values of aircraft like ''maxVelocity'', you must first set [[SetAircraftMaxVelocity|setAircraftMaxVelocity]].}}&lt;br /&gt;
&lt;br /&gt;
{{Handling Properties}}&lt;br /&gt;
*'''value:''' The value of the property you wish to set the handling of the vehicle to.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the handling was set successfully, ''false'' otherwise. See below a list of valid properties and their required values:&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example will make Infernus handling very fast and also make it damage proof from collision (handling by Mr.unpredictable).&lt;br /&gt;
this example will help you in creating your own vehicle handling.&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function vhandling ( theVehicle )&lt;br /&gt;
    if getElementModel(theVehicle) == 411 then -------------- vehicle Id&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;mass&amp;quot;, 300.0)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;turnMass&amp;quot;, 200)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;dragCoeff&amp;quot;, 4.0 )&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;centerOfMass&amp;quot;, { 0.0,0.08,-0.09 } )&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;percentSubmerged&amp;quot;, 103)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;tractionMultiplier&amp;quot;, 1.8)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;tractionLoss&amp;quot;, 1.0)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;tractionBias&amp;quot;, 0.48)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;numberOfGears&amp;quot;, 5)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;maxVelocity&amp;quot;, 300.0)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;engineAcceleration&amp;quot;, 90.0 )&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;engineInertia&amp;quot;, 5.0)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;driveType&amp;quot;, &amp;quot;rwd&amp;quot;)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;engineType&amp;quot;, &amp;quot;petrol&amp;quot;)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;brakeDeceleration&amp;quot;, 20.0)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;brakeBias&amp;quot;, 0.60)&lt;br /&gt;
        -----abs----&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;steeringLock&amp;quot;,  35.0 )&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;suspensionForceLevel&amp;quot;, 0.85)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;suspensionDamping&amp;quot;, 0.15 )&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;suspensionHighSpeedDamping&amp;quot;, 0.0)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;suspensionUpperLimit&amp;quot;, 0.15 )&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;suspensionLowerLimit&amp;quot;, -0.16)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;suspensionFrontRearBias&amp;quot;, 0.5 )&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;suspensionAntiDiveMultiplier&amp;quot;, 0.0)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;seatOffsetDistance&amp;quot;, 0.0)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;collisionDamageMultiplier&amp;quot;, 0.00)&lt;br /&gt;
        --setVehicleHandling(theVehicle, &amp;quot;monetary&amp;quot;,  10000) This one is disabled for now&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;modelFlags&amp;quot;, 1002000)&lt;br /&gt;
        setVehicleHandling(theVehicle, &amp;quot;handlingFlags&amp;quot;, 1000002)&lt;br /&gt;
        --setVehicleHandling(theVehicle, &amp;quot;headLight&amp;quot;, 3) This one is disabled for now&lt;br /&gt;
        --setVehicleHandling(theVehicle, &amp;quot;tailLight&amp;quot;, 2) This one is disabled for now&lt;br /&gt;
        --setVehicleHandling(theVehicle, &amp;quot;animGroup&amp;quot;, 4) This one is disabled for now&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement(), vhandling )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example will add a command for players with which they can change the mass of the vehicle.&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;	 &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function massChange ( me, command, mass )&lt;br /&gt;
    local mass = tonumber ( mass ) -- Convert mass to a number&lt;br /&gt;
    local veh = getPedOccupiedVehicle ( me ) -- Get the player's vehicle&lt;br /&gt;
    &lt;br /&gt;
    if mass and veh then  -- If valid mass and in a vehicle&lt;br /&gt;
        local success = setVehicleHandling ( veh, &amp;quot;mass&amp;quot;, mass) -- Set the vehicle's mass, and check if successful&lt;br /&gt;
        &lt;br /&gt;
        if success then -- If successful&lt;br /&gt;
            outputChatBox ( &amp;quot;Your vehicle's mass has been changed to: &amp;quot;..mass..&amp;quot; kg&amp;quot;, me, 0, 255, 0 ) -- Notify the player of success&lt;br /&gt;
        else -- Too bad failure is still an option&lt;br /&gt;
            outputChatBox ( &amp;quot;Setting mass failed. It's probably above or below allowed limits&amp;quot;, me, 255, 0, 0 ) -- Notify the player of failure, and give a possible reason&lt;br /&gt;
        end&lt;br /&gt;
    elseif not veh then -- If not in a vehicle&lt;br /&gt;
        outputChatBox ( &amp;quot;You're not in a vehicle&amp;quot;, me, 255, 0, 0 ) -- Tell the player; He / she obviously doesn't know&lt;br /&gt;
    elseif not mass then -- If not a valid mass&lt;br /&gt;
        outputChatBox ( &amp;quot;Syntax: /changemass [mass]&amp;quot;, me, 255, 0, 0 ) -- Tell the player the proper syntax&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;changemass&amp;quot;, massChange )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example will apply custom handling as defined for each specific vehicle (ID) in below table&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;	 &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local predefinedHandling = {&lt;br /&gt;
	[411] = {&lt;br /&gt;
		[&amp;quot;engineAcceleration&amp;quot;] = 14,&lt;br /&gt;
		[&amp;quot;dragCoeff&amp;quot;] = 0,&lt;br /&gt;
		[&amp;quot;maxVelocity&amp;quot;] = 100000,&lt;br /&gt;
		[&amp;quot;tractionMultiplier&amp;quot;] = 0.9,&lt;br /&gt;
		[&amp;quot;tractionLoss&amp;quot;] = 1.1,&lt;br /&gt;
	},&lt;br /&gt;
	[415] = {&lt;br /&gt;
		[&amp;quot;engineAcceleration&amp;quot;] = 14,&lt;br /&gt;
		[&amp;quot;dragCoeff&amp;quot;] = 0,&lt;br /&gt;
		[&amp;quot;maxVelocity&amp;quot;] = 100000,&lt;br /&gt;
		[&amp;quot;tractionMultiplier&amp;quot;] = 0.9,&lt;br /&gt;
		[&amp;quot;tractionLoss&amp;quot;] = 1.1,&lt;br /&gt;
	},&lt;br /&gt;
		[562] = { -- Universal drift handling&lt;br /&gt;
		[&amp;quot;driveType&amp;quot;] = &amp;quot;rwd&amp;quot;,&lt;br /&gt;
		[&amp;quot;engineAcceleration&amp;quot;] = 200,&lt;br /&gt;
		[&amp;quot;dragCoeff&amp;quot;] = 1.5,&lt;br /&gt;
		[&amp;quot;maxVelocity&amp;quot;] = 300,&lt;br /&gt;
		[&amp;quot;tractionMultiplier&amp;quot;] = 0.7,&lt;br /&gt;
		[&amp;quot;tractionLoss&amp;quot;] = 0.8,&lt;br /&gt;
		[&amp;quot;collisionDamageMultiplier&amp;quot;] = 0.4,&lt;br /&gt;
		[&amp;quot;engineInertia&amp;quot;] = -175,&lt;br /&gt;
		[&amp;quot;steeringLock&amp;quot;] = 75,&lt;br /&gt;
		[&amp;quot;numberOfGears&amp;quot;] = 4,&lt;br /&gt;
		[&amp;quot;suspensionForceLevel&amp;quot;] = 0.8,&lt;br /&gt;
		[&amp;quot;suspensionDamping&amp;quot;] = 0.8,&lt;br /&gt;
		[&amp;quot;suspensionUpperLimit&amp;quot;] = 0.33,&lt;br /&gt;
		[&amp;quot;suspensionFrontRearBias&amp;quot;] = 0.3,&lt;br /&gt;
		[&amp;quot;mass&amp;quot;] = 1800,&lt;br /&gt;
		[&amp;quot;turnMass&amp;quot;] = 3000,&lt;br /&gt;
		[&amp;quot;centerOfMass&amp;quot;] = { [1]=0, [2]=-0.2, [3]=-0.5 }, -- Good example to understand centerOfMass parameter usage&lt;br /&gt;
	},&lt;br /&gt;
&lt;br /&gt;
	--next model below etc (copy rows)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
for i,v in pairs (predefinedHandling) do&lt;br /&gt;
	if i then&lt;br /&gt;
		for handling, value in pairs (v) do&lt;br /&gt;
			if not setModelHandling (i, handling, value) then&lt;br /&gt;
				outputDebugString (&amp;quot;* Predefined handling '&amp;quot;..tostring(handling)..&amp;quot;' for vehicle model '&amp;quot;..tostring(i)..&amp;quot;' could not be set to '&amp;quot;..tostring(value)..&amp;quot;'&amp;quot;)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
for _,v in ipairs (getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
	if v and predefinedHandling[getElementModel(v)] then&lt;br /&gt;
		for k,vl in pairs (predefinedHandling[getElementModel(v)]) do&lt;br /&gt;
			setVehicleHandling (v, k, vl)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function resetHandling()&lt;br /&gt;
	for model in pairs (predefinedHandling) do&lt;br /&gt;
		if model then&lt;br /&gt;
			for k in pairs(getOriginalHandling(model)) do&lt;br /&gt;
				setModelHandling(model, k, nil)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for _,v in ipairs (getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
		if v then&lt;br /&gt;
			local model = getElementModel(v)&lt;br /&gt;
			if predefinedHandling[model] then&lt;br /&gt;
				for k,h in pairs(getOriginalHandling(model)) do&lt;br /&gt;
					setVehicleHandling(v, k, h)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStop&amp;quot;, resourceRoot, resetHandling)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.5.5-3.12009|Added for vehicles created on client-side.}}&lt;br /&gt;
&lt;br /&gt;
==See other vehicle functions==&lt;br /&gt;
{{Vehicle functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnSettingChange&amp;diff=72996</id>
		<title>OnSettingChange</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnSettingChange&amp;diff=72996"/>
		<updated>2021-11-02T07:36:30Z</updated>

		<summary type="html">&lt;p&gt;NOki: Improved clarity of example code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server event}}&lt;br /&gt;
This event is triggered when resource setting has been changed. For instance, this event would trigger if you would edit the settings of the Race resource through the Admin panel.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string setting, string oldValue, string newValue&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''setting''': The setting which was changed. For instance: &amp;quot;*race.ghostmode&amp;quot;&lt;br /&gt;
*'''oldValue''': The previous value. Please note that this value is in [[JSON]]. To get a normal Lua value, use [[fromJSON]]&lt;br /&gt;
*'''newValue''': The new value. Also in [[JSON]]&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[root element]].&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function makeSettingsChangesVisible(setting, oldValue, newValue)&lt;br /&gt;
    local whatItWas = fromJSON(oldValue)&lt;br /&gt;
    local whatItsNow = fromJSON(newValue)&lt;br /&gt;
    outputDebugString(&amp;quot;The setting &amp;quot;..setting..&amp;quot; was &amp;quot;..whatItWas..&amp;quot; and has been changed to &amp;quot;..whatItsNow..&amp;quot;.&amp;quot;) -- Making the setting change visible in debug (use /debugscript [number] to see it)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onSettingChange&amp;quot;, root, makeSettingsChangesVisible)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{See also/Server event|Server events}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetGlitchEnabled&amp;diff=54563</id>
		<title>SetGlitchEnabled</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetGlitchEnabled&amp;diff=54563"/>
		<updated>2018-04-05T09:53:23Z</updated>

		<summary type="html">&lt;p&gt;NOki: Cleaned example code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function enables or disables glitches that are found in the original Single Player game that can be used to gain an advantage in multiplayer. &lt;br /&gt;
{{Note|By default all these glitches are disabled - use this function to '''enable''' them.}}&lt;br /&gt;
&lt;br /&gt;
Users of the '''fastmove''' glitch may additionally want to install [https://community.mtasa.com/index.php?p=resources&amp;amp;s=details&amp;amp;id=13368 this resource to disable crouchsliding]. &lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool setGlitchEnabled ( string glitchName, bool enable )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''glitchName:''' the name of the property to set. Possible values are:&lt;br /&gt;
{{Glitches}}&lt;br /&gt;
*'''enable:''' whether or not to enable the glitch.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example enables all glitches in the server once the resource is loaded.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local glitches = {&amp;quot;quickreload&amp;quot;, &amp;quot;fastmove&amp;quot;, &amp;quot;fastfire&amp;quot;, &amp;quot;crouchbug&amp;quot;, &amp;quot;highcloserangedamage&amp;quot;, &amp;quot;hitanim&amp;quot;, &amp;quot;fastsprint&amp;quot;, &amp;quot;baddrivebyhitbox&amp;quot;, &amp;quot;quickstand&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
function enableGlitches()&lt;br /&gt;
   for _, glitch in ipairs(glitches) do&lt;br /&gt;
      setGlitchEnabled(glitch, true)&lt;br /&gt;
   end &lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot, enableGlitches)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Server functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DxGetTextWidth&amp;diff=48594</id>
		<title>DxGetTextWidth</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DxGetTextWidth&amp;diff=48594"/>
		<updated>2016-07-25T11:30:14Z</updated>

		<summary type="html">&lt;p&gt;NOki: Added a note about this function being relative to client screen size&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}} &lt;br /&gt;
This function retrieves the theoretical width of a certain piece of text, if it were to be drawn using [[dxDrawText]].&lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' This function is relative to the client's screen resolution.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float dxGetTextWidth ( string text, [float scale=1, mixed font=&amp;quot;default&amp;quot;, bool bColorCoded=false] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{New feature/item|3.0141|1.4.1|6942|{{OOP|This syntax requires you to ignore the font argument above| [[Element/DX font|font]]:getTextWidth}}}}&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
* '''text:''' A string representing the text for which you wish to retrieve with width for.&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
* '''scale:''' The size of the text.&lt;br /&gt;
* '''font:''' Either a custom [[DX font]] element or the name of a built-in dx font:&lt;br /&gt;
{{DxFonts}}&lt;br /&gt;
* '''bColorCoded:''' Should we exclude color codes from the width? (false will include the hex in the length)&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the float of the width of the text. &lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Example&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This will show you the width of a message in a normal chatbox sent by a player&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function dxwidth(msg)&lt;br /&gt;
    chatbox = getChatboxLayout()&lt;br /&gt;
    local length = dxGetTextWidth(msg,chatbox[&amp;quot;chat_scale&amp;quot;][1])&lt;br /&gt;
    outputChatBox(tostring(length))&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientChatMessage&amp;quot;,root,dxwidth)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Drawing_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GuiGetScreenSize&amp;diff=48593</id>
		<title>GuiGetScreenSize</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GuiGetScreenSize&amp;diff=48593"/>
		<updated>2016-07-25T11:29:29Z</updated>

		<summary type="html">&lt;p&gt;NOki: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function retrieves the local screen size according to the resolution they are using.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float float guiGetScreenSize()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
This returns two floats representing the player's screen resolution, ''width'' and ''height''.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example checks whether a player is using a low resolution, and warns them that GUI may appear incorrect.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--setup a function when the resource starts&lt;br /&gt;
function checkResolutionOnStart ()&lt;br /&gt;
	local x,y = guiGetScreenSize() --get their screen size&lt;br /&gt;
	if ( x &amp;lt;= 640 ) and ( y &amp;lt;= 480 ) then --if their resolution is lower or equal to 640x480&lt;br /&gt;
		--warn them about GUI problems.&lt;br /&gt;
		outputChatBox ( &amp;quot;WARNING: You are running on a low resolution.  Some GUI may be placed or appear incorrectly.&amp;quot; )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
--attach the function to the event handler&lt;br /&gt;
addEventHandler ( &amp;quot;onClientResourceStart&amp;quot;, resourceRoot, checkResolutionOnStart )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Using guiGetScreenSize to fit GUI &amp;amp; DX drawing in all resolutions==&lt;br /&gt;
To get the precise coordinates of a GUI element or DX drawings, you need to decide which edges of the screen you want to have them positioned against, then you just need to find the difference between your screen size and your position values.&lt;br /&gt;
&lt;br /&gt;
For example, there is a DX text. It fits on 1024x768 resolution.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function DXtext ()&lt;br /&gt;
dxDrawText(tostring &amp;quot;Hello World!&amp;quot;,684.0,731.0,732.0,766.0,tocolor(0,255,255,175),1.0,&amp;quot;bankgothic&amp;quot;,&amp;quot;left&amp;quot;,&amp;quot;top&amp;quot;,false,false,false)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler ( &amp;quot;onClientRender&amp;quot;, getRootElement(), DXtext )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now if you want it to fit on all resolutions. Then follow these steps:&lt;br /&gt;
&lt;br /&gt;
1. Add ''width'' and ''height'' variables to get GUI's screen size, here we use sWidth and sHeight.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sWidth,sHeight = guiGetScreenSize() -- The variables&lt;br /&gt;
dxDrawText( &amp;quot;Hello World!&amp;quot;,684.0,731.0,732.0,766.0,tocolor(0,255,255,175),1.0,&amp;quot;bankgothic&amp;quot;,&amp;quot;left&amp;quot;,&amp;quot;top&amp;quot;,false,false,false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Divide each of the DX text's position values by the screen size manually (remembering the resolution is 1024x768):&lt;br /&gt;
&lt;br /&gt;
*'''Left''' position value is 684, 684/1024 = 0.668&lt;br /&gt;
*'''Top''' position value is 731, 731/768 = 0.952&lt;br /&gt;
*'''Right''' position values is 732, 732/1024 = 0.715&lt;br /&gt;
*'''Bottom''' position value is 766, 766/768 = 0.997&lt;br /&gt;
&lt;br /&gt;
You may want to use a calculator to help you count.&lt;br /&gt;
&lt;br /&gt;
3. Now with the answer above remove all of the position values and replace it with the width or height variable multiplied by the answer. Which would be:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sWidth,sHeight = guiGetScreenSize() -- The variables&lt;br /&gt;
dxDrawText(&amp;quot;Hello World!&amp;quot;,sWidth*0.668, sHeight*0.952, sWidth*0.715, sHeight*0.997,tocolor(0,255,255,175),1.0,&amp;quot;bankgothic&amp;quot;,&amp;quot;left&amp;quot;,&amp;quot;top&amp;quot;,false,false,false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So the final results will be a DX text which will fit on all resolutions which will be:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function DXtext ()&lt;br /&gt;
local sWidth,sHeight = guiGetScreenSize() -- The variables&lt;br /&gt;
dxDrawText(&amp;quot;Hello World!&amp;quot;,sWidth*0.668, sHeight*0.952, sWidth*0.715, sHeight*0.997,tocolor(0,255,255,175),1.0,&amp;quot;bankgothic&amp;quot;,&amp;quot;left&amp;quot;,&amp;quot;top&amp;quot;,false,false,false)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler ( &amp;quot;onClientRender&amp;quot;, getRootElement(), DXtext )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{GUI_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=TextDisplayRemoveText&amp;diff=48004</id>
		<title>TextDisplayRemoveText</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=TextDisplayRemoveText&amp;diff=48004"/>
		<updated>2016-07-06T08:20:25Z</updated>

		<summary type="html">&lt;p&gt;NOki: Changed argument order&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function removes a [[textitem]] from a [[textdisplay]]. This stops any observers of the [[textdisplay]] from being able to see the [[textitem]].&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
void textDisplayRemoveText ( textdisplay displayToRemoveFrom, textitem itemToRemove )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''displayToRemoveFrom''': The [[textdisplay]] to remove the [[textitem]] from.&lt;br /&gt;
* '''itemToRemove''': The [[textitem]] to remove from the display.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example creates a text display and adds a &amp;quot;Hello World&amp;quot; text item to it.  It then removes that text item 5 seconds later.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Create a text display.&lt;br /&gt;
myTextDisplay = textCreateDisplay ( )&lt;br /&gt;
-- Add a player as an observer, i.e. this player will see everything added to this display&lt;br /&gt;
textDisplayAddObserver ( myTextDisplay, aPlayer )&lt;br /&gt;
-- Create a new text item with the text 'Hello World' and a priority of 'low' and colored red.&lt;br /&gt;
myTextItem = textCreateTextItem ( &amp;quot;Hello World&amp;quot;, 0.5, 0.5, &amp;quot;low&amp;quot;, 255, 0, 0, 0, 1.0 )&lt;br /&gt;
-- Add the newly created text item to the display&lt;br /&gt;
textDisplayAddText ( myTextDisplay, myTextItem )&lt;br /&gt;
-- Remove the text item from the display&lt;br /&gt;
setTimer ( textDisplayRemoveText, 5000, 1, myTestDispay, myTextItem )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Text functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetPedWeapon&amp;diff=47032</id>
		<title>GetPedWeapon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetPedWeapon&amp;diff=47032"/>
		<updated>2016-03-30T06:18:43Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function tells you which weapon type is in a certain weapon slot of a ped. See [[weapon|Weapon Info]]&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int getPedWeapon ( ped thePed, [ int weaponSlot = current ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP|||[[ped]]:getWeapon()|}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed''': the [[ped]] you want to get the weapon type from.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''weaponSlot''': an integer representing the weapon slot (set to the ped's current slot if not given).&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns an [[int]] indicating the type of the weapon the ped has in the specified slot. If the slot is empty, it returns 0.&lt;br /&gt;
&lt;br /&gt;
It should be noted that if a ped runs out of ammo for a weapon, it will still return the ID of that weapon in the slot (even if it appears as if the ped does not have a weapon at all), though [[getPedTotalAmmo]] will return '''0'''.  Therefore, [[getPedTotalAmmo]] should be used in conjunction with [[getPedWeapon]] in order to check if a ped has a weapon.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example will display a player's current weapon type. In this case,a random player.&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Find a player called someguy and find his current weapon id.&lt;br /&gt;
local weaponType = getPedWeapon ( getRandomPlayer() )&lt;br /&gt;
-- If a weapon type was returned then&lt;br /&gt;
if ( weaponType ) then&lt;br /&gt;
    outputChatBox ( &amp;quot;someguy's current Weapon-type: &amp;quot; .. weaponType .. &amp;quot;.&amp;quot; ) -- Display the weapon type in the chat box&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_ped_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=FileGetSize&amp;diff=46456</id>
		<title>FileGetSize</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=FileGetSize&amp;diff=46456"/>
		<updated>2016-01-22T00:08:00Z</updated>

		<summary type="html">&lt;p&gt;NOki: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
&lt;br /&gt;
Returns the total size in bytes of the given file.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int fileGetSize ( file theFile )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[file]]:getSize|size}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theFile:''' the file handle you wish to get the size of.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the file size if successful, or ''false'' if an error occured (e.g. an invalid file handle was passed).&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local newFile = fileCreate(&amp;quot;test.txt&amp;quot;)                -- attempt to create a new file&lt;br /&gt;
if (newFile) then                                       -- check if the creation succeeded&lt;br /&gt;
	fileWrite(newFile, &amp;quot;This is a test file!&amp;quot;)        -- write a text line&lt;br /&gt;
	local size = fileGetSize(newFile)              -- get size&lt;br /&gt;
	if size then&lt;br /&gt;
		outputChatBox(&amp;quot;Size of test.txt is: &amp;quot;..size, source) -- output size&lt;br /&gt;
        end&lt;br /&gt;
	fileClose(newFile)                                -- close the file once you're done with it&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{File functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnColShapeHit&amp;diff=46348</id>
		<title>OnColShapeHit</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnColShapeHit&amp;diff=46348"/>
		<updated>2016-01-09T08:23:54Z</updated>

		<summary type="html">&lt;p&gt;NOki: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server event}}&lt;br /&gt;
This event is triggered when a physical [[element]] hits a [[colshape]].&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': The hit won't be detected if the [[element]] that entered the colshape is a colshape.&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
element hitElement, bool matchingDimension&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''hitElement''': the [[element]] that entered the colshape.&lt;br /&gt;
*'''matchingDimension''': a boolean referring to whether the hit collision shape was in the same dimension as the element.&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[colshape]] that got hit by a player or vehicle.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example creates a hill area for a ''King of the hill'' gamemode.  When a player enters or leaves the area, it's announced in the chatbox.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- create our hill area for our gamemode&lt;br /&gt;
local hillArea = createColRectangle ( -2171.0678710938, 678.17950439453, 15, 15 )&lt;br /&gt;
&lt;br /&gt;
-- add hill_Enter as a handler for when a player enters the hill area&lt;br /&gt;
function hill_Enter ( thePlayer, matchingDimension )&lt;br /&gt;
        if getElementType ( thePlayer ) == &amp;quot;player&amp;quot; then --if the element that entered was player&lt;br /&gt;
                --let's get the name of the player&lt;br /&gt;
                local nameOfThePlayer = getPlayerName ( thePlayer )&lt;br /&gt;
	        --announce to everyone that the player entered the hill&lt;br /&gt;
	        outputChatBox ( nameOfThePlayer..&amp;quot; entered the zone!&amp;quot;, getRootElement(), 255, 255, 109 )&lt;br /&gt;
        end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onColShapeHit&amp;quot;, hillArea, hill_Enter )&lt;br /&gt;
&lt;br /&gt;
-- add hill_Enter as a handler for when a player leaves the hill area&lt;br /&gt;
function hill_Exit ( thePlayer, matchingDimension )&lt;br /&gt;
        if getElementType ( thePlayer ) == &amp;quot;player&amp;quot; then --if the element that left was player&lt;br /&gt;
	        --check if the player is not dead&lt;br /&gt;
	        if isPlayerDead ( thePlayer ) ~= true then&lt;br /&gt;
                        --let's get the name of the player&lt;br /&gt;
                        local nameOfThePlayer = getPlayerName ( thePlayer )&lt;br /&gt;
	        	--if he was alive, announce to everyone that the player has left the hill&lt;br /&gt;
	        	outputChatBox ( nameOfThePlayer..&amp;quot; left the zone!&amp;quot;, getRootElement(), 255, 255, 109 )&lt;br /&gt;
	        end&lt;br /&gt;
        end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onColShapeLeave&amp;quot;, hillArea, hill_Exit )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{See also/Server event|Colshape events}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetControlState&amp;diff=46345</id>
		<title>SetControlState</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetControlState&amp;diff=46345"/>
		<updated>2016-01-08T13:01:22Z</updated>

		<summary type="html">&lt;p&gt;NOki: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}} &lt;br /&gt;
__NOTOC__ &lt;br /&gt;
Sets a state of a specified player's control, as if they pressed or released it.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool setControlState ( player thePlayer, string control, bool state ) &amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePlayer:''' The player you wish to set the control state of.&lt;br /&gt;
*'''control:''' The control that you want to set the state of. See [[control names]] for a list of possible controls.&lt;br /&gt;
*'''state:''' A boolean value representing whether or not the key will be set to pressed or not.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool setControlState ( string control, bool state ) &amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''control:''' The control that you want to set the state of. See [[control names]] for a list of possible controls.&lt;br /&gt;
*'''state:''' A boolean value representing whether or not the key will be set to pressed or not.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the control state was successfully set, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==  &lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example will disable the use of the accelerate, brake/reverse and handbrake keys, then force the accelerate on for any player who enters a vehicle. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onPlayerEnterVehicle ( theVehicle, seat, jacked )&lt;br /&gt;
    toggleControl ( source, &amp;quot;accelerate&amp;quot;, false ) -- disable the accelerate key&lt;br /&gt;
    toggleControl ( source, &amp;quot;brake_reverse&amp;quot;, false ) -- disable the brake_reverse key&lt;br /&gt;
    toggleControl ( source, &amp;quot;handbrake&amp;quot;, false ) -- disable the handbrake key&lt;br /&gt;
    setControlState ( source, &amp;quot;accelerate&amp;quot;, true ) -- force the accelerate key on&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement(), onPlayerEnterVehicle )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example will disable the use of the accelerate, brake/reverse and handbrake keys, then force the accelerate on for any player who enters a vehicle. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function onClientPlayerEnterVehicle ( theVehicle, seat, jacked )&lt;br /&gt;
    toggleControl ( &amp;quot;accelerate&amp;quot;, false ) -- disable the accelerate key&lt;br /&gt;
    toggleControl ( &amp;quot;brake_reverse&amp;quot;, false ) -- disable the brake_reverse key&lt;br /&gt;
    toggleControl ( &amp;quot;handbrake&amp;quot;, false ) -- disable the handbrake key&lt;br /&gt;
    setControlState ( &amp;quot;accelerate&amp;quot;, true ) -- force the accelerate key on&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onClientPlayerVehicleEnter&amp;quot;, getRootElement(), onClientPlayerEnterVehicle )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Input functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CreateBlipAttachedTo&amp;diff=46286</id>
		<title>CreateBlipAttachedTo</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CreateBlipAttachedTo&amp;diff=46286"/>
		<updated>2016-01-03T09:53:11Z</updated>

		<summary type="html">&lt;p&gt;NOki: Changed : to . because this is a static function.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function creates a [[blip]] that is attached to an [[element]]. This blip is displayed as an icon on the client's radar and will 'follow' the element that it is attached to around.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
blip createBlipAttachedTo ( element elementToAttachTo, [int icon=0, int size=2, int r=255, int g=0, int b=0, int a=255, int ordering=0, float visibleDistance=99999.0, visibleTo = getRootElement()] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
{{OOP|The element type of this class is [[Blip]].|[[Blip]].createAttachedTo||}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''elementToAttachTo:''' The [[element]] to attach the marker to.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''icon:''' The icon that the radar blips should be. Valid values are:&lt;br /&gt;
{{Blip_Icons}}&lt;br /&gt;
*'''size:''' The size of the radar blip. Only applicable to the ''Marker'' icon. Default value is 2.&lt;br /&gt;
*'''r:''' The amount of red in the blip's color (0 - 255). Only applicable to the ''Marker'' icon. Default is 255. &lt;br /&gt;
*'''g:''' The amount of green in the blip's color (0 - 255). Only applicable to the ''Marker'' icon. Default is 0.&lt;br /&gt;
*'''b:''' The amount of blue in the blip's color (0 - 255). Only applicable to the ''Marker'' icon. Default is 0.&lt;br /&gt;
*'''a:''' The amount of alpha in the blip's color (0 - 255). Only applicable to the ''Marker'' icon. Default is 255.&lt;br /&gt;
{{New feature/item|3|1.0||&lt;br /&gt;
*'''ordering:''' This defines the blip's Z-level ordering (-32768 - 32767). Default is 0.&lt;br /&gt;
*'''visibleDistance:''' The maximum distance from the camera at which the blip is still visible (0 - 65535)&lt;br /&gt;
}}&lt;br /&gt;
*'''visibleTo:''' What elements can see the blip. Defaults to visible to everyone. See [[visibility]].&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
blip createBlipAttachedTo ( element elementToAttachTo, [int icon=0, int size=2, int r=255, int g=0, int b=0, &lt;br /&gt;
int a=255, int ordering=0, float visibleDistance=99999.0] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''elementToAttachTo:''' The [[element]] to attach the marker to.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''icon:''' The icon that the radar blips should be. Valid values are:&lt;br /&gt;
{{Blip_Icons}}&lt;br /&gt;
*'''size:''' The size of the radar blip. Only applicable to the ''Marker'' icon. Default is 2.&lt;br /&gt;
*'''r:''' The amount of red in the blip's color (0 - 255). Only applicable to the ''Marker'' icon. 'Default is 255. &lt;br /&gt;
*'''g:''' The amount of green in the blip's color (0 - 255). Only applicable to the ''Marker'' icon. Default is 0.&lt;br /&gt;
*'''b:''' The amount of blue in the blip's color (0 - 255). Only applicable to the ''Marker'' icon. Default is 0.&lt;br /&gt;
*'''a:''' The amount of alpha in the blip's color (0 - 255). Only applicable to the ''Marker'' icon. Default is 255.&lt;br /&gt;
{{New feature/item|3|1.0||&lt;br /&gt;
*'''ordering:''' This defines the blip's Z-level ordering (-32768 - 32767). Default is 0.&lt;br /&gt;
*'''visibleDistance:''' The maximum distance from the camera at which the blip is still visible&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a [[blip]] if the blip was created succesfully, or ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example creates a radar blip attached to a random player, visible to everyone. The blip will follow the player around as they move. This could be used for manhunt, to emphasise a random player.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Pick a random player&lt;br /&gt;
function setupRandomRobber ()&lt;br /&gt;
	local myPlayer = getRandomPlayer ()&lt;br /&gt;
	-- Create a radar blip at the player's position, with a 'cash' icon and only visible to everyone (no 'visibleTo' parameter)&lt;br /&gt;
	local myBlip = createBlipAttachedTo ( myPlayer, 52 )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Blip_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnClientGUITabSwitched&amp;diff=46257</id>
		<title>OnClientGUITabSwitched</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnClientGUITabSwitched&amp;diff=46257"/>
		<updated>2015-12-23T23:40:34Z</updated>

		<summary type="html">&lt;p&gt;NOki: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client event}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This event is triggered each time the user switch from GUI tab.&lt;br /&gt;
&lt;br /&gt;
==Parameters== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
element theElement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
* '''theElement''':  The tab which was selected.&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the tab.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example creates a window with a tabpanel with two tabs. Every time a user changes tabpage a notification will be shown.&lt;br /&gt;
&lt;br /&gt;
First we'll create the window. Then add a tabpanel and couple tabs with some labels in them. Qoute: [[GuiCreateWindow#Example]]&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, &amp;quot;Information&amp;quot;, true )  -- create a window which has &amp;quot;Information&amp;quot; in the title bar.&lt;br /&gt;
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow )       -- create a tab panel which fills the whole window&lt;br /&gt;
local tabMap = guiCreateTab( &amp;quot;Map Information&amp;quot;, tabPanel )                -- create a tab named &amp;quot;Map Information&amp;quot; on 'tabPanel'&lt;br /&gt;
local tabHelp = guiCreateTab( &amp;quot;Help&amp;quot;, tabPanel )                          -- create another tab named &amp;quot;Help&amp;quot; on 'tabPanel'&lt;br /&gt;
 &lt;br /&gt;
-- adds a label (text) to each tab&lt;br /&gt;
guiCreateLabel( 0.02, 0.04, 0.94, 0.2, &amp;quot;This is information about the current map&amp;quot;, true, tabMap )&lt;br /&gt;
guiCreateLabel( 0.02, 0.04, 0.94, 0.92, &amp;quot;This is help text.&amp;quot;, true, tabHelp )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now let's add the event handler.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function OnChange(selectedTab)&lt;br /&gt;
	-- If there is a selected tab.&lt;br /&gt;
	if selectedTab ~= nil then &lt;br /&gt;
		outputChatBox( &amp;quot;You've changed your active tab.&amp;quot; )&lt;br /&gt;
	end	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onClientGUITabSwitched&amp;quot;, root, OnChange)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
===GUI events===&lt;br /&gt;
{{GUI_events}}&lt;br /&gt;
===Client event functions===&lt;br /&gt;
{{Client_event_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=HasObjectPermissionTo&amp;diff=46228</id>
		<title>HasObjectPermissionTo</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=HasObjectPermissionTo&amp;diff=46228"/>
		<updated>2015-12-20T23:06:47Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function returns whether or not the given object has access to perform the given action. &lt;br /&gt;
{{Note|Only certain action names work. This function seems to return ''nil'' and output a bad argument error when checking if an object has rights for an action which doesn't start with ''function.'', ''command.'' or ''resource.'' keywords.}}&lt;br /&gt;
&lt;br /&gt;
Scripts frequently wish to limit access to features to particular users. The naïve way to do this would be to check if the player who is attempting to perform an action is in a particular group (usually the Admin group). The main issue with doing this is that the Admin group is not guaranteed to exist. It also doesn't give the server admin any flexibility. He might want to allow his 'moderators' access to the function you're limiting access to, or he may want it disabled entirely. &lt;br /&gt;
&lt;br /&gt;
This is where using the ACL properly comes in, and luckily this is very easy. It all comes down to using this function. This, somewhat confusingly named function lets you check if an ACL object (a player or a resource) has a particular ACL right. In this case, we just care about players.&lt;br /&gt;
&lt;br /&gt;
So, first of all, think of a name for your 'right'. Let's say we want a private area only certain people can go in, we'll call our right accessPrivateArea. Then, all you need to do is add one 'if' statement to your code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;if hasObjectPermissionTo ( player, &amp;quot;resource.YourResourceName.accessPrivateArea&amp;quot;, false ) then&lt;br /&gt;
-- Whatever you want to happen if they're allowed in&lt;br /&gt;
else&lt;br /&gt;
-- Whatever you want to happen if they aren't&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that we've named the ''right'' using ''resource.YourResourceName.accessPrivateArea'' - this is just for neatness, so that the admin knows what resource the right belongs to. It's strongly advised you follow this convention. The ''false'' argument specifies the 'defaultPermission', false indicating that if the user hasn't had the right allowed or dissallowed (i.e. the admin hasn't added it to the config), that it should default to being not allowed.&lt;br /&gt;
&lt;br /&gt;
The only downside of using this method is that the admin has to modify his config. The upsides are that the admin has much more control and your script will work for any server, however the admin has configured it.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool hasObjectPermissionTo ( string / element theObject, string theAction [, bool defaultPermission = true ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&amp;lt;!-- Yes! This is actually correct this time ^^ notice theObject can be a string! --&amp;gt;&lt;br /&gt;
{{OOP|This function is also a static function underneath the ACL class.|[[ACL]].hasObjectPermissionTo||}}&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theObject:''' The object to test if has permission to. This can be a client element (ie. a player), a resource or a string in the form &amp;quot;user.&amp;lt;name&amp;gt;&amp;quot; or &amp;quot;resource.&amp;lt;name&amp;gt;&amp;quot;.&lt;br /&gt;
*'''theAction:''' The action to test if the given object has access to. Ie. &amp;quot;function.kickPlayer&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''defaultPermission:''' The default permission if none is specified in either of the groups the given object is a member of. If this is left to true, the given object will have permissions to perform the action unless the opposite is explicitly specified in the [[ACL]]. If false, the action will be denied by default unless explicitly approved by the [[Access Control List]].&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the given object has permission to perform the given action, ''false'' otherwise. Returns ''nil'' if the function failed because of bad arguments.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example kicks a player if the user using it has access to the kickPlayer function.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Kick command&lt;br /&gt;
function onKickCommandHandler ( playerSource, commandName, playerToKick, stringReason )&lt;br /&gt;
    -- Does the calling user have permission to kick the player? Default&lt;br /&gt;
    -- to false for safety reasons. We do this so any user can't use us to&lt;br /&gt;
    -- kick players.&lt;br /&gt;
    if ( hasObjectPermissionTo ( playerSource, &amp;quot;function.kickPlayer&amp;quot;, false ) ) then&lt;br /&gt;
&lt;br /&gt;
        -- Do we have permission to kick the player? We do this so we can fail&lt;br /&gt;
        -- nicely if this resource doesn't have access to call that function.&lt;br /&gt;
        if ( hasObjectPermissionTo ( getThisResource (), &amp;quot;function.kickPlayer&amp;quot;, true ) ) then&lt;br /&gt;
            -- Kick him&lt;br /&gt;
            kickPlayer ( playerToKick, playerSource, stringReason )&lt;br /&gt;
        else&lt;br /&gt;
            -- Resource doesn't have any permissions, sorry&lt;br /&gt;
            outputChatBox ( &amp;quot;kick: The admin resource is not able to kick players. Please give this resource access to 'function.kickPlayer' in the ACL to use this function.&amp;quot;, playerSource )&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        -- User doesn't have any permissions&lt;br /&gt;
        outputChatBox ( &amp;quot;kick: You don't have permissions to use this command.&amp;quot;, playerSource )&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;kick&amp;quot;, onKickCommandHandler )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&amp;lt;!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --&amp;gt;&lt;br /&gt;
{{ACL_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnClientFileDownloadComplete&amp;diff=46222</id>
		<title>OnClientFileDownloadComplete</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnClientFileDownloadComplete&amp;diff=46222"/>
		<updated>2015-12-18T10:54:38Z</updated>

		<summary type="html">&lt;p&gt;NOki: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client event}}&lt;br /&gt;
{{New items|3.0140|1.4|&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This event is triggered when a file has been downloaded after [[downloadFile]] has been successfully called.&lt;br /&gt;
}}&lt;br /&gt;
==Parameters== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string fileName, bool success&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''fileName''': the file downloaded.&lt;br /&gt;
*'''success''': whether successful or not.&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[root element]] of the resource that called [[downloadFile]].&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example plays a sound if it was downloaded successfully&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onDownloadFinish ( file, success )&lt;br /&gt;
    if ( source == resourceRoot ) then                            -- if the file relates to this resource&lt;br /&gt;
        if ( success ) then                                       -- if the file was downloaded successfully&lt;br /&gt;
            if ( file == &amp;quot;test.mp3&amp;quot; ) then                        -- if the file name is what we were expecting&lt;br /&gt;
                currentTrack = playSound ( &amp;quot;test.mp3&amp;quot; )&lt;br /&gt;
            end&lt;br /&gt;
        else                                                      -- if the file wasn't downloaded successfully&lt;br /&gt;
            if ( file == &amp;quot;test.mp3&amp;quot; ) then&lt;br /&gt;
                outputChatBox ( &amp;quot;test.mp3 failed to download&amp;quot; )&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onClientFileDownloadComplete&amp;quot;, root, onDownloadFinish )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
===Other client events===&lt;br /&gt;
{{Client_other_events}}&lt;br /&gt;
===Client event functions===&lt;br /&gt;
{{Client_event_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CreateWeapon&amp;diff=46211</id>
		<title>CreateWeapon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CreateWeapon&amp;diff=46211"/>
		<updated>2015-12-15T12:40:53Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Returns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&amp;lt;!--{{Needs_Checking|&amp;quot;Some weapon types do not work.&amp;quot;... needs investigating. Shotguns do not work because the pellet code was complex and its actually 8 very clustered pellets. All other bullet weapons should work and be synced. Exact weapons this works with needs documenting still.}}--&amp;gt;&lt;br /&gt;
{{Client function}}&lt;br /&gt;
Creates a [[Element/Weapon|custom weapon]] that can fire bullets. '''Do not confuse this with player held weapons'''.&lt;br /&gt;
{{Tip|Some weapons (such as the minigun) visually point to a slightly different direction to where they fire. To adjust this, use [[setWeaponProperty]] with 'fire_rotation'. See the example below.}}&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;weapon createWeapon ( string theType, float x, float y, float z )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[Element/Weapon|Weapon]]}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theType:''' The weapon type which can be:&lt;br /&gt;
{{Custom Weapon Types}}&lt;br /&gt;
&lt;br /&gt;
* '''x:''' The x position to create the weapon.&lt;br /&gt;
* '''y:''' The y position to create the weapon.&lt;br /&gt;
* '''z:''' The z position to create the weapon.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a [[Element/Weapon|custom weapon]] element, which represents a weapon floating at that position.&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|n/a|1.3.0-9.04555|}}&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example adds a ''/createminigun'' command to create a weapon that is always firing.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createMinigunWeapon()&lt;br /&gt;
    -- Create the weapon 1 meter above the player&lt;br /&gt;
    local x, y, z = getElementPosition(getLocalPlayer())&lt;br /&gt;
    local weapon = createWeapon(&amp;quot;minigun&amp;quot;, x, y, z + 1)&lt;br /&gt;
    -- Give it some ammo and fire it&lt;br /&gt;
    setWeaponClipAmmo(weapon, 99999)&lt;br /&gt;
    setWeaponState(weapon, &amp;quot;firing&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    -- Optionally adjust for model rotation (this value will be different for other weapons)&lt;br /&gt;
    setWeaponProperty(weapon, &amp;quot;fire_rotation&amp;quot;, 0, -30, 0)&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;createminigun&amp;quot;, createMinigunWeapon)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Client weapon creation functions}}&lt;br /&gt;
[[ru:createWeapon]]&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetKeyState&amp;diff=46188</id>
		<title>GetKeyState</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetKeyState&amp;diff=46188"/>
		<updated>2015-12-09T04:05:54Z</updated>

		<summary type="html">&lt;p&gt;NOki: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function determines if a certain key is pressed or not.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'ralt' may trigger both 'ralt' and 'lctrl', this is due to AltGr&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool getKeyState ( string keyName )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''keyName:''' The name of the key you're checking state of. See [[Key names]].&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the specified key is pressed, ''false'' if it isn't or if an invalid key name is passed.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This clientside example prints a message when &amp;quot;p&amp;quot; is pressed, and a different one for the &amp;quot;control+p&amp;quot; combination.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- define a function that outputs a message if control is pressed, and a different one if it isn't&lt;br /&gt;
function printMessageFunction()&lt;br /&gt;
	-- if the left or right control keys are pressed, the user has pressed the &amp;quot;control+p&amp;quot; combo&lt;br /&gt;
	if getKeyState( &amp;quot;lctrl&amp;quot; ) == true or getKeyState( &amp;quot;rctrl&amp;quot; ) == true then&lt;br /&gt;
		outputChatBox ( &amp;quot;You have pressed 'control+p'.&amp;quot; )&lt;br /&gt;
	-- if none of those were pressed, he just pressed the &amp;quot;p&amp;quot; key&lt;br /&gt;
	else&lt;br /&gt;
		outputChatBox ( &amp;quot;You have pressed 'p'.&amp;quot; )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
-- bind the &amp;quot;p&amp;quot; key to our function&lt;br /&gt;
bindKey( &amp;quot;p&amp;quot;, &amp;quot;down&amp;quot;, &amp;quot;Print message&amp;quot;, printMessageFunction )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_input_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Installing_and_Running_MTASA_Server_on_GNU_Linux&amp;diff=46185</id>
		<title>Installing and Running MTASA Server on GNU Linux</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Installing_and_Running_MTASA_Server_on_GNU_Linux&amp;diff=46185"/>
		<updated>2015-12-09T01:57:27Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Main binary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installation ==&lt;br /&gt;
&lt;br /&gt;
=== Main binary ===&lt;br /&gt;
Download the latest stable Linux binaries from here:&lt;br /&gt;
 rm multitheftauto_linux-{{Current Version|full}}.tar.gz&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://linux.mtasa.com/dl/151/multitheftauto_linux-{{Current Version|full}}.tar.gz&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
or if you are feeling daring, get the latest nightly build from here:&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://nightly.mtasa.com/?multitheftauto_linux-{{Current Version|full}}-latest&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
Unpack into a directory:&lt;br /&gt;
 tar -xf multitheftauto_linux-{{Current Version|full}}.tar.gz&lt;br /&gt;
&lt;br /&gt;
=== Default config ===&lt;br /&gt;
Download the default config files:&lt;br /&gt;
 rm baseconfig-{{Current Version|full}}.tar.gz&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://linux.mtasa.com/dl/151/baseconfig-{{Current Version|full}}.tar.gz&lt;br /&gt;
&lt;br /&gt;
Unpack and move into the deathmatch directory:&amp;lt;br/&amp;gt;&lt;br /&gt;
('''''Note:''' Only do this for new installations as it will overwrite any existing config files.)''&lt;br /&gt;
 tar -xf baseconfig-{{Current Version|full}}.tar.gz&lt;br /&gt;
 mv baseconfig/* multitheftauto_linux-{{Current Version|full}}/mods/deathmatch&lt;br /&gt;
&lt;br /&gt;
Change to the MTA server install directory:&lt;br /&gt;
 cd multitheftauto_linux-{{Current Version|full}}&lt;br /&gt;
&lt;br /&gt;
=== Test ===&lt;br /&gt;
You can now test if the server will start correctly:&lt;br /&gt;
 ./mta-server&lt;br /&gt;
or if using the 64 bit server:&lt;br /&gt;
 ./mta-server64&lt;br /&gt;
&lt;br /&gt;
=== Default resources ===&lt;br /&gt;
If you need the default resources:&lt;br /&gt;
Download the latest default resources zip from http://mirror.mtasa.com/mtasa/resources/&lt;br /&gt;
and unzip into '''mods/deathmatch/resources'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Make sure you are in the MTA server install directory when following this example:'''&lt;br /&gt;
 apt-get install unzip&lt;br /&gt;
 mkdir mods/deathmatch/resources&lt;br /&gt;
 cd mods/deathmatch/resources&lt;br /&gt;
 rm mtasa-resources-latest.zip&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip&lt;br /&gt;
 unzip mtasa-resources-latest.zip&lt;br /&gt;
 rm mtasa-resources-latest.zip&lt;br /&gt;
&lt;br /&gt;
== Running with 32 or 64 bit Linux==&lt;br /&gt;
=== Make sure your server libraries and stuff are up to date ===&lt;br /&gt;
On Debian/Ubuntu this is done with:&lt;br /&gt;
 apt-get update&lt;br /&gt;
 apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
== Running with 32 bit Linux ==&lt;br /&gt;
===32 bit Troubleshooting===&lt;br /&gt;
* If you get a problem with such as &amp;quot;libreadline.so.5: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 32 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libreadline5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libncursesw.so.5 cannot open shared object file: No such file or directory&amp;quot;, it can be solved on 32 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libncursesw5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libmysqlclient.so.16: cannot open shared object file: No such file or directory&amp;quot;, it can be solved on Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libmysqlclient16&lt;br /&gt;
&lt;br /&gt;
If that fails, download [http://nightly.mtasa.com/files/libmysqlclient.so.16 libmysqlclient.so.16] and put it in '''/usr/lib/'''&lt;br /&gt;
&lt;br /&gt;
== Running with 64 bit Linux ==&lt;br /&gt;
===Debian 7 (wheezy) 64 bit===&lt;br /&gt;
Before running MTASA Server, use this command line for installation of 32 bit libs :&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32ncursesw5 lib32readline5&lt;br /&gt;
&lt;br /&gt;
===Install 32 bit libs for your 64 bit distro===&lt;br /&gt;
For 64 bit Debian 6, this is achieved with:&amp;lt;br/&amp;gt;&lt;br /&gt;
''(Some 64 bit distros have 32 bit libs already installed for you. So this step might not be required)''&lt;br /&gt;
&lt;br /&gt;
 apt-get install ia32-libs&lt;br /&gt;
&lt;br /&gt;
===64 bit Troubleshooting===&lt;br /&gt;
====64 bit Debian/Ubuntu====&lt;br /&gt;
* If you get a problem with such as &amp;quot;libstdc++.so.6: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32stdc++6&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libz.so.1: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32z1&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libreadline.so.5: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32readline5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libncursesw.so.5 cannot open shared object file: No such file or directory&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32ncursesw5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libmysqlclient.so.16: cannot open shared object file: No such file or directory&amp;quot;, it can be solved on Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libmysqlclient16&lt;br /&gt;
&lt;br /&gt;
** If that fails, download [http://nightly.mtasa.com/files/libmysqlclient.so.16 libmysqlclient.so.16] and put it in '''/usr/lib/'''&lt;br /&gt;
&lt;br /&gt;
**NOTE: If you are running the experimental MTA x64 server, you will need [http://nightly.mtasa.com/files/x64/libmysqlclient.so.16 this file] instead:&lt;br /&gt;
&lt;br /&gt;
====64 bit CentOS 6====&lt;br /&gt;
* If you get a problem with such as &amp;quot;libreadline.so.5: cannot open shared object file: No such file or directory.&amp;quot;, edit '''''/etc/yum.conf''''' and add this line:&lt;br /&gt;
 multilib_policy=all&lt;br /&gt;
Then issue this command:&lt;br /&gt;
 yum install compat-readline5&lt;br /&gt;
* Further 64 bit solutions can be found [http://forum.mtasa.com/viewtopic.php?f=106&amp;amp;t=35328#p367282 on the forums]&lt;br /&gt;
&lt;br /&gt;
== MySQL Troubleshooting==&lt;br /&gt;
* If you are using the inbuild MySQL functions such as [[dbConnect]] and [[dbQuery]], you will need to have '''libmysqlclient.so.16''' installed.&lt;br /&gt;
* If you can't get '''libmysqlclient.so.16''' installed by conventional means, then try [http://nightly.mtasa.com/files/libmysqlclient.so.16 downloading the file from here] and copying it to your Linux server '''/usr/lib/''' directory.&lt;br /&gt;
&lt;br /&gt;
==Cent OS Troubleshooting==&lt;br /&gt;
* If you are using Cent OS and you get something like /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by xmll.so) this can be resolved by doing downloading the archive [[http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/9/Fedora/i386/os/Packages/libstdc++-4.3.0-8.i386.rpm here]] and unpacking it with the following command:&lt;br /&gt;
&lt;br /&gt;
 rpm2cpio libstdc++-4.3.0-8.i386.rpm | cpio -i --make-directories&lt;br /&gt;
&lt;br /&gt;
==[Optional] Installing and Configuring an External Web Server==&lt;br /&gt;
Instructions on how to install and configure Nginx as an external web server for MTA is here: [[Installing and Configuring Nginx as an External Web Server]]&lt;br /&gt;
&lt;br /&gt;
== Server crashes ==&lt;br /&gt;
&lt;br /&gt;
If your Linux server crashes, please obtain a backtrace and post a report on our [http://bugs.mtasa.com/ Bug tracker]&lt;br /&gt;
&lt;br /&gt;
====To obtain a backtrace:====&lt;br /&gt;
===Do you have a core dump file in the the MTA server directory?===&lt;br /&gt;
It's usually called 'core', and usually over 100MB, and looks something like this:&lt;br /&gt;
 [[Image:Core.png]]&lt;br /&gt;
====If you have a core dump file in the the MTA server directory:====&lt;br /&gt;
*Install gdb. To install gdb on Debian, use this command:&lt;br /&gt;
 apt-get install gdb&lt;br /&gt;
*And from the MTA install directory do this command&lt;br /&gt;
 gdb mta-server -c core&lt;br /&gt;
*When gdb launches, do this command to get a  module list:&lt;br /&gt;
 i sh&lt;br /&gt;
*And then this command to get a backtrace:&lt;br /&gt;
 bt&lt;br /&gt;
*Save the output&lt;br /&gt;
*(To exit gdb, use the quit command)&lt;br /&gt;
&lt;br /&gt;
====If you do not have a core dump file in the the MTA server directory:====&lt;br /&gt;
*Install gdb. To install gdb on Debian, use this command:&lt;br /&gt;
 apt-get install gdb&lt;br /&gt;
*And from the MTA server directory start the mta-server like this:&lt;br /&gt;
 gdb mta-server -ex &amp;quot;set print thread-events off&amp;quot; --eval-command run&lt;br /&gt;
*Now wait for a crash. (Ignore any weird screen output in the meantime)&lt;br /&gt;
*When a crash occurs, do this command to get a module list:&lt;br /&gt;
 i sh&lt;br /&gt;
*And then this command to get a backtrace:&lt;br /&gt;
 bt&lt;br /&gt;
*Save the output&lt;br /&gt;
*(To exit gdb, use the quit command)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Server freezes''' ==&lt;br /&gt;
&lt;br /&gt;
If your Linux server freezes, please obtain a backtrace with thread information and post a report on our [http://bugs.mtasa.com/ Bug tracker]&lt;br /&gt;
&lt;br /&gt;
====To obtain a backtrace with thread information:====&lt;br /&gt;
*Install gdb. To install gdb on Debian, use this command:&lt;br /&gt;
 apt-get install gdb&lt;br /&gt;
*And from the MTA server directory start the mta-server like this:&lt;br /&gt;
 gdb mta-server -ex &amp;quot;set print thread-events off&amp;quot; --eval-command run&lt;br /&gt;
*Now wait for a freeze. (Ignore any weird screen output in the meantime)&lt;br /&gt;
*When a freeze occurs, press ctrl-c to start gdb&lt;br /&gt;
*Then do this command to get a module list:&lt;br /&gt;
 i sh&lt;br /&gt;
*And then this command to get a backtrace:&lt;br /&gt;
 bt&lt;br /&gt;
*And then this command to get thread information:&lt;br /&gt;
 info threads&lt;br /&gt;
*Save the output&lt;br /&gt;
*(To exit gdb, use the quit command)&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Installing_and_Running_MTASA_Server_on_GNU_Linux&amp;diff=46184</id>
		<title>Installing and Running MTASA Server on GNU Linux</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Installing_and_Running_MTASA_Server_on_GNU_Linux&amp;diff=46184"/>
		<updated>2015-12-09T01:57:17Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Default config */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installation ==&lt;br /&gt;
&lt;br /&gt;
=== Main binary ===&lt;br /&gt;
Download the latest stable Linux binaries from here:&lt;br /&gt;
 rm multitheftauto_linux-{{Current Version|full}}.tar.gz&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://linux.mtasa.com/dl/15/multitheftauto_linux-{{Current Version|full}}.tar.gz&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
or if you are feeling daring, get the latest nightly build from here:&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://nightly.mtasa.com/?multitheftauto_linux-{{Current Version|full}}-latest&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
Unpack into a directory:&lt;br /&gt;
 tar -xf multitheftauto_linux-{{Current Version|full}}.tar.gz&lt;br /&gt;
&lt;br /&gt;
=== Default config ===&lt;br /&gt;
Download the default config files:&lt;br /&gt;
 rm baseconfig-{{Current Version|full}}.tar.gz&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://linux.mtasa.com/dl/151/baseconfig-{{Current Version|full}}.tar.gz&lt;br /&gt;
&lt;br /&gt;
Unpack and move into the deathmatch directory:&amp;lt;br/&amp;gt;&lt;br /&gt;
('''''Note:''' Only do this for new installations as it will overwrite any existing config files.)''&lt;br /&gt;
 tar -xf baseconfig-{{Current Version|full}}.tar.gz&lt;br /&gt;
 mv baseconfig/* multitheftauto_linux-{{Current Version|full}}/mods/deathmatch&lt;br /&gt;
&lt;br /&gt;
Change to the MTA server install directory:&lt;br /&gt;
 cd multitheftauto_linux-{{Current Version|full}}&lt;br /&gt;
&lt;br /&gt;
=== Test ===&lt;br /&gt;
You can now test if the server will start correctly:&lt;br /&gt;
 ./mta-server&lt;br /&gt;
or if using the 64 bit server:&lt;br /&gt;
 ./mta-server64&lt;br /&gt;
&lt;br /&gt;
=== Default resources ===&lt;br /&gt;
If you need the default resources:&lt;br /&gt;
Download the latest default resources zip from http://mirror.mtasa.com/mtasa/resources/&lt;br /&gt;
and unzip into '''mods/deathmatch/resources'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Make sure you are in the MTA server install directory when following this example:'''&lt;br /&gt;
 apt-get install unzip&lt;br /&gt;
 mkdir mods/deathmatch/resources&lt;br /&gt;
 cd mods/deathmatch/resources&lt;br /&gt;
 rm mtasa-resources-latest.zip&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip&lt;br /&gt;
 unzip mtasa-resources-latest.zip&lt;br /&gt;
 rm mtasa-resources-latest.zip&lt;br /&gt;
&lt;br /&gt;
== Running with 32 or 64 bit Linux==&lt;br /&gt;
=== Make sure your server libraries and stuff are up to date ===&lt;br /&gt;
On Debian/Ubuntu this is done with:&lt;br /&gt;
 apt-get update&lt;br /&gt;
 apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
== Running with 32 bit Linux ==&lt;br /&gt;
===32 bit Troubleshooting===&lt;br /&gt;
* If you get a problem with such as &amp;quot;libreadline.so.5: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 32 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libreadline5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libncursesw.so.5 cannot open shared object file: No such file or directory&amp;quot;, it can be solved on 32 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libncursesw5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libmysqlclient.so.16: cannot open shared object file: No such file or directory&amp;quot;, it can be solved on Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libmysqlclient16&lt;br /&gt;
&lt;br /&gt;
If that fails, download [http://nightly.mtasa.com/files/libmysqlclient.so.16 libmysqlclient.so.16] and put it in '''/usr/lib/'''&lt;br /&gt;
&lt;br /&gt;
== Running with 64 bit Linux ==&lt;br /&gt;
===Debian 7 (wheezy) 64 bit===&lt;br /&gt;
Before running MTASA Server, use this command line for installation of 32 bit libs :&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32ncursesw5 lib32readline5&lt;br /&gt;
&lt;br /&gt;
===Install 32 bit libs for your 64 bit distro===&lt;br /&gt;
For 64 bit Debian 6, this is achieved with:&amp;lt;br/&amp;gt;&lt;br /&gt;
''(Some 64 bit distros have 32 bit libs already installed for you. So this step might not be required)''&lt;br /&gt;
&lt;br /&gt;
 apt-get install ia32-libs&lt;br /&gt;
&lt;br /&gt;
===64 bit Troubleshooting===&lt;br /&gt;
====64 bit Debian/Ubuntu====&lt;br /&gt;
* If you get a problem with such as &amp;quot;libstdc++.so.6: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32stdc++6&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libz.so.1: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32z1&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libreadline.so.5: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32readline5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libncursesw.so.5 cannot open shared object file: No such file or directory&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32ncursesw5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libmysqlclient.so.16: cannot open shared object file: No such file or directory&amp;quot;, it can be solved on Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libmysqlclient16&lt;br /&gt;
&lt;br /&gt;
** If that fails, download [http://nightly.mtasa.com/files/libmysqlclient.so.16 libmysqlclient.so.16] and put it in '''/usr/lib/'''&lt;br /&gt;
&lt;br /&gt;
**NOTE: If you are running the experimental MTA x64 server, you will need [http://nightly.mtasa.com/files/x64/libmysqlclient.so.16 this file] instead:&lt;br /&gt;
&lt;br /&gt;
====64 bit CentOS 6====&lt;br /&gt;
* If you get a problem with such as &amp;quot;libreadline.so.5: cannot open shared object file: No such file or directory.&amp;quot;, edit '''''/etc/yum.conf''''' and add this line:&lt;br /&gt;
 multilib_policy=all&lt;br /&gt;
Then issue this command:&lt;br /&gt;
 yum install compat-readline5&lt;br /&gt;
* Further 64 bit solutions can be found [http://forum.mtasa.com/viewtopic.php?f=106&amp;amp;t=35328#p367282 on the forums]&lt;br /&gt;
&lt;br /&gt;
== MySQL Troubleshooting==&lt;br /&gt;
* If you are using the inbuild MySQL functions such as [[dbConnect]] and [[dbQuery]], you will need to have '''libmysqlclient.so.16''' installed.&lt;br /&gt;
* If you can't get '''libmysqlclient.so.16''' installed by conventional means, then try [http://nightly.mtasa.com/files/libmysqlclient.so.16 downloading the file from here] and copying it to your Linux server '''/usr/lib/''' directory.&lt;br /&gt;
&lt;br /&gt;
==Cent OS Troubleshooting==&lt;br /&gt;
* If you are using Cent OS and you get something like /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by xmll.so) this can be resolved by doing downloading the archive [[http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/9/Fedora/i386/os/Packages/libstdc++-4.3.0-8.i386.rpm here]] and unpacking it with the following command:&lt;br /&gt;
&lt;br /&gt;
 rpm2cpio libstdc++-4.3.0-8.i386.rpm | cpio -i --make-directories&lt;br /&gt;
&lt;br /&gt;
==[Optional] Installing and Configuring an External Web Server==&lt;br /&gt;
Instructions on how to install and configure Nginx as an external web server for MTA is here: [[Installing and Configuring Nginx as an External Web Server]]&lt;br /&gt;
&lt;br /&gt;
== Server crashes ==&lt;br /&gt;
&lt;br /&gt;
If your Linux server crashes, please obtain a backtrace and post a report on our [http://bugs.mtasa.com/ Bug tracker]&lt;br /&gt;
&lt;br /&gt;
====To obtain a backtrace:====&lt;br /&gt;
===Do you have a core dump file in the the MTA server directory?===&lt;br /&gt;
It's usually called 'core', and usually over 100MB, and looks something like this:&lt;br /&gt;
 [[Image:Core.png]]&lt;br /&gt;
====If you have a core dump file in the the MTA server directory:====&lt;br /&gt;
*Install gdb. To install gdb on Debian, use this command:&lt;br /&gt;
 apt-get install gdb&lt;br /&gt;
*And from the MTA install directory do this command&lt;br /&gt;
 gdb mta-server -c core&lt;br /&gt;
*When gdb launches, do this command to get a  module list:&lt;br /&gt;
 i sh&lt;br /&gt;
*And then this command to get a backtrace:&lt;br /&gt;
 bt&lt;br /&gt;
*Save the output&lt;br /&gt;
*(To exit gdb, use the quit command)&lt;br /&gt;
&lt;br /&gt;
====If you do not have a core dump file in the the MTA server directory:====&lt;br /&gt;
*Install gdb. To install gdb on Debian, use this command:&lt;br /&gt;
 apt-get install gdb&lt;br /&gt;
*And from the MTA server directory start the mta-server like this:&lt;br /&gt;
 gdb mta-server -ex &amp;quot;set print thread-events off&amp;quot; --eval-command run&lt;br /&gt;
*Now wait for a crash. (Ignore any weird screen output in the meantime)&lt;br /&gt;
*When a crash occurs, do this command to get a module list:&lt;br /&gt;
 i sh&lt;br /&gt;
*And then this command to get a backtrace:&lt;br /&gt;
 bt&lt;br /&gt;
*Save the output&lt;br /&gt;
*(To exit gdb, use the quit command)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Server freezes''' ==&lt;br /&gt;
&lt;br /&gt;
If your Linux server freezes, please obtain a backtrace with thread information and post a report on our [http://bugs.mtasa.com/ Bug tracker]&lt;br /&gt;
&lt;br /&gt;
====To obtain a backtrace with thread information:====&lt;br /&gt;
*Install gdb. To install gdb on Debian, use this command:&lt;br /&gt;
 apt-get install gdb&lt;br /&gt;
*And from the MTA server directory start the mta-server like this:&lt;br /&gt;
 gdb mta-server -ex &amp;quot;set print thread-events off&amp;quot; --eval-command run&lt;br /&gt;
*Now wait for a freeze. (Ignore any weird screen output in the meantime)&lt;br /&gt;
*When a freeze occurs, press ctrl-c to start gdb&lt;br /&gt;
*Then do this command to get a module list:&lt;br /&gt;
 i sh&lt;br /&gt;
*And then this command to get a backtrace:&lt;br /&gt;
 bt&lt;br /&gt;
*And then this command to get thread information:&lt;br /&gt;
 info threads&lt;br /&gt;
*Save the output&lt;br /&gt;
*(To exit gdb, use the quit command)&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnClientPlayerChangeNick&amp;diff=46147</id>
		<title>OnClientPlayerChangeNick</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnClientPlayerChangeNick&amp;diff=46147"/>
		<updated>2015-12-04T06:05:05Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client event}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This event is triggered when a player changes his nickname.&lt;br /&gt;
&lt;br /&gt;
==Parameters== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string oldNick, string newNick&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*'''oldNick:''' the nickname the player had before.&lt;br /&gt;
*'''newNick:''' the new nickname of the player.&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The source of this event is the player that changed his nick&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example snippet sends a lame message every time the local player changes his nick.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler ( &amp;quot;onClientPlayerChangeNick&amp;quot;, getLocalPlayer(),&lt;br /&gt;
    function ( oldNick, newNick )&lt;br /&gt;
        outputChatBox ( &amp;quot;Hi &amp;quot; .. oldNick .. &amp;quot;! Oh... You're not &amp;quot; .. oldNick .. &amp;quot; anymore, are you?&amp;quot;, 0, 255, 0 )&lt;br /&gt;
        outputChatBox ( &amp;quot;I like your new name, &amp;quot; .. newNick .. &amp;quot;!&amp;quot;, 0, 255, 0 )&lt;br /&gt;
    end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
===Client player events===&lt;br /&gt;
{{Client_player_events}}&lt;br /&gt;
===Client event functions===&lt;br /&gt;
{{Client_event_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVersion&amp;diff=46124</id>
		<title>GetVersion</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVersion&amp;diff=46124"/>
		<updated>2015-11-25T21:24:17Z</updated>

		<summary type="html">&lt;p&gt;NOki: Made example code look nice. getPlayerSkin --&amp;gt; getElementModel&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
&lt;br /&gt;
This function gives you various version information about MTA and the operating system.&lt;br /&gt;
&lt;br /&gt;
''Note:'' Clientside will return the version from the player, and the server-sided will return version from the server.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table getVersion ( )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a table with version information. Specifically these keys are present in the table:&lt;br /&gt;
*'''number:''' the MTA server or client version (depending where the function was called) in pure numerical form, e.g. ''&amp;quot;256&amp;quot;''&lt;br /&gt;
*'''mta:''' the MTA server or client version (depending where the function was called) in textual form, e.g. ''&amp;quot;1.0&amp;quot;''&lt;br /&gt;
*'''name:''' the full MTA product name, either ''&amp;quot;MTA:SA Server&amp;quot;'' or ''&amp;quot;MTA:SA Client&amp;quot;''.&lt;br /&gt;
*'''netcode:''' the netcode version number.&lt;br /&gt;
*'''os:''' returns the operating system on which the server or client is running&lt;br /&gt;
*'''type:''' the type of build.  can be:&lt;br /&gt;
**'''&amp;quot;Nightly rX&amp;quot;''' - A nightly development build.  '''X''' represents the nightly build revision.&lt;br /&gt;
**'''&amp;quot;Custom&amp;quot;''' - A build compiled manually&lt;br /&gt;
**'''&amp;quot;Release&amp;quot;''' - A build that is publicly released (provisional).&lt;br /&gt;
*'''tag:''' the build tag (from 1.0.3 onwards). Contains infomation about the underlying version used. i.e. The final version of 1.0.3 has the build tag of &amp;quot;1.0.3 rc-9&amp;quot;. (This can be confirmed by using the console command 'ver'.)&lt;br /&gt;
*'''sortable:''' a 15 character sortable version string (from 1.0.4 onwards). Format of the string is described in [[getPlayerVersion]].&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
'''Example 1:''' This example will make a script compatible only with version 1.0:&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function setHoboSkin(playerSource)&lt;br /&gt;
  local version = getVersion()&lt;br /&gt;
  if version.number &amp;lt; 256 then -- MTA 1.0 version number is 0x0100&lt;br /&gt;
    setElementModel(playerSource, 137)&lt;br /&gt;
  else&lt;br /&gt;
    setElementModel(playerSource, 137)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;hobo&amp;quot;, setHoboSkin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This client and server example will kick players that have anything earlier than the final released version of 1.0.3:&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sendVersion()&lt;br /&gt;
  -- Send local player version to the server&lt;br /&gt;
  triggerServerEvent(&amp;quot;onNotifyPlayerVersion&amp;quot;, resourceRoot, getVersion())&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientResourceStart&amp;quot;, resourceRoot, sendVersion)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function handlePlayerVersion(version)&lt;br /&gt;
  if version.number &amp;gt; 256 + 3 then  -- Allow anything above 1.0.3&lt;br /&gt;
    return&lt;br /&gt;
  end&lt;br /&gt;
  if version.number == 256 + 3 then  -- Check further if it is exactly 1.0.3&lt;br /&gt;
    if version.type == &amp;quot;Release&amp;quot; then -- Check further if it is the &amp;quot;Release&amp;quot; type&lt;br /&gt;
      local _, _, buildnumber = string.find(version.tag or &amp;quot;&amp;quot;, &amp;quot;(%d)$&amp;quot;)  -- Extract the build number if there&lt;br /&gt;
      buildnumber = tonumber(buildnumber) or 0&lt;br /&gt;
      if buildnumber &amp;gt;= 9 then  -- Allow 9 and above&lt;br /&gt;
        return&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  outputConsole(&amp;quot;Kicking player as below 1.0.3 Release build 9&amp;quot;)&lt;br /&gt;
  kickPlayer(client, &amp;quot;Upgrade your version at www.mtasa.com&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
addEvent(&amp;quot;onNotifyPlayerVersion&amp;quot;, true)&lt;br /&gt;
addEventHandler(&amp;quot;onNotifyPlayerVersion&amp;quot;, resourceRoot, handlePlayerVersion)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Server functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Light&amp;diff=46064</id>
		<title>Light</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Light&amp;diff=46064"/>
		<updated>2015-10-26T11:49:37Z</updated>

		<summary type="html">&lt;p&gt;NOki: Redirected page to Element/Light&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Element/Light]]&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Light&amp;diff=46063</id>
		<title>Light</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Light&amp;diff=46063"/>
		<updated>2015-10-26T11:44:13Z</updated>

		<summary type="html">&lt;p&gt;NOki: Redirected page to Https://wiki.multitheftauto.com/wiki/Element/Light&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[https://wiki.multitheftauto.com/wiki/Element/Light]]&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User:NOki&amp;diff=46022</id>
		<title>User:NOki</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User:NOki&amp;diff=46022"/>
		<updated>2015-10-01T07:06:58Z</updated>

		<summary type="html">&lt;p&gt;NOki: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Contributions==&lt;br /&gt;
&lt;br /&gt;
- Addition of Tunisian flag to admin and admin2 [via GitHub].&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehicleColor&amp;diff=45921</id>
		<title>GetVehicleColor</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehicleColor&amp;diff=45921"/>
		<updated>2015-09-08T11:15:40Z</updated>

		<summary type="html">&lt;p&gt;NOki: Changed set to get (function name doesn't involving setting anything)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function returns the color of the specified vehicle. A vehicle can have up to four colors.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int int int int getVehicleColor ( vehicle theVehicle )             &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
{{OOP||[[vehicle]]:getColor}}&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theVehicle:''' the [[vehicle]] element.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns 4 [[int|ints]] indicating the color of the vehicle. Returns ''false'' if the vehicle doesn't exist.&lt;br /&gt;
&lt;br /&gt;
Valid color ids:&lt;br /&gt;
{{Vehicle_colors}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{New feature|3.0110|1.1|&lt;br /&gt;
From 1.1, as well as the above syntax, colors can also be retrieved as RGB values:&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int, int, int, int, int, int, int, int, int, int, int, int = getVehicleColor ( vehicle theVehicle, bool bRGB )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theVehicle:''' The [[vehicle]] that you wish to get the color of.&lt;br /&gt;
*'''bRGB :''' A boolean specifying whether to return RGB values. A setting of ''false'' will result in the function returning color ids instead.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
*Returns 12 [[int|ints]] (if bRGB is ''true'') indicating the red, green and blue components of each of the 4 vehicle colors.&lt;br /&gt;
*Returns 4 [[int|ints]] (if bRGB is ''false'') indicating the color ids of each of the 4 vehicle colors.&lt;br /&gt;
*Returns ''false'' if the vehicle doesn't exist.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt; &lt;br /&gt;
This will output the 4 colors of any car that the player enters.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function playerEnterVehicle ( theVehicle, seat, jacked )&lt;br /&gt;
    -- Get the colors of the car and store them to 4 seperate variables&lt;br /&gt;
    local color1, color2, color3, color4 = getVehicleColor ( theVehicle )&lt;br /&gt;
    -- Output the four retrieved car colors into the chatbox&lt;br /&gt;
    outputChatBox ( &amp;quot;Car color 1: &amp;quot; .. color1 )&lt;br /&gt;
    outputChatBox ( &amp;quot;Car color 2: &amp;quot; .. color2 )&lt;br /&gt;
    outputChatBox ( &amp;quot;Car color 3: &amp;quot; .. color3 )&lt;br /&gt;
    outputChatBox ( &amp;quot;Car color 4: &amp;quot; .. color4 )&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement(), playerEnterVehicle )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Vehicle functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetPedTarget&amp;diff=45881</id>
		<title>GetPedTarget</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetPedTarget&amp;diff=45881"/>
		<updated>2015-09-05T15:02:48Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function is used to get the element a [[ped]] is currently targeting.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
element getPedTarget ( ped thePed )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{OOP||[[ped]]:getTarget}}&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed:''' The [[ped]] whose target you want to retrieve.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the [[element]] that's being targeted, or ''false'' if there isn't one.&lt;br /&gt;
&lt;br /&gt;
This is only effective on physical GTA elements, namely:&lt;br /&gt;
* Players&lt;br /&gt;
* Vehicles&lt;br /&gt;
* Objects&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example blows up any vehicle a player targets (aims at).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function playerTargetCheck ( )&lt;br /&gt;
    local target&lt;br /&gt;
    for i, thePlayer in ipairs ( getElementsByType(&amp;quot;player&amp;quot;) ) do  -- iterate over all players&lt;br /&gt;
        target = getPedTarget ( thePlayer )                        -- get the target of the current player&lt;br /&gt;
        if ( target ) then                                         -- if there was a target&lt;br /&gt;
            if ( getElementType ( target ) == &amp;quot;vehicle&amp;quot; ) then     -- and the target is a vehicle&lt;br /&gt;
                blowVehicle ( target )                             -- blow it up&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
setTimer ( playerTargetCheck, 1000, 0 )                            -- call the check function every second&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: A more efficient way to do this would be to use the [[onPlayerTarget]] event.''&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Ped_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetVehicleColor&amp;diff=45880</id>
		<title>SetVehicleColor</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetVehicleColor&amp;diff=45880"/>
		<updated>2015-09-05T13:26:57Z</updated>

		<summary type="html">&lt;p&gt;NOki: Corrected wrong OOP syntax&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function will set the color of a vehicle. Colors are in RGB format, vehicles can have up to 4 colors. Most vehicles have 2 colors only.&lt;br /&gt;
&lt;br /&gt;
{{New feature|3.0110|1.1|&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setVehicleColor ( vehicle theVehicle, int r1, int g1, int b1, [int r2, int g2, int b2, int r3, int g3, int b3, int r4, int g4, int b4] )            &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{{OOP||[[vehicle]]:setColor}}&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theVehicle:''' The [[vehicle]] that you wish to set the color of.&lt;br /&gt;
*'''r1, g1, b1:''' Three integers indicating the red, green and blue components of the first (main) color for the vehicle&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''r2, g2, b2:''' Three integers indicating the red, green and blue components of the second color for the vehicle&lt;br /&gt;
*'''r3, g3, b3:''' Three integers indicating the red, green and blue components of the third color for the vehicle&lt;br /&gt;
*'''r4, g4, b4:''' Three integers indicating the red, green and blue components of the fourth color for the vehicle&lt;br /&gt;
}}&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if vehicle's color was set, ''false'' if an invalid vehicle or invalid colors were specified.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 1&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example implements a serverside ''random_color'' console command.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler( 'random_color',&lt;br /&gt;
	function( uPlayer )&lt;br /&gt;
		if isPedInVehicle( uPlayer ) then&lt;br /&gt;
			local uVehicle = getPedOccupiedVehicle( uPlayer )&lt;br /&gt;
			if uVehicle then&lt;br /&gt;
				local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 )&lt;br /&gt;
				setVehicleColor( uVehicle, r, g, b )&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Warning|Informations below apply to MTA:SA v1.0.5 and older!|true}}&lt;br /&gt;
&lt;br /&gt;
This function will set the color of a vehicle. Each vehicle can have up to 4 colors, for different aspects of the vehicle. Most vehicles only use two of the colors.&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setVehicleColor ( vehicle theVehicle, int color1, int color2, int color3, int color4 )            &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theVehicle:''' The [[vehicle]] that you wish to set the color of.&lt;br /&gt;
*'''color1:''' An integer indicating the first (main) color for the vehicle&lt;br /&gt;
*'''color2:''' An integer indicating the second color for the vehicle&lt;br /&gt;
*'''color3:''' An integer indicating the third color for the vehicle&lt;br /&gt;
*'''color4:''' An integer indicating the fourth color for the vehicle&lt;br /&gt;
&lt;br /&gt;
The table below shows valid color ids:&lt;br /&gt;
{{Vehicle_colors}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 1&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;
This example implements a serverside ''set_vehicle_color'' console command.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Define our function that will handle the command&lt;br /&gt;
function consoleSetVehicleColor ( playerSource, commandName, col1, col2, col3, col4 )&lt;br /&gt;
	-- If a player triggered this in-game&lt;br /&gt;
	if ( playerSource ) then&lt;br /&gt;
		-- Get the player's vehicle&lt;br /&gt;
		playerVehicle = getPlayerOccupiedVehicle ( playerSource )&lt;br /&gt;
		-- If the player is in a vehicle and we've got at least 1 parameter&lt;br /&gt;
		if ( playerVehicle and col1 ) then&lt;br /&gt;
			-- Get the vehicle's existing color and use it if fewer than 4 arguments were passed&lt;br /&gt;
			exCol1, exCol2, exCol3, exCol4 = getVehicleColor ( playerVehicle )&lt;br /&gt;
&lt;br /&gt;
			if not col2 then col2 = exCol2 end&lt;br /&gt;
			if not col3 then col3 = exCol3 end&lt;br /&gt;
			if not col4 then col4 = exCol4 end&lt;br /&gt;
&lt;br /&gt;
			-- Set the vehicle's color&lt;br /&gt;
			setVehicleColor ( playerVehicle, col1, col2, col3, col4 )&lt;br /&gt;
		else&lt;br /&gt;
			-- If we didn't get at least 1 parameter or the player doesn't have a vehicle, display some help text&lt;br /&gt;
			outputConsole ( &amp;quot;This function will set your current vehicle's colors. A vehicle can have up to 4 colors.&amp;quot;, playerSource )&lt;br /&gt;
			outputConsole ( &amp;quot;Syntax: set_vehicle_color color1 [ color2 color3 color4 ]&amp;quot;, playerSource )&lt;br /&gt;
			outputConsole ( &amp;quot;You must be in a vehicle to use this function.&amp;quot;, playerSource )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Register the command handler and attach it to the consoleSetVehicleColor function&lt;br /&gt;
addCommandHandler ( &amp;quot;set_vehicle_color&amp;quot;, consoleSetVehicleColor )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 2&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;
This example changes all vehicles color to random every 0.5 sec.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function randomVehColors()&lt;br /&gt;
	for i, car in ipairs( getElementsByType( &amp;quot;vehicle&amp;quot; ) ) do&lt;br /&gt;
		local color = {}&lt;br /&gt;
		color[1] = math.random(0,126) -- random from 0 to 126, because colors is from 0 to 126&lt;br /&gt;
		color[2] = math.random(0,126)&lt;br /&gt;
		color[3] = math.random(0,126)&lt;br /&gt;
		color[4] = math.random(0,126) -- we take 4 random numbers because setVehicleColor have parameters with 4 colors&lt;br /&gt;
		setVehicleColor ( car, color[1], color[2], color[3], color[4] ) -- setting color to vehicle&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
setTimer( randomVehColors, 500, 0 )	-- timer changes all vehicles colors to random every 0.5 sec.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Vehicle_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetVehicleColor&amp;diff=45879</id>
		<title>SetVehicleColor</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetVehicleColor&amp;diff=45879"/>
		<updated>2015-09-05T13:26:00Z</updated>

		<summary type="html">&lt;p&gt;NOki: Added OOP syntax&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function will set the color of a vehicle. Colors are in RGB format, vehicles can have up to 4 colors. Most vehicles have 2 colors only.&lt;br /&gt;
&lt;br /&gt;
{{New feature|3.0110|1.1|&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setVehicleColor ( vehicle theVehicle, int r1, int g1, int b1, [int r2, int g2, int b2, int r3, int g3, int b3, int r4, int g4, int b4] )            &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{{OOP||[[vehicle]]:setVehicleColor}}&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theVehicle:''' The [[vehicle]] that you wish to set the color of.&lt;br /&gt;
*'''r1, g1, b1:''' Three integers indicating the red, green and blue components of the first (main) color for the vehicle&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''r2, g2, b2:''' Three integers indicating the red, green and blue components of the second color for the vehicle&lt;br /&gt;
*'''r3, g3, b3:''' Three integers indicating the red, green and blue components of the third color for the vehicle&lt;br /&gt;
*'''r4, g4, b4:''' Three integers indicating the red, green and blue components of the fourth color for the vehicle&lt;br /&gt;
}}&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if vehicle's color was set, ''false'' if an invalid vehicle or invalid colors were specified.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 1&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example implements a serverside ''random_color'' console command.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler( 'random_color',&lt;br /&gt;
	function( uPlayer )&lt;br /&gt;
		if isPedInVehicle( uPlayer ) then&lt;br /&gt;
			local uVehicle = getPedOccupiedVehicle( uPlayer )&lt;br /&gt;
			if uVehicle then&lt;br /&gt;
				local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 )&lt;br /&gt;
				setVehicleColor( uVehicle, r, g, b )&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Warning|Informations below apply to MTA:SA v1.0.5 and older!|true}}&lt;br /&gt;
&lt;br /&gt;
This function will set the color of a vehicle. Each vehicle can have up to 4 colors, for different aspects of the vehicle. Most vehicles only use two of the colors.&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setVehicleColor ( vehicle theVehicle, int color1, int color2, int color3, int color4 )            &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theVehicle:''' The [[vehicle]] that you wish to set the color of.&lt;br /&gt;
*'''color1:''' An integer indicating the first (main) color for the vehicle&lt;br /&gt;
*'''color2:''' An integer indicating the second color for the vehicle&lt;br /&gt;
*'''color3:''' An integer indicating the third color for the vehicle&lt;br /&gt;
*'''color4:''' An integer indicating the fourth color for the vehicle&lt;br /&gt;
&lt;br /&gt;
The table below shows valid color ids:&lt;br /&gt;
{{Vehicle_colors}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 1&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;
This example implements a serverside ''set_vehicle_color'' console command.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Define our function that will handle the command&lt;br /&gt;
function consoleSetVehicleColor ( playerSource, commandName, col1, col2, col3, col4 )&lt;br /&gt;
	-- If a player triggered this in-game&lt;br /&gt;
	if ( playerSource ) then&lt;br /&gt;
		-- Get the player's vehicle&lt;br /&gt;
		playerVehicle = getPlayerOccupiedVehicle ( playerSource )&lt;br /&gt;
		-- If the player is in a vehicle and we've got at least 1 parameter&lt;br /&gt;
		if ( playerVehicle and col1 ) then&lt;br /&gt;
			-- Get the vehicle's existing color and use it if fewer than 4 arguments were passed&lt;br /&gt;
			exCol1, exCol2, exCol3, exCol4 = getVehicleColor ( playerVehicle )&lt;br /&gt;
&lt;br /&gt;
			if not col2 then col2 = exCol2 end&lt;br /&gt;
			if not col3 then col3 = exCol3 end&lt;br /&gt;
			if not col4 then col4 = exCol4 end&lt;br /&gt;
&lt;br /&gt;
			-- Set the vehicle's color&lt;br /&gt;
			setVehicleColor ( playerVehicle, col1, col2, col3, col4 )&lt;br /&gt;
		else&lt;br /&gt;
			-- If we didn't get at least 1 parameter or the player doesn't have a vehicle, display some help text&lt;br /&gt;
			outputConsole ( &amp;quot;This function will set your current vehicle's colors. A vehicle can have up to 4 colors.&amp;quot;, playerSource )&lt;br /&gt;
			outputConsole ( &amp;quot;Syntax: set_vehicle_color color1 [ color2 color3 color4 ]&amp;quot;, playerSource )&lt;br /&gt;
			outputConsole ( &amp;quot;You must be in a vehicle to use this function.&amp;quot;, playerSource )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Register the command handler and attach it to the consoleSetVehicleColor function&lt;br /&gt;
addCommandHandler ( &amp;quot;set_vehicle_color&amp;quot;, consoleSetVehicleColor )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 2&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;
This example changes all vehicles color to random every 0.5 sec.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function randomVehColors()&lt;br /&gt;
	for i, car in ipairs( getElementsByType( &amp;quot;vehicle&amp;quot; ) ) do&lt;br /&gt;
		local color = {}&lt;br /&gt;
		color[1] = math.random(0,126) -- random from 0 to 126, because colors is from 0 to 126&lt;br /&gt;
		color[2] = math.random(0,126)&lt;br /&gt;
		color[3] = math.random(0,126)&lt;br /&gt;
		color[4] = math.random(0,126) -- we take 4 random numbers because setVehicleColor have parameters with 4 colors&lt;br /&gt;
		setVehicleColor ( car, color[1], color[2], color[3], color[4] ) -- setting color to vehicle&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
setTimer( randomVehColors, 500, 0 )	-- timer changes all vehicles colors to random every 0.5 sec.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Vehicle_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehicleType&amp;diff=45875</id>
		<title>GetVehicleType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehicleType&amp;diff=45875"/>
		<updated>2015-09-05T10:44:17Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Required Arguments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
This function retrieves the type of a vehicle (such as if it is a car or a boat).&lt;br /&gt;
}}&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string getVehicleType ( vehicle theVehicle )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
{{OOP||[[vehicle]]:getVehicleType|vehicleType}}&lt;br /&gt;
'''OR'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string getVehicleType ( int modelId )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''vehicle:''' The vehicle element to get the type of.&lt;br /&gt;
&lt;br /&gt;
'''OR'''&lt;br /&gt;
&lt;br /&gt;
*'''modelID:''' A vehicle model ID&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a ''string'' with vehicle type or ''false'' if an invalid modelID has been supplied, or an empty string if the vehicle is blocked internally (some trailers).&lt;br /&gt;
&lt;br /&gt;
Possible strings returned:&lt;br /&gt;
* '''Automobile''': Cars, vans and trucks&lt;br /&gt;
* '''Plane'''&lt;br /&gt;
* '''Bike''': Motorbikes&lt;br /&gt;
* '''Helicopter'''&lt;br /&gt;
* '''Boat'''&lt;br /&gt;
* '''Train'''&lt;br /&gt;
* '''Trailer''': A trailer for a truck&lt;br /&gt;
* '''BMX'''&lt;br /&gt;
* '''Monster Truck'''&lt;br /&gt;
* '''Quad''': Quadbikes&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
'''Example 1:''' In this example when a player enters an airplane, it displays a message welcoming the player onboard.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function enterPlane(theVehicle, seat, jacked)&lt;br /&gt;
    if (getVehicleType(theVehicle) == &amp;quot;Plane&amp;quot;) then&lt;br /&gt;
        outputChatBox(&amp;quot;Welcome onboard!&amp;quot;, source)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement(), enterPlane)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' In this example player gets message what type of vehicle he just entered.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function enteredVehicleType(theVehicle, seat, jacked)&lt;br /&gt;
	outputChatBox(&amp;quot;You entered &amp;quot;.. getVehicleType(theVehicle) ..&amp;quot;.&amp;quot;, source)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement(), enteredVehicleType)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Vehicle functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=ExecuteSQLQuery&amp;diff=44716</id>
		<title>ExecuteSQLQuery</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ExecuteSQLQuery&amp;diff=44716"/>
		<updated>2015-02-22T08:25:28Z</updated>

		<summary type="html">&lt;p&gt;NOki: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
&lt;br /&gt;
This function executes an arbitrary SQL query and returns the result rows if there are any. It allows parameter binding for security (SQL injection is rendered impossible).&lt;br /&gt;
&lt;br /&gt;
'''NOTE: This function only acts upon registry.db. Use dbQuery to query a custom SQL databse.'''&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table executeSQLQuery(string query [, var param1 [, var param2 ...]])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''query:''' An SQL query. Positions where parameter values will be inserted are marked with a &amp;quot;?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''paramX:''' A variable number of parameters. These must be strings or numbers - it is important to make sure they are of the correct type. Also, the number of parameters passed must be equal to the number of &amp;quot;?&amp;quot; characters in the query string.&lt;br /&gt;
String parameters are automatically escaped by adding a backslash (\) before ' and \ characters.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a table with the result of the query if it was a SELECT query, or ''false'' if otherwise. In case of a SELECT query the result table may be empty (if there are no result rows). The table is of the form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    { colname1=value1, colname2=value2, ... },&lt;br /&gt;
    { colname1=value3, colname2=value4, ... },&lt;br /&gt;
    ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
Below are examples of equivalents for the deprecated executeSQL functions. Note that ` (backtick) can optionally be used to surround table and row names. It usually a good idea to do this to avoid name clashes with SQL reserved words.&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLCreateTable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;CREATE TABLE IF NOT EXISTS players (clothes_head_texture TEXT, clothes_head_model TEXT, name TEXT)&amp;quot;)&lt;br /&gt;
executeSQLQuery(&amp;quot;CREATE TABLE IF NOT EXISTS `players` (`clothes_head_texture` TEXT, `clothes_head_model` TEXT, `name` TEXT)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLDelete:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;DELETE FROM players WHERE name=?&amp;quot;, playerName)&lt;br /&gt;
executeSQLQuery(&amp;quot;DELETE FROM `players` WHERE `name`=?&amp;quot;, playerName)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLDropTable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;DROP TABLE players&amp;quot; )&lt;br /&gt;
executeSQLQuery(&amp;quot;DROP TABLE `players`&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLSelect:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;SELECT score,health FROM players WHERE name=?&amp;quot;, playerName )&lt;br /&gt;
executeSQLQuery(&amp;quot;SELECT `score`,`health` FROM `players` WHERE `name`=?&amp;quot;, playerName )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLInsert:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;INSERT INTO players(name,color,sound) VALUES(?,?,?)&amp;quot;, playerName, colorName, soundName )&lt;br /&gt;
executeSQLQuery(&amp;quot;INSERT INTO `players`(`name`,`color`,`sound`) VALUES(?,?,?)&amp;quot;, playerName, colorName, soundName )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLUpdate:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;UPDATE players SET color='green',sound='somehead' WHERE name=?&amp;quot;, playerName )&lt;br /&gt;
executeSQLQuery(&amp;quot;UPDATE players SET color=?,sound=? WHERE name=?&amp;quot;, colorName, soundName, playerName )&lt;br /&gt;
executeSQLQuery(&amp;quot;UPDATE `players` SET `color`=?,`sound`=? WHERE `name`=?&amp;quot;, colorName, soundName, playerName )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example defines a console command that shows the ID's and names of all registered (stored in database) players that have more than the specified amount of money.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function listPlayersWithMoreMoneyThan(thePlayer, command, amount)&lt;br /&gt;
    local players = executeSQLQuery(&amp;quot;SELECT id, name FROM players WHERE money &amp;gt; ?&amp;quot;, tonumber(amount))&lt;br /&gt;
    outputConsole(&amp;quot;Players with more money than &amp;quot; .. amount .. &amp;quot;:&amp;quot;, thePlayer)&lt;br /&gt;
    for i, playerdata in ipairs(players) do&lt;br /&gt;
        outputConsole(playerdata.id .. &amp;quot;: &amp;quot; .. playerdata.name, thePlayer)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;richplayers&amp;quot;, listPlayersWithMoreMoneyThan)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example shows the amount of money a certain registered player has.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function showPlayerMoney(thePlayer, command, playerName)&lt;br /&gt;
    local result = executeSQLQuery(&amp;quot;SELECT money FROM players WHERE name=?&amp;quot;, playerName)&lt;br /&gt;
    if(#result == 0) then&lt;br /&gt;
        outputConsole(&amp;quot;No player named &amp;quot; .. playerName .. &amp;quot; is registered.&amp;quot;, thePlayer)&lt;br /&gt;
    else&lt;br /&gt;
        outputConsole(&amp;quot;Money amount of player &amp;quot; .. playerName .. &amp;quot; is &amp;quot; .. result[1].money, thePlayer)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;playermoney&amp;quot;, showPlayerMoney)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice the lack of single quotes around the &amp;quot;?&amp;quot; in this example, even though it represents a string. executeSQLQuery will see that the playerName variable is a string and take care of the correct execution of the query by itself.&lt;br /&gt;
&lt;br /&gt;
The advantage of using executeSQLQuery is that it is immune to users trying to exploit the query with an SQL injection attack. playerName may contain special characters like ', &amp;quot; or -- that will not influence the query, unlike the older approach where playerName would be concatenated into the query string.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Registry_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=ExecuteSQLQuery&amp;diff=44715</id>
		<title>ExecuteSQLQuery</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ExecuteSQLQuery&amp;diff=44715"/>
		<updated>2015-02-22T08:24:32Z</updated>

		<summary type="html">&lt;p&gt;NOki: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
&lt;br /&gt;
This function executes an arbitrary SQL query and returns the result rows if there are any. It allows parameter binding for security (SQL injection is rendered impossible).&lt;br /&gt;
&lt;br /&gt;
'''NOTE: This function only acts upon registry.db'''&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table executeSQLQuery(string query [, var param1 [, var param2 ...]])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''query:''' An SQL query. Positions where parameter values will be inserted are marked with a &amp;quot;?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''paramX:''' A variable number of parameters. These must be strings or numbers - it is important to make sure they are of the correct type. Also, the number of parameters passed must be equal to the number of &amp;quot;?&amp;quot; characters in the query string.&lt;br /&gt;
String parameters are automatically escaped by adding a backslash (\) before ' and \ characters.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a table with the result of the query if it was a SELECT query, or ''false'' if otherwise. In case of a SELECT query the result table may be empty (if there are no result rows). The table is of the form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    { colname1=value1, colname2=value2, ... },&lt;br /&gt;
    { colname1=value3, colname2=value4, ... },&lt;br /&gt;
    ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
Below are examples of equivalents for the deprecated executeSQL functions. Note that ` (backtick) can optionally be used to surround table and row names. It usually a good idea to do this to avoid name clashes with SQL reserved words.&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLCreateTable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;CREATE TABLE IF NOT EXISTS players (clothes_head_texture TEXT, clothes_head_model TEXT, name TEXT)&amp;quot;)&lt;br /&gt;
executeSQLQuery(&amp;quot;CREATE TABLE IF NOT EXISTS `players` (`clothes_head_texture` TEXT, `clothes_head_model` TEXT, `name` TEXT)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLDelete:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;DELETE FROM players WHERE name=?&amp;quot;, playerName)&lt;br /&gt;
executeSQLQuery(&amp;quot;DELETE FROM `players` WHERE `name`=?&amp;quot;, playerName)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLDropTable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;DROP TABLE players&amp;quot; )&lt;br /&gt;
executeSQLQuery(&amp;quot;DROP TABLE `players`&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLSelect:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;SELECT score,health FROM players WHERE name=?&amp;quot;, playerName )&lt;br /&gt;
executeSQLQuery(&amp;quot;SELECT `score`,`health` FROM `players` WHERE `name`=?&amp;quot;, playerName )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLInsert:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;INSERT INTO players(name,color,sound) VALUES(?,?,?)&amp;quot;, playerName, colorName, soundName )&lt;br /&gt;
executeSQLQuery(&amp;quot;INSERT INTO `players`(`name`,`color`,`sound`) VALUES(?,?,?)&amp;quot;, playerName, colorName, soundName )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLUpdate:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;UPDATE players SET color='green',sound='somehead' WHERE name=?&amp;quot;, playerName )&lt;br /&gt;
executeSQLQuery(&amp;quot;UPDATE players SET color=?,sound=? WHERE name=?&amp;quot;, colorName, soundName, playerName )&lt;br /&gt;
executeSQLQuery(&amp;quot;UPDATE `players` SET `color`=?,`sound`=? WHERE `name`=?&amp;quot;, colorName, soundName, playerName )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example defines a console command that shows the ID's and names of all registered (stored in database) players that have more than the specified amount of money.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function listPlayersWithMoreMoneyThan(thePlayer, command, amount)&lt;br /&gt;
    local players = executeSQLQuery(&amp;quot;SELECT id, name FROM players WHERE money &amp;gt; ?&amp;quot;, tonumber(amount))&lt;br /&gt;
    outputConsole(&amp;quot;Players with more money than &amp;quot; .. amount .. &amp;quot;:&amp;quot;, thePlayer)&lt;br /&gt;
    for i, playerdata in ipairs(players) do&lt;br /&gt;
        outputConsole(playerdata.id .. &amp;quot;: &amp;quot; .. playerdata.name, thePlayer)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;richplayers&amp;quot;, listPlayersWithMoreMoneyThan)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example shows the amount of money a certain registered player has.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function showPlayerMoney(thePlayer, command, playerName)&lt;br /&gt;
    local result = executeSQLQuery(&amp;quot;SELECT money FROM players WHERE name=?&amp;quot;, playerName)&lt;br /&gt;
    if(#result == 0) then&lt;br /&gt;
        outputConsole(&amp;quot;No player named &amp;quot; .. playerName .. &amp;quot; is registered.&amp;quot;, thePlayer)&lt;br /&gt;
    else&lt;br /&gt;
        outputConsole(&amp;quot;Money amount of player &amp;quot; .. playerName .. &amp;quot; is &amp;quot; .. result[1].money, thePlayer)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;playermoney&amp;quot;, showPlayerMoney)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice the lack of single quotes around the &amp;quot;?&amp;quot; in this example, even though it represents a string. executeSQLQuery will see that the playerName variable is a string and take care of the correct execution of the query by itself.&lt;br /&gt;
&lt;br /&gt;
The advantage of using executeSQLQuery is that it is immune to users trying to exploit the query with an SQL injection attack. playerName may contain special characters like ', &amp;quot; or -- that will not influence the query, unlike the older approach where playerName would be concatenated into the query string.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Registry_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=ExecuteSQLQuery&amp;diff=44714</id>
		<title>ExecuteSQLQuery</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ExecuteSQLQuery&amp;diff=44714"/>
		<updated>2015-02-22T08:23:55Z</updated>

		<summary type="html">&lt;p&gt;NOki: Added registry.db information (http://forum.mtasa.com/viewtopic.php?f=91&amp;amp;t=85455#p774295)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
&lt;br /&gt;
This function executes an arbitrary SQL query and returns the result rows if there are any. It allows parameter binding for security (SQL injection is rendered impossible).&lt;br /&gt;
'''NOTE: This function only acts upon registry.db'''&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table executeSQLQuery(string query [, var param1 [, var param2 ...]])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''query:''' An SQL query. Positions where parameter values will be inserted are marked with a &amp;quot;?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''paramX:''' A variable number of parameters. These must be strings or numbers - it is important to make sure they are of the correct type. Also, the number of parameters passed must be equal to the number of &amp;quot;?&amp;quot; characters in the query string.&lt;br /&gt;
String parameters are automatically escaped by adding a backslash (\) before ' and \ characters.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a table with the result of the query if it was a SELECT query, or ''false'' if otherwise. In case of a SELECT query the result table may be empty (if there are no result rows). The table is of the form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    { colname1=value1, colname2=value2, ... },&lt;br /&gt;
    { colname1=value3, colname2=value4, ... },&lt;br /&gt;
    ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
Below are examples of equivalents for the deprecated executeSQL functions. Note that ` (backtick) can optionally be used to surround table and row names. It usually a good idea to do this to avoid name clashes with SQL reserved words.&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLCreateTable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;CREATE TABLE IF NOT EXISTS players (clothes_head_texture TEXT, clothes_head_model TEXT, name TEXT)&amp;quot;)&lt;br /&gt;
executeSQLQuery(&amp;quot;CREATE TABLE IF NOT EXISTS `players` (`clothes_head_texture` TEXT, `clothes_head_model` TEXT, `name` TEXT)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLDelete:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;DELETE FROM players WHERE name=?&amp;quot;, playerName)&lt;br /&gt;
executeSQLQuery(&amp;quot;DELETE FROM `players` WHERE `name`=?&amp;quot;, playerName)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLDropTable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;DROP TABLE players&amp;quot; )&lt;br /&gt;
executeSQLQuery(&amp;quot;DROP TABLE `players`&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLSelect:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;SELECT score,health FROM players WHERE name=?&amp;quot;, playerName )&lt;br /&gt;
executeSQLQuery(&amp;quot;SELECT `score`,`health` FROM `players` WHERE `name`=?&amp;quot;, playerName )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLInsert:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;INSERT INTO players(name,color,sound) VALUES(?,?,?)&amp;quot;, playerName, colorName, soundName )&lt;br /&gt;
executeSQLQuery(&amp;quot;INSERT INTO `players`(`name`,`color`,`sound`) VALUES(?,?,?)&amp;quot;, playerName, colorName, soundName )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example equivalents for executeSQLUpdate:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
executeSQLQuery(&amp;quot;UPDATE players SET color='green',sound='somehead' WHERE name=?&amp;quot;, playerName )&lt;br /&gt;
executeSQLQuery(&amp;quot;UPDATE players SET color=?,sound=? WHERE name=?&amp;quot;, colorName, soundName, playerName )&lt;br /&gt;
executeSQLQuery(&amp;quot;UPDATE `players` SET `color`=?,`sound`=? WHERE `name`=?&amp;quot;, colorName, soundName, playerName )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example defines a console command that shows the ID's and names of all registered (stored in database) players that have more than the specified amount of money.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function listPlayersWithMoreMoneyThan(thePlayer, command, amount)&lt;br /&gt;
    local players = executeSQLQuery(&amp;quot;SELECT id, name FROM players WHERE money &amp;gt; ?&amp;quot;, tonumber(amount))&lt;br /&gt;
    outputConsole(&amp;quot;Players with more money than &amp;quot; .. amount .. &amp;quot;:&amp;quot;, thePlayer)&lt;br /&gt;
    for i, playerdata in ipairs(players) do&lt;br /&gt;
        outputConsole(playerdata.id .. &amp;quot;: &amp;quot; .. playerdata.name, thePlayer)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;richplayers&amp;quot;, listPlayersWithMoreMoneyThan)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example shows the amount of money a certain registered player has.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function showPlayerMoney(thePlayer, command, playerName)&lt;br /&gt;
    local result = executeSQLQuery(&amp;quot;SELECT money FROM players WHERE name=?&amp;quot;, playerName)&lt;br /&gt;
    if(#result == 0) then&lt;br /&gt;
        outputConsole(&amp;quot;No player named &amp;quot; .. playerName .. &amp;quot; is registered.&amp;quot;, thePlayer)&lt;br /&gt;
    else&lt;br /&gt;
        outputConsole(&amp;quot;Money amount of player &amp;quot; .. playerName .. &amp;quot; is &amp;quot; .. result[1].money, thePlayer)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;playermoney&amp;quot;, showPlayerMoney)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice the lack of single quotes around the &amp;quot;?&amp;quot; in this example, even though it represents a string. executeSQLQuery will see that the playerName variable is a string and take care of the correct execution of the query by itself.&lt;br /&gt;
&lt;br /&gt;
The advantage of using executeSQLQuery is that it is immune to users trying to exploit the query with an SQL injection attack. playerName may contain special characters like ', &amp;quot; or -- that will not influence the query, unlike the older approach where playerName would be concatenated into the query string.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Registry_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Installing_and_Running_MTASA_Server_on_GNU_Linux&amp;diff=44672</id>
		<title>Installing and Running MTASA Server on GNU Linux</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Installing_and_Running_MTASA_Server_on_GNU_Linux&amp;diff=44672"/>
		<updated>2015-02-15T04:38:59Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Default config */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installation ==&lt;br /&gt;
&lt;br /&gt;
=== Main binary ===&lt;br /&gt;
Download the latest stable Linux binaries from here:&lt;br /&gt;
 rm multitheftauto_linux-{{Current Version|full}}.tar.gz&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://linux.mtasa.com/dl/141/multitheftauto_linux-{{Current Version|full}}.tar.gz&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
or if you are feeling daring, get the latest nightly build from here:&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://nightly.mtasa.com/?multitheftauto_linux-{{Current Version|full}}-latest&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
Unpack into a directory:&lt;br /&gt;
 tar -xf multitheftauto_linux-{{Current Version|full}}.tar.gz&lt;br /&gt;
&lt;br /&gt;
=== Default config ===&lt;br /&gt;
Download the default config files:&lt;br /&gt;
 rm baseconfig-{{Current Version|full}}.tar.gz&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://linux.mtasa.com/dl/141/baseconfig-{{Current Version|full}}.tar.gz&lt;br /&gt;
&lt;br /&gt;
Unpack and move into the deathmatch directory:&amp;lt;br/&amp;gt;&lt;br /&gt;
('''''Note:''' Only do this for new installations as it will overwrite any existing config files.)''&lt;br /&gt;
 tar -xf baseconfig-{{Current Version|full}}.tar.gz&lt;br /&gt;
 mv baseconfig/* multitheftauto_linux-{{Current Version|full}}/mods/deathmatch&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Default resources ===&lt;br /&gt;
Download the latest default resources:&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip&lt;br /&gt;
(mtasa-resources-latest.zip is an example. Check http://mirror.mtasa.com/mtasa/resources/ for the latest file name)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Test ===&lt;br /&gt;
You can now test if the server will start correctly, by entering the install directory:&lt;br /&gt;
 cd multitheftauto_linux-{{Current Version|full}}&lt;br /&gt;
&lt;br /&gt;
and launching:&lt;br /&gt;
 ./mta-server&lt;br /&gt;
&lt;br /&gt;
=== Default resources ===&lt;br /&gt;
If you need the default resources:&lt;br /&gt;
Download the latest default resources zip from http://mirror.mtasa.com/mtasa/resources/&lt;br /&gt;
and unzip into '''mods/deathmatch/resources'''&lt;br /&gt;
For example:&lt;br /&gt;
 apt-get install unzip&lt;br /&gt;
 mkdir mods/deathmatch/resources&lt;br /&gt;
 cd mods/deathmatch/resources&lt;br /&gt;
 rm mtasa-resources-latest.zip&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip&lt;br /&gt;
 unzip mtasa-resources-latest.zip&lt;br /&gt;
 rm mtasa-resources-latest.zip&lt;br /&gt;
&lt;br /&gt;
== Running with 32 or 64 bit Linux==&lt;br /&gt;
=== Make sure your server libraries and stuff are up to date ===&lt;br /&gt;
On Debian/Ubuntu this is done with:&lt;br /&gt;
 apt-get update&lt;br /&gt;
 apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
== Running with 32 bit Linux ==&lt;br /&gt;
===32 bit Troubleshooting===&lt;br /&gt;
* If you get a problem with such as &amp;quot;libreadline.so.5: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 32 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libreadline5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libncursesw.so.5 cannot open shared object file: No such file or directory&amp;quot;, it can be solved on 32 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libncursesw5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libmysqlclient.so.16: cannot open shared object file: No such file or directory&amp;quot;, it can be solved on Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libmysqlclient16&lt;br /&gt;
&lt;br /&gt;
If that fails, download [http://nightly.mtasa.com/files/libmysqlclient.so.16 libmysqlclient.so.16] and put it in '''/usr/lib/'''&lt;br /&gt;
&lt;br /&gt;
== Running with 64 bit Linux ==&lt;br /&gt;
===Debian 7 (wheezy) 64 bit===&lt;br /&gt;
Before running MTASA Server, use this command line for installation of 32 bit libs :&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32ncursesw5 lib32readline5&lt;br /&gt;
&lt;br /&gt;
===Install 32 bit libs for your 64 bit distro===&lt;br /&gt;
For 64 bit Debian 6, this is achieved with:&amp;lt;br/&amp;gt;&lt;br /&gt;
''(Some 64 bit distros have 32 bit libs already installed for you. So this step might not be required)''&lt;br /&gt;
&lt;br /&gt;
 apt-get install ia32-libs&lt;br /&gt;
&lt;br /&gt;
===64 bit Troubleshooting===&lt;br /&gt;
====64 bit Debian/Ubuntu====&lt;br /&gt;
* If you get a problem with such as &amp;quot;libstdc++.so.6: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32stdc++6&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libz.so.1: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32z1&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libreadline.so.5: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32readline5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libncursesw.so.5 cannot open shared object file: No such file or directory&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32ncursesw5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libmysqlclient.so.16: cannot open shared object file: No such file or directory&amp;quot;, it can be solved on Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libmysqlclient16&lt;br /&gt;
&lt;br /&gt;
** If that fails, download [http://nightly.mtasa.com/files/libmysqlclient.so.16 libmysqlclient.so.16] and put it in '''/usr/lib/'''&lt;br /&gt;
&lt;br /&gt;
**NOTE: If you are running the experimental MTA x64 server, you will need [http://nightly.mtasa.com/files/x64/libmysqlclient.so.16 this file] instead:&lt;br /&gt;
&lt;br /&gt;
====64 bit CentOS 6====&lt;br /&gt;
* If you get a problem with such as &amp;quot;libreadline.so.5: cannot open shared object file: No such file or directory.&amp;quot;, edit '''''/etc/yum.conf''''' and add this line:&lt;br /&gt;
 multilib_policy=all&lt;br /&gt;
Then issue this command:&lt;br /&gt;
 yum install compat-readline5&lt;br /&gt;
* Further 64 bit solutions can be found [http://forum.mtasa.com/viewtopic.php?f=106&amp;amp;t=35328#p367282 on the forums]&lt;br /&gt;
&lt;br /&gt;
== MySQL Troubleshooting==&lt;br /&gt;
* If you are using the inbuild MySQL functions such as [[dbConnect]] and [[dbQuery]], you will need to have '''libmysqlclient.so.16''' installed.&lt;br /&gt;
* If you can't get '''libmysqlclient.so.16''' installed by conventional means, then try [http://nightly.mtasa.com/files/libmysqlclient.so.16 downloading the file from here] and copying it to your Linux server '''/usr/lib/''' directory.&lt;br /&gt;
&lt;br /&gt;
==Cent OS Troubleshooting==&lt;br /&gt;
* If you are using Cent OS and you get something like /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by xmll.so) this can be resolved by doing downloading the archive [[http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/9/Fedora/i386/os/Packages/libstdc++-4.3.0-8.i386.rpm here]] and unpacking it with the following command:&lt;br /&gt;
&lt;br /&gt;
 rpm2cpio libstdc++-4.3.0-8.i386.rpm | cpio -i --make-directories&lt;br /&gt;
&lt;br /&gt;
==[Optional] Installing and Configuring an External Web Server==&lt;br /&gt;
Instructions on how to install and configure Nginx as an external web server for MTA is here: [[Installing and Configuring Nginx as an External Web Server]]&lt;br /&gt;
&lt;br /&gt;
== Server crashes ==&lt;br /&gt;
&lt;br /&gt;
If your Linux server crashes, please obtain a backtrace and post a report on our [http://bugs.mtasa.com/ Bug tracker]&lt;br /&gt;
&lt;br /&gt;
====To obtain a backtrace:====&lt;br /&gt;
===Do you have a core dump file in the the MTA server directory?===&lt;br /&gt;
It's usually called 'core', and usually over 100MB, and looks something like this:&lt;br /&gt;
 [[Image:Core.png]]&lt;br /&gt;
====If you have a core dump file in the the MTA server directory:====&lt;br /&gt;
*Install gdb. To install gdb on Debian, use this command:&lt;br /&gt;
 apt-get install gdb&lt;br /&gt;
*And from the MTA install directory do this command&lt;br /&gt;
 gdb mta-server -c core&lt;br /&gt;
*When gdb launches, do this command to get a  module list:&lt;br /&gt;
 i sh&lt;br /&gt;
*And then this command to get a backtrace:&lt;br /&gt;
 bt&lt;br /&gt;
*Save the output&lt;br /&gt;
*(To exit gdb, use the quit command)&lt;br /&gt;
&lt;br /&gt;
====If you do not have a core dump file in the the MTA server directory:====&lt;br /&gt;
*Install gdb. To install gdb on Debian, use this command:&lt;br /&gt;
 apt-get install gdb&lt;br /&gt;
*And from the MTA server directory start the mta-server like this:&lt;br /&gt;
 gdb mta-server -ex &amp;quot;set print thread-events off&amp;quot; --eval-command run&lt;br /&gt;
*Now wait for a crash. (Ignore any weird screen output in the meantime)&lt;br /&gt;
*When a crash occurs, do this command to get a module list:&lt;br /&gt;
 i sh&lt;br /&gt;
*And then this command to get a backtrace:&lt;br /&gt;
 bt&lt;br /&gt;
*Save the output&lt;br /&gt;
*(To exit gdb, use the quit command)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Server freezes''' ==&lt;br /&gt;
&lt;br /&gt;
If your Linux server freezes, please obtain a backtrace with thread information and post a report on our [http://bugs.mtasa.com/ Bug tracker]&lt;br /&gt;
&lt;br /&gt;
====To obtain a backtrace with thread information:====&lt;br /&gt;
*Install gdb. To install gdb on Debian, use this command:&lt;br /&gt;
 apt-get install gdb&lt;br /&gt;
*And from the MTA server directory start the mta-server like this:&lt;br /&gt;
 gdb mta-server -ex &amp;quot;set print thread-events off&amp;quot; --eval-command run&lt;br /&gt;
*Now wait for a freeze. (Ignore any weird screen output in the meantime)&lt;br /&gt;
*When a freeze occurs, press ctrl-c to start gdb&lt;br /&gt;
*Then do this command to get a module list:&lt;br /&gt;
 i sh&lt;br /&gt;
*And then this command to get a backtrace:&lt;br /&gt;
 bt&lt;br /&gt;
*And then this command to get thread information:&lt;br /&gt;
 info threads&lt;br /&gt;
*Save the output&lt;br /&gt;
*(To exit gdb, use the quit command)&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Installing_and_Running_MTASA_Server_on_GNU_Linux&amp;diff=44671</id>
		<title>Installing and Running MTASA Server on GNU Linux</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Installing_and_Running_MTASA_Server_on_GNU_Linux&amp;diff=44671"/>
		<updated>2015-02-15T04:38:04Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Main binary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installation ==&lt;br /&gt;
&lt;br /&gt;
=== Main binary ===&lt;br /&gt;
Download the latest stable Linux binaries from here:&lt;br /&gt;
 rm multitheftauto_linux-{{Current Version|full}}.tar.gz&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://linux.mtasa.com/dl/141/multitheftauto_linux-{{Current Version|full}}.tar.gz&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
or if you are feeling daring, get the latest nightly build from here:&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://nightly.mtasa.com/?multitheftauto_linux-{{Current Version|full}}-latest&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
Unpack into a directory:&lt;br /&gt;
 tar -xf multitheftauto_linux-{{Current Version|full}}.tar.gz&lt;br /&gt;
&lt;br /&gt;
=== Default config ===&lt;br /&gt;
Download the default config files:&lt;br /&gt;
 rm baseconfig-{{Current Version|full}}.tar.gz&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://linux.mtasa.com/dl/140/baseconfig-{{Current Version|full}}.tar.gz&lt;br /&gt;
&lt;br /&gt;
Unpack and move into the deathmatch directory:&amp;lt;br/&amp;gt;&lt;br /&gt;
('''''Note:''' Only do this for new installations as it will overwrite any existing config files.)''&lt;br /&gt;
 tar -xf baseconfig-{{Current Version|full}}.tar.gz&lt;br /&gt;
 mv baseconfig/* multitheftauto_linux-{{Current Version|full}}/mods/deathmatch&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Default resources ===&lt;br /&gt;
Download the latest default resources:&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip&lt;br /&gt;
(mtasa-resources-latest.zip is an example. Check http://mirror.mtasa.com/mtasa/resources/ for the latest file name)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Test ===&lt;br /&gt;
You can now test if the server will start correctly, by entering the install directory:&lt;br /&gt;
 cd multitheftauto_linux-{{Current Version|full}}&lt;br /&gt;
&lt;br /&gt;
and launching:&lt;br /&gt;
 ./mta-server&lt;br /&gt;
&lt;br /&gt;
=== Default resources ===&lt;br /&gt;
If you need the default resources:&lt;br /&gt;
Download the latest default resources zip from http://mirror.mtasa.com/mtasa/resources/&lt;br /&gt;
and unzip into '''mods/deathmatch/resources'''&lt;br /&gt;
For example:&lt;br /&gt;
 apt-get install unzip&lt;br /&gt;
 mkdir mods/deathmatch/resources&lt;br /&gt;
 cd mods/deathmatch/resources&lt;br /&gt;
 rm mtasa-resources-latest.zip&lt;br /&gt;
 wget &amp;lt;nowiki&amp;gt;http&amp;lt;/nowiki&amp;gt;://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip&lt;br /&gt;
 unzip mtasa-resources-latest.zip&lt;br /&gt;
 rm mtasa-resources-latest.zip&lt;br /&gt;
&lt;br /&gt;
== Running with 32 or 64 bit Linux==&lt;br /&gt;
=== Make sure your server libraries and stuff are up to date ===&lt;br /&gt;
On Debian/Ubuntu this is done with:&lt;br /&gt;
 apt-get update&lt;br /&gt;
 apt-get upgrade&lt;br /&gt;
&lt;br /&gt;
== Running with 32 bit Linux ==&lt;br /&gt;
===32 bit Troubleshooting===&lt;br /&gt;
* If you get a problem with such as &amp;quot;libreadline.so.5: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 32 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libreadline5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libncursesw.so.5 cannot open shared object file: No such file or directory&amp;quot;, it can be solved on 32 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libncursesw5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libmysqlclient.so.16: cannot open shared object file: No such file or directory&amp;quot;, it can be solved on Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libmysqlclient16&lt;br /&gt;
&lt;br /&gt;
If that fails, download [http://nightly.mtasa.com/files/libmysqlclient.so.16 libmysqlclient.so.16] and put it in '''/usr/lib/'''&lt;br /&gt;
&lt;br /&gt;
== Running with 64 bit Linux ==&lt;br /&gt;
===Debian 7 (wheezy) 64 bit===&lt;br /&gt;
Before running MTASA Server, use this command line for installation of 32 bit libs :&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32ncursesw5 lib32readline5&lt;br /&gt;
&lt;br /&gt;
===Install 32 bit libs for your 64 bit distro===&lt;br /&gt;
For 64 bit Debian 6, this is achieved with:&amp;lt;br/&amp;gt;&lt;br /&gt;
''(Some 64 bit distros have 32 bit libs already installed for you. So this step might not be required)''&lt;br /&gt;
&lt;br /&gt;
 apt-get install ia32-libs&lt;br /&gt;
&lt;br /&gt;
===64 bit Troubleshooting===&lt;br /&gt;
====64 bit Debian/Ubuntu====&lt;br /&gt;
* If you get a problem with such as &amp;quot;libstdc++.so.6: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32stdc++6&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libz.so.1: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32z1&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libreadline.so.5: cannot open shared object file: No such file or directory.&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32readline5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libncursesw.so.5 cannot open shared object file: No such file or directory&amp;quot;, it can be solved on 64 bit Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install lib32ncursesw5&lt;br /&gt;
&lt;br /&gt;
* If you get a problem with such as &amp;quot;libmysqlclient.so.16: cannot open shared object file: No such file or directory&amp;quot;, it can be solved on Debian/Ubuntu by doing this:&lt;br /&gt;
&lt;br /&gt;
 apt-get install libmysqlclient16&lt;br /&gt;
&lt;br /&gt;
** If that fails, download [http://nightly.mtasa.com/files/libmysqlclient.so.16 libmysqlclient.so.16] and put it in '''/usr/lib/'''&lt;br /&gt;
&lt;br /&gt;
**NOTE: If you are running the experimental MTA x64 server, you will need [http://nightly.mtasa.com/files/x64/libmysqlclient.so.16 this file] instead:&lt;br /&gt;
&lt;br /&gt;
====64 bit CentOS 6====&lt;br /&gt;
* If you get a problem with such as &amp;quot;libreadline.so.5: cannot open shared object file: No such file or directory.&amp;quot;, edit '''''/etc/yum.conf''''' and add this line:&lt;br /&gt;
 multilib_policy=all&lt;br /&gt;
Then issue this command:&lt;br /&gt;
 yum install compat-readline5&lt;br /&gt;
* Further 64 bit solutions can be found [http://forum.mtasa.com/viewtopic.php?f=106&amp;amp;t=35328#p367282 on the forums]&lt;br /&gt;
&lt;br /&gt;
== MySQL Troubleshooting==&lt;br /&gt;
* If you are using the inbuild MySQL functions such as [[dbConnect]] and [[dbQuery]], you will need to have '''libmysqlclient.so.16''' installed.&lt;br /&gt;
* If you can't get '''libmysqlclient.so.16''' installed by conventional means, then try [http://nightly.mtasa.com/files/libmysqlclient.so.16 downloading the file from here] and copying it to your Linux server '''/usr/lib/''' directory.&lt;br /&gt;
&lt;br /&gt;
==Cent OS Troubleshooting==&lt;br /&gt;
* If you are using Cent OS and you get something like /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by xmll.so) this can be resolved by doing downloading the archive [[http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/9/Fedora/i386/os/Packages/libstdc++-4.3.0-8.i386.rpm here]] and unpacking it with the following command:&lt;br /&gt;
&lt;br /&gt;
 rpm2cpio libstdc++-4.3.0-8.i386.rpm | cpio -i --make-directories&lt;br /&gt;
&lt;br /&gt;
==[Optional] Installing and Configuring an External Web Server==&lt;br /&gt;
Instructions on how to install and configure Nginx as an external web server for MTA is here: [[Installing and Configuring Nginx as an External Web Server]]&lt;br /&gt;
&lt;br /&gt;
== Server crashes ==&lt;br /&gt;
&lt;br /&gt;
If your Linux server crashes, please obtain a backtrace and post a report on our [http://bugs.mtasa.com/ Bug tracker]&lt;br /&gt;
&lt;br /&gt;
====To obtain a backtrace:====&lt;br /&gt;
===Do you have a core dump file in the the MTA server directory?===&lt;br /&gt;
It's usually called 'core', and usually over 100MB, and looks something like this:&lt;br /&gt;
 [[Image:Core.png]]&lt;br /&gt;
====If you have a core dump file in the the MTA server directory:====&lt;br /&gt;
*Install gdb. To install gdb on Debian, use this command:&lt;br /&gt;
 apt-get install gdb&lt;br /&gt;
*And from the MTA install directory do this command&lt;br /&gt;
 gdb mta-server -c core&lt;br /&gt;
*When gdb launches, do this command to get a  module list:&lt;br /&gt;
 i sh&lt;br /&gt;
*And then this command to get a backtrace:&lt;br /&gt;
 bt&lt;br /&gt;
*Save the output&lt;br /&gt;
*(To exit gdb, use the quit command)&lt;br /&gt;
&lt;br /&gt;
====If you do not have a core dump file in the the MTA server directory:====&lt;br /&gt;
*Install gdb. To install gdb on Debian, use this command:&lt;br /&gt;
 apt-get install gdb&lt;br /&gt;
*And from the MTA server directory start the mta-server like this:&lt;br /&gt;
 gdb mta-server -ex &amp;quot;set print thread-events off&amp;quot; --eval-command run&lt;br /&gt;
*Now wait for a crash. (Ignore any weird screen output in the meantime)&lt;br /&gt;
*When a crash occurs, do this command to get a module list:&lt;br /&gt;
 i sh&lt;br /&gt;
*And then this command to get a backtrace:&lt;br /&gt;
 bt&lt;br /&gt;
*Save the output&lt;br /&gt;
*(To exit gdb, use the quit command)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Server freezes''' ==&lt;br /&gt;
&lt;br /&gt;
If your Linux server freezes, please obtain a backtrace with thread information and post a report on our [http://bugs.mtasa.com/ Bug tracker]&lt;br /&gt;
&lt;br /&gt;
====To obtain a backtrace with thread information:====&lt;br /&gt;
*Install gdb. To install gdb on Debian, use this command:&lt;br /&gt;
 apt-get install gdb&lt;br /&gt;
*And from the MTA server directory start the mta-server like this:&lt;br /&gt;
 gdb mta-server -ex &amp;quot;set print thread-events off&amp;quot; --eval-command run&lt;br /&gt;
*Now wait for a freeze. (Ignore any weird screen output in the meantime)&lt;br /&gt;
*When a freeze occurs, press ctrl-c to start gdb&lt;br /&gt;
*Then do this command to get a module list:&lt;br /&gt;
 i sh&lt;br /&gt;
*And then this command to get a backtrace:&lt;br /&gt;
 bt&lt;br /&gt;
*And then this command to get thread information:&lt;br /&gt;
 info threads&lt;br /&gt;
*Save the output&lt;br /&gt;
*(To exit gdb, use the quit command)&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=FileGetPos&amp;diff=43508</id>
		<title>FileGetPos</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=FileGetPos&amp;diff=43508"/>
		<updated>2014-12-27T08:08:33Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
&lt;br /&gt;
Returns the current read/write position in the given file.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; int fileGetPos ( file theFile, bool readOnly ) &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theFile:''' the file handle you wish to get the position of.&lt;br /&gt;
*'''readOnly:''' is file handled as read only.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the file position if successful, or ''false'' if an error occured (e.g. an invalid handle was passed).&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example opens the file test.txt and outputs its contents and current read position to the console. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local hFile = fileOpen(&amp;quot;test.txt&amp;quot;, true)       -- attempt to open the file (read only)&lt;br /&gt;
if hFile then                                  -- check if it was successfully opened&lt;br /&gt;
    local buffer&lt;br /&gt;
    while not fileIsEOF(hFile) do              -- as long as we're not at the end of the file...&lt;br /&gt;
        buffer = fileRead(hFile, 500)          -- ... read the next 500 bytes...&lt;br /&gt;
        outputConsole(buffer..&amp;quot;Current Position: &amp;quot;..fileGetPos(hFile))                  -- ... and output them to the console and outputs the current read position&lt;br /&gt;
    end&lt;br /&gt;
    fileClose(hFile)                           -- close the file once we're done with it&lt;br /&gt;
else&lt;br /&gt;
    outputConsole(&amp;quot;Unable to open test.txt&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{File functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=FileGetPos&amp;diff=43507</id>
		<title>FileGetPos</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=FileGetPos&amp;diff=43507"/>
		<updated>2014-12-27T08:08:17Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Required Arguments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
&lt;br /&gt;
Returns the current read/write position in the given file.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; int fileGetPos ( file theFile ) &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theFile:''' the file handle you wish to get the position of.&lt;br /&gt;
*'''readOnly:''' is file handled as read only.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the file position if successful, or ''false'' if an error occured (e.g. an invalid handle was passed).&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example opens the file test.txt and outputs its contents and current read position to the console. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local hFile = fileOpen(&amp;quot;test.txt&amp;quot;, true)       -- attempt to open the file (read only)&lt;br /&gt;
if hFile then                                  -- check if it was successfully opened&lt;br /&gt;
    local buffer&lt;br /&gt;
    while not fileIsEOF(hFile) do              -- as long as we're not at the end of the file...&lt;br /&gt;
        buffer = fileRead(hFile, 500)          -- ... read the next 500 bytes...&lt;br /&gt;
        outputConsole(buffer..&amp;quot;Current Position: &amp;quot;..fileGetPos(hFile))                  -- ... and output them to the console and outputs the current read position&lt;br /&gt;
    end&lt;br /&gt;
    fileClose(hFile)                           -- close the file once we're done with it&lt;br /&gt;
else&lt;br /&gt;
    outputConsole(&amp;quot;Unable to open test.txt&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{File functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=FileGetPos&amp;diff=43506</id>
		<title>FileGetPos</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=FileGetPos&amp;diff=43506"/>
		<updated>2014-12-27T08:08:02Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Required Arguments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
&lt;br /&gt;
Returns the current read/write position in the given file.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; int fileGetPos ( file theFile ) &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theFile:''' the file handle you wish to get the position of.&lt;br /&gt;
*'''readOnly:''' ''boolean'' is file handled as read only.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the file position if successful, or ''false'' if an error occured (e.g. an invalid handle was passed).&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example opens the file test.txt and outputs its contents and current read position to the console. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local hFile = fileOpen(&amp;quot;test.txt&amp;quot;, true)       -- attempt to open the file (read only)&lt;br /&gt;
if hFile then                                  -- check if it was successfully opened&lt;br /&gt;
    local buffer&lt;br /&gt;
    while not fileIsEOF(hFile) do              -- as long as we're not at the end of the file...&lt;br /&gt;
        buffer = fileRead(hFile, 500)          -- ... read the next 500 bytes...&lt;br /&gt;
        outputConsole(buffer..&amp;quot;Current Position: &amp;quot;..fileGetPos(hFile))                  -- ... and output them to the console and outputs the current read position&lt;br /&gt;
    end&lt;br /&gt;
    fileClose(hFile)                           -- close the file once we're done with it&lt;br /&gt;
else&lt;br /&gt;
    outputConsole(&amp;quot;Unable to open test.txt&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{File functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=FileGetPos&amp;diff=43505</id>
		<title>FileGetPos</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=FileGetPos&amp;diff=43505"/>
		<updated>2014-12-27T08:07:35Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Required Arguments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
&lt;br /&gt;
Returns the current read/write position in the given file.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; int fileGetPos ( file theFile ) &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theFile:''' the file handle you wish to get the position of.&lt;br /&gt;
*'''readOnly:''' is file handled as read only.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the file position if successful, or ''false'' if an error occured (e.g. an invalid handle was passed).&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example opens the file test.txt and outputs its contents and current read position to the console. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local hFile = fileOpen(&amp;quot;test.txt&amp;quot;, true)       -- attempt to open the file (read only)&lt;br /&gt;
if hFile then                                  -- check if it was successfully opened&lt;br /&gt;
    local buffer&lt;br /&gt;
    while not fileIsEOF(hFile) do              -- as long as we're not at the end of the file...&lt;br /&gt;
        buffer = fileRead(hFile, 500)          -- ... read the next 500 bytes...&lt;br /&gt;
        outputConsole(buffer..&amp;quot;Current Position: &amp;quot;..fileGetPos(hFile))                  -- ... and output them to the console and outputs the current read position&lt;br /&gt;
    end&lt;br /&gt;
    fileClose(hFile)                           -- close the file once we're done with it&lt;br /&gt;
else&lt;br /&gt;
    outputConsole(&amp;quot;Unable to open test.txt&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{File functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementHealth&amp;diff=39489</id>
		<title>GetElementHealth</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementHealth&amp;diff=39489"/>
		<updated>2014-05-07T09:20:58Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function returns the current health for the specified [[element]]. This can be a [[player]], a [[ped]], or a [[vehicle]].&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float getElementHealth ( element theElement )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theElement:''' The [[player]] or [[vehicle]] whose health you want to check.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a float indicating the element's health, or ''false'' if invalid arguments were passed.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Clientside example&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example outputs the health of the player who enters the command 'showhealth', and their vehicle's health.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function showLocalHealth()&lt;br /&gt;
	-- get the player's health and output it&lt;br /&gt;
	local playerHealth = getElementHealth ( getLocalPlayer() )&lt;br /&gt;
	outputChatBox ( &amp;quot;Your health: &amp;quot; .. playerHealth )&lt;br /&gt;
&lt;br /&gt;
	-- get the player's vehicle: if he is in one, output its health as well&lt;br /&gt;
	local playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() )&lt;br /&gt;
	if playerVehicle then&lt;br /&gt;
		local vehicleHealth = getElementHealth ( playerVehicle ) / 10  -- Divide this by 10, as default the denominator is 1000&lt;br /&gt;
		outputChatBox ( &amp;quot;Your vehicle's health: &amp;quot; .. vehicleHealth )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;showhealth&amp;quot;, showLocalHealth )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Element functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User:Noki&amp;diff=39361</id>
		<title>User:Noki</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User:Noki&amp;diff=39361"/>
		<updated>2014-04-14T04:17:12Z</updated>

		<summary type="html">&lt;p&gt;NOki: Created page with &amp;quot;See [https://wiki.multitheftauto.com/wiki/User:NOki User:NOki]&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See [https://wiki.multitheftauto.com/wiki/User:NOki User:NOki]&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetPlayerPing&amp;diff=39360</id>
		<title>GetPlayerPing</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetPlayerPing&amp;diff=39360"/>
		<updated>2014-04-14T02:24:12Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function returns the ping of a specified [[player]]. The ping is the number of milliseconds that data takes to travel from the player's client to the server or vice versa.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;int getPlayerPing ( player thePlayer )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePlayer''': The [[player]] whose ping you want to determine.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the ping as an [[int]], or ''false'' if the player is invalid.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example checks thePlayer's ping, and if it's over 500, kicks him/her.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function kickPing() -- Creates a function called kickPing&lt;br /&gt;
	if (getPlayerPing(thePlayer) &amp;gt;= 500) then -- If thePlayer's ping is over 500&lt;br /&gt;
		kickPlayer(thePlayer, &amp;quot;Ping over 500!&amp;quot;) -- Kick them&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
setTimer(kickPing, 5000, 0) -- Every 5 seconds, the kickPing function is called.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example checks the ping of every player entering the 'ping' command and warns him if it's over 100.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function checkPing()&lt;br /&gt;
        local ping = getPlayerPing(getLocalPlayer())  -- get the ping from the source element (the player who joined)&lt;br /&gt;
        if (ping &amp;gt; 100) then                          -- if it's higher than 100...&lt;br /&gt;
                outputChatBox(&amp;quot;Your ping is pretty high! Please try to lower it if possible.&amp;quot;) -- output a message to the player&lt;br /&gt;
        end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;ping&amp;quot;, checkPing)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Player functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPlayerMoney&amp;diff=39359</id>
		<title>SetPlayerMoney</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPlayerMoney&amp;diff=39359"/>
		<updated>2014-04-14T02:18:50Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
Sets a player's money to a certain value, regardless of current player money. It should be noted that setting negative values does not work and in fact gives the player large amounts of money.&lt;br /&gt;
{{Note|Using this function client side (not recommended) will not change a players money server side.}}&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setPlayerMoney ( player thePlayer, int amount ) &amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePlayer:''' Which player to set the money of.&lt;br /&gt;
*'''amount:''' A whole integer specifying the new amount of money the player will have.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setPlayerMoney ( int amount ) &amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''amount:''' A whole integer specifying the new amount of money the local player will have.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the money was added, or ''false'' if invalid parameters were passed.&lt;br /&gt;
&lt;br /&gt;
==Example==  &lt;br /&gt;
'''Example 1:''' This example sets the player's money to the desired amount when he types &amp;quot;setcash&amp;quot; in console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function setCash(thePlayer, command, amount)       -- when the setcash function is called&lt;br /&gt;
    setPlayerMoney(thePlayer, tonumber(amount))    -- change player's money to the desired amount&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;setcash&amp;quot;, setCash)           -- add a command handler for setcash&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Example 2:''' This sets all players the amount of 1337 money when &amp;quot;leet&amp;quot; is typed in console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function leetmoney()&lt;br /&gt;
	setPlayerMoney(root, 1337)&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;leet&amp;quot;, leetmoney)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Player functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=RenameResource&amp;diff=39358</id>
		<title>RenameResource</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=RenameResource&amp;diff=39358"/>
		<updated>2014-04-14T02:12:51Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function renames a resource.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool renameResource ( string resourceName, string newResourceName, [ string organizationalPath ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''resourceName:''' The name of resource to rename.&lt;br /&gt;
*'''newResourceName:''' The name of what the resource should be renamed to.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''organizationalPath:''' If you want to store the new resource inside a category.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the resource has been renamed successfully, ''false'' otherwise. This could fail if the resource name already is in use, if a directory already exists with the name you've specified (but this isn't a valid resource) or if the name you specify isn't valid. It could also fail if the disk was full or for other similar reasons. Won't work on a started resource or if the resource is not loaded (not known by MTA (use /refresh))&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example renames the resource &amp;quot;reload&amp;quot; to &amp;quot;reload2&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function renameReloadResource()&lt;br /&gt;
	renameResource(&amp;quot;reload&amp;quot;, &amp;quot;reload2&amp;quot;);&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot, renameReloadResource);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.1.1-9.03316|n/a|}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Resource_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=RenameResource&amp;diff=39357</id>
		<title>RenameResource</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=RenameResource&amp;diff=39357"/>
		<updated>2014-04-14T02:12:19Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function renames a resource.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool renameResource ( string resourceName, string newResourceName, [ string organizationalPath ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''resourceName:''' The name of resource to rename.&lt;br /&gt;
*'''newResourceName:''' The name of what the resource should be renamed to.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''organizationalPath:''' If you want to store the new resource inside a category.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the resource has been renamed successfully, ''false'' otherwise. This could fail if the resource name already is in use, if a directory already exists with the name you've specified (but this isn't a valid resource) or if the name you specify isn't valid. It could also fail if the disk was full or for other similar reasons. Won't work on a started resource or if the resource is not loaded (not known by MTA (use /refresh))&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example renames the resource &amp;quot;reload&amp;quot; to &amp;quot;reload2&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function renameReloadResource()&lt;br /&gt;
	renameResource(&amp;quot;reload&amp;quot;, reload2&amp;quot;);&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot, renameReloadResource);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.1.1-9.03316|n/a|}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Resource_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User:NOki&amp;diff=39356</id>
		<title>User:NOki</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User:NOki&amp;diff=39356"/>
		<updated>2014-04-14T02:10:13Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Contributions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NOki, also known as Lewis Watson, is an avid MTA Lua scripter.&lt;br /&gt;
==Contributions==&lt;br /&gt;
&lt;br /&gt;
None as of yet.&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User:NOki&amp;diff=39355</id>
		<title>User:NOki</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User:NOki&amp;diff=39355"/>
		<updated>2014-04-14T02:09:25Z</updated>

		<summary type="html">&lt;p&gt;NOki: Created page with &amp;quot;==Contributions==  None as of yet.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Contributions==&lt;br /&gt;
&lt;br /&gt;
None as of yet.&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetTeamFromName&amp;diff=39344</id>
		<title>GetTeamFromName</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetTeamFromName&amp;diff=39344"/>
		<updated>2014-04-11T07:28:18Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function finds a team object by the team's name.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
team getTeamFromName ( string teamName )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''teamName:''' A string determining the name of the team you wish to find.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the team object if it was found, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example creates a team, and sets the player's team to it's partial name:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Creates a red team&lt;br /&gt;
createTeam(&amp;quot;Red&amp;quot;, 255, 0, 0)&lt;br /&gt;
&lt;br /&gt;
function joinRedTeam (source)&lt;br /&gt;
	if (redteam) then -- If the team was successfully created&lt;br /&gt;
		-- Sets the player's team by getting the partial name of the red team.&lt;br /&gt;
		setPlayerTeam(client, getTeamFromName(&amp;quot;Red&amp;quot;))&lt;br /&gt;
		outputChatBox(&amp;quot;You are now in the 'Red' team&amp;quot;, source)&lt;br /&gt;
	else&lt;br /&gt;
		outputChatBox(&amp;quot;Sorry, we can't set your team. An error occurred!&amp;quot;, source)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--Add console command to join the team when 'joinTeam' is typed.&lt;br /&gt;
addCommandHandler(&amp;quot;jointeam&amp;quot;, joinRedTeam)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Team_functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CenterWindow&amp;diff=39343</id>
		<title>CenterWindow</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CenterWindow&amp;diff=39343"/>
		<updated>2014-04-11T07:23:23Z</updated>

		<summary type="html">&lt;p&gt;NOki: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function center the window in any resolution.&amp;lt;br&amp;gt;&lt;br /&gt;
* '''NOTE:''' This is made to be used clientside!.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;string centerWindow( element TheElement )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theElement''': The element you want to center it.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Clientside script&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function centerWindow (center_window)&lt;br /&gt;
    local screenW, screenH = guiGetScreenSize()&lt;br /&gt;
    local windowW, windowH = guiGetSize(center_window, false)&lt;br /&gt;
    local x, y = (screenW - windowW) /2,(screenH - windowH) /2&lt;br /&gt;
    guiSetPosition(center_window, x, y, false)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example center the window.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler( &amp;quot;onClientResourceStart&amp;quot;, resourceRoot, function()&lt;br /&gt;
  myWindow = guiCreateWindow( 350, 100, 200, 250, &amp;quot;Window Title&amp;quot;, false )&lt;br /&gt;
end )&lt;br /&gt;
&lt;br /&gt;
addCommandHandler( &amp;quot;center&amp;quot;, function()&lt;br /&gt;
  if myWindow then&lt;br /&gt;
    centerWindow( myWindow )&lt;br /&gt;
  end&lt;br /&gt;
end )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Author: laserlaser&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetPlayerFromNamePart&amp;diff=39328</id>
		<title>GetPlayerFromNamePart</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetPlayerFromNamePart&amp;diff=39328"/>
		<updated>2014-04-10T06:26:42Z</updated>

		<summary type="html">&lt;p&gt;NOki: moved GetPlayerFromNamePart to GetPlayerFromPartialName: Grammar needed fixing (heil grammar)!&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[GetPlayerFromPartialName]]&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetPlayerFromPartialName&amp;diff=39327</id>
		<title>GetPlayerFromPartialName</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetPlayerFromPartialName&amp;diff=39327"/>
		<updated>2014-04-10T06:26:42Z</updated>

		<summary type="html">&lt;p&gt;NOki: moved GetPlayerFromNamePart to GetPlayerFromPartialName: Grammar needed fixing (heil grammar)!&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to get player from their partial name.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
player getPlayerFromPartialName ( string Name )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''Name''': A string containing the partial name of a player you want to reference.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a [[player]] if the partial name exists, ''nil'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function getPlayerFromPartialName(name)&lt;br /&gt;
    local name = name and name:gsub(&amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;):lower() or nil&lt;br /&gt;
    if name then&lt;br /&gt;
        for _, player in ipairs(getElementsByType(&amp;quot;player&amp;quot;)) do&lt;br /&gt;
            local name_ = getPlayerName(player):gsub(&amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;):lower()&lt;br /&gt;
            if name_:find(name, 1, true) then&lt;br /&gt;
                return player&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Author: TAPL'''&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetPlayerFromPartialName&amp;diff=39326</id>
		<title>GetPlayerFromPartialName</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetPlayerFromPartialName&amp;diff=39326"/>
		<updated>2014-04-10T06:25:03Z</updated>

		<summary type="html">&lt;p&gt;NOki: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to get player from their partial name.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
player getPlayerFromPartialName ( string Name )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''Name''': A string containing the partial name of a player you want to reference.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a [[player]] if the partial name exists, ''nil'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function getPlayerFromPartialName(name)&lt;br /&gt;
    local name = name and name:gsub(&amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;):lower() or nil&lt;br /&gt;
    if name then&lt;br /&gt;
        for _, player in ipairs(getElementsByType(&amp;quot;player&amp;quot;)) do&lt;br /&gt;
            local name_ = getPlayerName(player):gsub(&amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;):lower()&lt;br /&gt;
            if name_:find(name, 1, true) then&lt;br /&gt;
                return player&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Author: TAPL'''&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>NOki</name></author>
	</entry>
</feed>