<?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=Arezu</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=Arezu"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Arezu"/>
	<updated>2026-05-17T20:43:38Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=44793</id>
		<title>GetElementMatrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=44793"/>
		<updated>2015-03-10T09:55:43Z</updated>

		<summary type="html">&lt;p&gt;Arezu: Why was this text changed? the regular getElementMatrix returns false for objects that are not streamed in.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function gets an [[element]]'s transform [[matrix]]. This contains 16 float values that multiplied to a point will give you the point transformed. It is most useful for matrix calculations such as calculating offsets. For further information, please refer to a tutorial of matrices in computer graphics programming.&lt;br /&gt;
{{Note|The [[matrix]] returned by this function is [http://bugs.mtasa.com/view.php?id{{=}}6984 not setup correctly for some calculations] unless the '''legacy''' argument is set to '''''false'''''.}}&lt;br /&gt;
{{Tip|''For [[matrix]] manipulation which goes beyond the basic examples given on this page, see the [[Lua matrix library]].'' If you are using MTA: SA 1.4 or higher, using the built-in [[matrix]] class is also recommended.}}&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table getElementMatrix ( element theElement [, bool legacy = true ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[element]]:getMatrix|matrix|setElementMatrix}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theElement:''' The [[element]] which you wish to retrieve the [[matrix]] for.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''legacy:''' Set to ''false'' to return correctly setup [[matrix]] (i.e. Last column in the first 3 rows set to zero).&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a multi-dimensional array (which can be transformed into a proper [[matrix]] class using ''Matrix.create'' method) containing a 4x4 matrix. Returns ''false'' if the element is not streamed in, and not a [[vehicle]], [[ped]] or [[object]].&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example creates a utility function that turns an offset into a position that is relative to the specified element.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getPositionFromElementOffset(element,offX,offY,offZ)&lt;br /&gt;
    local m = getElementMatrix ( element )  -- Get the matrix&lt;br /&gt;
    local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  -- Apply transform&lt;br /&gt;
    local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]&lt;br /&gt;
    local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]&lt;br /&gt;
    return x, y, z                               -- Return the transformed point&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 3 units to the right of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,3,0,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 2 units in front of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,2,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 1 unit above the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,0,1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example creates some more matrix utility functions&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getMatrixLeft(m)&lt;br /&gt;
    return m[1][1], m[1][2], m[1][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixForward(m)&lt;br /&gt;
    return m[2][1], m[2][2], m[2][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixUp(m)&lt;br /&gt;
    return m[3][1], m[3][2], m[3][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixPosition(m)&lt;br /&gt;
    return m[4][1], m[4][2], m[4][3]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element)  -- Get the matrix&lt;br /&gt;
x,y,z = getMatrixLeft(mat)     -- Get the matrix left direction&lt;br /&gt;
x,y,z = getMatrixForward(mat)  -- Get the matrix forward direction&lt;br /&gt;
x,y,z = getMatrixUp(mat)       -- Get the matrix up direction&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example function allows you to get the element matrix of an element that is not streamed in.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getElementMatrix(element)&lt;br /&gt;
    local rx, ry, rz = getElementRotation(element, &amp;quot;ZXY&amp;quot;)&lt;br /&gt;
    rx, ry, rz = math.rad(rx), math.rad(ry), math.rad(rz)&lt;br /&gt;
    local matrix = {}&lt;br /&gt;
    matrix[1] = {}&lt;br /&gt;
    matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
    matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
    matrix[1][3] = -math.cos(rx)*math.sin(ry)&lt;br /&gt;
    matrix[1][4] = 1&lt;br /&gt;
    &lt;br /&gt;
    matrix[2] = {}&lt;br /&gt;
    matrix[2][1] = -math.cos(rx)*math.sin(rz)&lt;br /&gt;
    matrix[2][2] = math.cos(rz)*math.cos(rx)&lt;br /&gt;
    matrix[2][3] = math.sin(rx)&lt;br /&gt;
    matrix[2][4] = 1&lt;br /&gt;
	&lt;br /&gt;
    matrix[3] = {}&lt;br /&gt;
    matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx)&lt;br /&gt;
    matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx)&lt;br /&gt;
    matrix[3][3] = math.cos(rx)*math.cos(ry)&lt;br /&gt;
    matrix[3][4] = 1&lt;br /&gt;
	&lt;br /&gt;
    matrix[4] = {}&lt;br /&gt;
    matrix[4][1], matrix[4][2], matrix[4][3] = getElementPosition(element)&lt;br /&gt;
    matrix[4][4] = 1&lt;br /&gt;
	&lt;br /&gt;
    return matrix&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.3.0-9.04186|Added legacy argument}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_element_functions}}&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CreateProjectile&amp;diff=44732</id>
		<title>CreateProjectile</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CreateProjectile&amp;diff=44732"/>
		<updated>2015-02-23T20:02:47Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function creates a projectile of the specified type on the specified coordinates.&lt;br /&gt;
&lt;br /&gt;
{{Note|&lt;br /&gt;
*'''Model''' argument is not synchronized between clients. Clients differs from local player see always standard projectile model.&lt;br /&gt;
*'''Target''' argument can only be defined as a player or another projectile.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
projectile createProjectile ( element creator, int weaponType [, float posX, float posY, float posZ, float force = 1.0, element target = nil, float rotX, float rotY, float rotZ, float velX, float velY, float velZ, int model ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[Projectile]]}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''creator:''' The [[element]] representing creator of the projectile. In case you want the projectile to be synced for everybody creator must be the local player or his vehicle.&lt;br /&gt;
*'''weaponType:''' [[int]] representing the projectile weaponType (characteristics). Valid IDs are:&lt;br /&gt;
{{Projectiles}}&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''posX''', '''posY''', '''posZ''': [[float]] starting coordinates for the projectile. They are coordinates of creator by default.&lt;br /&gt;
*'''force''': [[float]] representing the starting force for throwable projectiles.&lt;br /&gt;
*'''target''': [[element]] target used for heat seeking rockets.&lt;br /&gt;
*'''rotX''', '''rotY''', '''rotZ''': [[float]] starting rotation for the projectile.&lt;br /&gt;
*'''velX''', '''velY''', '''velZ''': [[float]] starting velocity for the projectile.&lt;br /&gt;
*'''model''': Integer representing the projectile's model, uses default model for weaponType if not specified.&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns a ''[[projectile]]'' element if [[projectile]] creation was successful. Returns ''false'' if unable to create a [[projectile]] (wrong weapon ID or projectiles limit was reached).&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example makes a rocket minigun (minigun shooting with rockets).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- This function gets triggered everytime player shoots.&lt;br /&gt;
function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement)&lt;br /&gt;
	if weapon == 38 then -- if source is a local player and he uses minigun...&lt;br /&gt;
                x,y,z = getElementPosition(getLocalPlayer())&lt;br /&gt;
		if not createProjectile(getLocalPlayer(),19,x,y,z,200) then -- then we either create a projectile...&lt;br /&gt;
			outputChatBox ( &amp;quot;Rocket minigun overheated! Give it a rest pal!&amp;quot;, source ) -- or if projectile limit is reached we output player a chat message&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire.&lt;br /&gt;
addEventHandler(&amp;quot;onClientPlayerWeaponFire&amp;quot;, getLocalPlayer(), onClientPlayerWeaponFireFunc)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example code shoots a projectile from your occupied vehicle that travels in the direction your vehicle is facing when you press vehicle_fire (left mouse button with default controls)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function shootProjectile()&lt;br /&gt;
	local vehicle = getPedOccupiedVehicle(localPlayer)&lt;br /&gt;
	-- Only create projectile if we are inside a vehicle&lt;br /&gt;
	if(vehicle)then&lt;br /&gt;
		local x, y, z = getElementPosition(vehicle)&lt;br /&gt;
		createProjectile(vehicle, 19, x, y, z)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
bindKey(&amp;quot;vehicle_fire&amp;quot;, &amp;quot;down&amp;quot;, shootProjectile)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Issues== &lt;br /&gt;
{{Issues|&lt;br /&gt;
{{Issue|8132|Projectile target only allows player element (and a projectile?)}}&lt;br /&gt;
{{Issue|5072|createProjectile creates one projectile for every person in the vehicle}}&lt;br /&gt;
}} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Client projectile functions}}&lt;br /&gt;
&lt;br /&gt;
[[it:createProjectile]]&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Matrix&amp;diff=41654</id>
		<title>Matrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Matrix&amp;diff=41654"/>
		<updated>2014-08-27T17:58:43Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
[[Category:Incomplete]]&lt;br /&gt;
The Matrix class is a class introduced in 1.4&lt;br /&gt;
&lt;br /&gt;
===Metamethods===&lt;br /&gt;
&lt;br /&gt;
*[[Matrix.__tostring|__tostring]]&lt;br /&gt;
*[[Matrix.__gc|__gc]]&lt;br /&gt;
*[[Matrix.__add|__add]]&lt;br /&gt;
*[[Matrix.__sub|__sub]]&lt;br /&gt;
*[[Matrix.__mul|__mul]]&lt;br /&gt;
*[[Matrix.__div|__div]]&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
*[[Matrix.create|create]]&lt;br /&gt;
*[[Matrix.getPosition|getPosition]]&lt;br /&gt;
*[[Matrix.getRotation|getRotation]]&lt;br /&gt;
*[[Matrix.getForward|getForward]]&lt;br /&gt;
*[[Matrix.getRight|getRight]]&lt;br /&gt;
*[[Matrix.getUp|getUp]]&lt;br /&gt;
*[[Matrix.getUp|getUp]]&lt;br /&gt;
*[[Matrix.setPosition|setPosition]]&lt;br /&gt;
*[[Matrix.setForward|setForward]]&lt;br /&gt;
*[[Matrix.setRight|setRight]]&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
*[[Matrix.position|position]]&lt;br /&gt;
*[[Matrix.rotation|rotation]]&lt;br /&gt;
*[[Matrix.forward|forward]]&lt;br /&gt;
*[[Matrix.right|right]]&lt;br /&gt;
*[[Matrix.up|up]]&lt;br /&gt;
&lt;br /&gt;
[[ru:Matrix]]&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Matrix&amp;diff=41652</id>
		<title>Matrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Matrix&amp;diff=41652"/>
		<updated>2014-08-27T17:29:14Z</updated>

		<summary type="html">&lt;p&gt;Arezu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
[[Category:Incomplete]]&lt;br /&gt;
The Matrix class is a class introduced in 1.4&lt;br /&gt;
&lt;br /&gt;
===Metamethods===&lt;br /&gt;
&lt;br /&gt;
*[[Matrix.__tostring|__tostring]]&lt;br /&gt;
*[[Matrix.__gc|__gc]]&lt;br /&gt;
*[[Matrix.__add|__add]]&lt;br /&gt;
*[[Matrix.__sub|__sub]]&lt;br /&gt;
*[[Matrix.__mul|__mul]]&lt;br /&gt;
*[[Matrix.__div|__div]]&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
*[[Matrix.create|create]]&lt;br /&gt;
*[[Matrix.getPosition|getPosition]]&lt;br /&gt;
*[[Matrix.getRotation|getRotation]]&lt;br /&gt;
*[[Matrix.getForward|getForward]]&lt;br /&gt;
*[[Matrix.getRight|getRight]]&lt;br /&gt;
*[[Matrix.getUp|getUp]]&lt;br /&gt;
*[[Matrix.getUp|getUp]]&lt;br /&gt;
*[[Matrix.setPosition|setPosition]]&lt;br /&gt;
*[[Matrix.setForward|setForward]]&lt;br /&gt;
*[[Matrix.setRight|setRight]]&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
*[[Matrix.position|position]]&lt;br /&gt;
*[[Matrix.rotation|rotation]]&lt;br /&gt;
*[[Matrix.front|front]]&lt;br /&gt;
*[[Matrix.right|right]]&lt;br /&gt;
*[[Matrix.up|up]]&lt;br /&gt;
&lt;br /&gt;
[[ru:Matrix]]&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=41651</id>
		<title>GetElementMatrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=41651"/>
		<updated>2014-08-27T16:59:38Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function gets an element's transform matrix. This contains 16 float values that multiplied to a point will give you the point transformed. It is most useful for matrix calculations such as calculating offsets. For further information, please refer to a tutorial of matrices in computer graphics programming.&lt;br /&gt;
{{Note|The matrix returned by this function is [http://bugs.mtasa.com/view.php?id{{=}}6984 not setup correctly for some calculations.] unless the '''legacy''' argument is set to '''false'''}}&lt;br /&gt;
{{Tip|''For matrix manipulation which goes beyond the basic examples given on this page, see the [[Lua matrix library]].''}}&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table getElementMatrix ( element theElement [, bool legacy = true ] )       &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theElement:''' The element which you wish to retrieve the matrix for&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''legacy :''' Set to false to return correctly setup matrix. (i.e. Last column in the first 3 rows set to zero.)&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a multi-dimensional array containing a 4x4 matrix. Returns false if the element is not streamed in, and not a vehicle or ped.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example creates a utility function that turns an offset into a position that is relative to the specified element.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getPositionFromElementOffset(element,offX,offY,offZ)&lt;br /&gt;
	local m = getElementMatrix ( element )  -- Get the matrix&lt;br /&gt;
	local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  -- Apply transform&lt;br /&gt;
	local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]&lt;br /&gt;
	local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]&lt;br /&gt;
	return x, y, z                               -- Return the transformed point&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 3 units to the left of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,3,0,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 2 units in front of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,2,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 1 unit above the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,0,1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example creates some more matrix utility functions&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getMatrixLeft(m)&lt;br /&gt;
        return m[1][1], m[1][2], m[1][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixForward(m)&lt;br /&gt;
        return m[2][1], m[2][2], m[2][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixUp(m)&lt;br /&gt;
        return m[3][1], m[3][2], m[3][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixPosition(m)&lt;br /&gt;
        return m[4][1], m[4][2], m[4][3]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element)  -- Get the matrix&lt;br /&gt;
x,y,z = getMatrixLeft(mat)     -- Get the matrix left direction&lt;br /&gt;
x,y,z = getMatrixForward(mat)  -- Get the matrix forward direction&lt;br /&gt;
x,y,z = getMatrixUp(mat)       -- Get the matrix up direction&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example function shows you what getElementMatrix does internally &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getElementMatrix(element)&lt;br /&gt;
	local rx, ry, rz = getElementRotation(element, &amp;quot;ZXY&amp;quot;)&lt;br /&gt;
	rx, ry, rz = math.rad(rx), math.rad(ry), math.rad(rz)&lt;br /&gt;
	local matrix = {}&lt;br /&gt;
	matrix[1] = {}&lt;br /&gt;
	matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][3] = -math.cos(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][4] = 1&lt;br /&gt;
	&lt;br /&gt;
	matrix[2] = {}&lt;br /&gt;
	matrix[2][1] = -math.cos(rx)*math.sin(rz)&lt;br /&gt;
	matrix[2][2] = math.cos(rz)*math.cos(rx)&lt;br /&gt;
	matrix[2][3] = math.sin(rx)&lt;br /&gt;
	matrix[2][4] = 1&lt;br /&gt;
	&lt;br /&gt;
	matrix[3] = {}&lt;br /&gt;
	matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx)&lt;br /&gt;
	matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx)&lt;br /&gt;
	matrix[3][3] = math.cos(rx)*math.cos(ry)&lt;br /&gt;
	matrix[3][4] = 1&lt;br /&gt;
	&lt;br /&gt;
	matrix[4] = {}&lt;br /&gt;
	matrix[4][1], matrix[4][2], matrix[4][3] = getElementPosition(element)&lt;br /&gt;
	matrix[4][4] = 1&lt;br /&gt;
	&lt;br /&gt;
	return matrix&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.3.0-9.04186|Added legacy argument}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_element_functions}}&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetCameraTarget&amp;diff=36685</id>
		<title>SetCameraTarget</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetCameraTarget&amp;diff=36685"/>
		<updated>2013-07-15T12:26:13Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Note|The function already places camera behind the player. No second call or a timer is needed.&lt;br /&gt;
{{Needs Checking|No it doesn't. A timer of no less than 112 ms was required for the rotation to be set.}}}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function allows you to set a player's camera to follow other elements instead. Currently supported element type is:&lt;br /&gt;
*[[Player]]s&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 setCameraTarget ( player thePlayer [, element target = nil ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePlayer:''' The player whose camera you wish to modify.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''target:''' The element that you want the camera to follow. If none is specified, the camera will target the player.&lt;br /&gt;
'''Note:''' setCameraTarget will behave strangely if the target you want the camera to follow is inside a vehicle that has hydraulics (upgrade id: 1087) added server sided and if the target is not you.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client 1&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 setCameraTarget ( element target )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''target:''' The element that you want the local camera to follow.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{New feature/item|4.0132|1.3.1|5212|&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client 2&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 setCameraTarget ( float targetX, float targetY, float targetZ )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''targetX, targetY, targetZ:''' The target position that you want the local camera to look at.&lt;br /&gt;
&amp;lt;/section&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the function was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This is an example of how one could implement a spectator function. Using the left and right arrow keys you can view other players. Note that this code isn't complete as it doesn't take into account joining or quitting players.&lt;br /&gt;
&amp;lt;section class=&amp;quot;client&amp;quot; name=&amp;quot;Client script&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;
g_Players = getElementsByType(&amp;quot;player&amp;quot;)        -- get a list of all players in the server&lt;br /&gt;
for i,aPlayer in ipairs(g_Players) do          -- find out what index the local player has in the list&lt;br /&gt;
    if aPlayer == getLocalPlayer() then&lt;br /&gt;
        g_CurrentSpectated = i&lt;br /&gt;
        break&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function spectatePrevious()                    -- decrement the spectate index and spectate the corresponding player&lt;br /&gt;
     if g_CurrentSpectated == 1 then&lt;br /&gt;
         g_CurrentSpectated = #g_Players&lt;br /&gt;
     else&lt;br /&gt;
         g_CurrentSpectated = g_CurrentSpectated - 1&lt;br /&gt;
     end&lt;br /&gt;
    setCameraTarget(g_Players[g_CurrentSpectated])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function spectateNext()                        -- increment the spectate index and spectate the corresponding player&lt;br /&gt;
     if g_CurrentSpectated == #g_Players then&lt;br /&gt;
         g_CurrentSpectated = 1&lt;br /&gt;
     else&lt;br /&gt;
         g_CurrentSpectated = g_CurrentSpectated + 1&lt;br /&gt;
     end&lt;br /&gt;
    setCameraTarget(g_Players[g_CurrentSpectated])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Bind above functions to arrow keys&lt;br /&gt;
bindKey(&amp;quot;arrow_l&amp;quot;, &amp;quot;down&amp;quot;, spectatePrevious)&lt;br /&gt;
bindKey(&amp;quot;arrow_r&amp;quot;, &amp;quot;down&amp;quot;, spectateNext)&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;
{{Camera functions}}&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=AddVehicleUpgrade&amp;diff=36684</id>
		<title>AddVehicleUpgrade</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=AddVehicleUpgrade&amp;diff=36684"/>
		<updated>2013-07-15T12:22:26Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Required Arguments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function adds an upgrade to an existing vehicle, eg: nos, hyrdraulics.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool addVehicleUpgrade ( vehicle theVehicle, int upgrade )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theVehicle''': The [[element]] representing the [[vehicle]] you wish to add the upgrade to.&lt;br /&gt;
*'''upgrade''': The id of the upgrade you wish to add. (1000 to 1193), ''see [[Vehicle Upgrades]]''&lt;br /&gt;
'''Note:''' setCameraTarget will behave strangely if you use hydraulics (upgrade id: 1087) server sided and when your camera target is the player inside the vehicle with hydraulics and if the player is not you.&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns ''true'' if the upgrade was successfully added to the vehicle, otherwise ''false''.&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 serverside function allows the user to get an upgrade by typing a command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- define the handler function for our command&lt;br /&gt;
function consoleAddUpgrade ( thePlayer, commandName, id )&lt;br /&gt;
        -- make sure the player is in a vehicle&lt;br /&gt;
        if ( isPedInVehicle ( thePlayer ) ) then&lt;br /&gt;
            -- convert the given ID from a string to a number&lt;br /&gt;
            local id = tonumber ( id )&lt;br /&gt;
            -- get the player's vehicle&lt;br /&gt;
            local theVehicle = getPedOccupiedVehicle ( thePlayer )&lt;br /&gt;
            -- add the requested upgrade to the vehicle&lt;br /&gt;
            local success = addVehicleUpgrade ( theVehicle, id )&lt;br /&gt;
            -- inform the player of whether the upgrade was added successfully&lt;br /&gt;
            if ( success ) then&lt;br /&gt;
                outputConsole ( getVehicleUpgradeSlotName ( id ) .. &amp;quot; upgrade added.&amp;quot;, thePlayer )&lt;br /&gt;
            else&lt;br /&gt;
                outputConsole ( &amp;quot;Failed to add upgrade.&amp;quot;, thePlayer )&lt;br /&gt;
            end&lt;br /&gt;
        else&lt;br /&gt;
            outputConsole ( &amp;quot;You must be in a vehicle!&amp;quot;, thePlayer )&lt;br /&gt;
        end&lt;br /&gt;
end&lt;br /&gt;
-- add the function as a handler for the &amp;quot;addupgrade&amp;quot; command&lt;br /&gt;
addCommandHandler ( &amp;quot;addupgrade&amp;quot;, consoleAddUpgrade )&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;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This client-side script gives vehicles a nitro upgrade whenever they pass through a certain collision shape:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- create a collision shape&lt;br /&gt;
local nitroColShape = createColSphere ( 1337, 100, 12, 2 )&lt;br /&gt;
&lt;br /&gt;
-- attach the collision shape to an 'onClientColShapeHit' event&lt;br /&gt;
function onNitroColShapeHit ( hitElement, matchingDimension )&lt;br /&gt;
    if ( getElementType ( hitElement ) == &amp;quot;vehicle&amp;quot; ) then&lt;br /&gt;
        -- add a nitro upgrade if the element that hit the colshape is a vehicle&lt;br /&gt;
        addVehicleUpgrade ( hitElement, 1010 )&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onClientColShapeHit&amp;quot;, nitroColShape, onNitroColShapeHit )&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>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=AddVehicleUpgrade&amp;diff=36683</id>
		<title>AddVehicleUpgrade</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=AddVehicleUpgrade&amp;diff=36683"/>
		<updated>2013-07-15T12:21:49Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Required Arguments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function adds an upgrade to an existing vehicle, eg: nos, hyrdraulics.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool addVehicleUpgrade ( vehicle theVehicle, int upgrade )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theVehicle''': The [[element]] representing the [[vehicle]] you wish to add the upgrade to.&lt;br /&gt;
*'''upgrade''': The id of the upgrade you wish to add. (1000 to 1193), ''see [[Vehicle Upgrades]]''&lt;br /&gt;
'''Note:''' setCameraTarget will behave strangely if you use hydraulics (upgrade id: 1087) server sided and when your camera target is the player inside the vehicle with hydraulics and the player is not you.&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns ''true'' if the upgrade was successfully added to the vehicle, otherwise ''false''.&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 serverside function allows the user to get an upgrade by typing a command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- define the handler function for our command&lt;br /&gt;
function consoleAddUpgrade ( thePlayer, commandName, id )&lt;br /&gt;
        -- make sure the player is in a vehicle&lt;br /&gt;
        if ( isPedInVehicle ( thePlayer ) ) then&lt;br /&gt;
            -- convert the given ID from a string to a number&lt;br /&gt;
            local id = tonumber ( id )&lt;br /&gt;
            -- get the player's vehicle&lt;br /&gt;
            local theVehicle = getPedOccupiedVehicle ( thePlayer )&lt;br /&gt;
            -- add the requested upgrade to the vehicle&lt;br /&gt;
            local success = addVehicleUpgrade ( theVehicle, id )&lt;br /&gt;
            -- inform the player of whether the upgrade was added successfully&lt;br /&gt;
            if ( success ) then&lt;br /&gt;
                outputConsole ( getVehicleUpgradeSlotName ( id ) .. &amp;quot; upgrade added.&amp;quot;, thePlayer )&lt;br /&gt;
            else&lt;br /&gt;
                outputConsole ( &amp;quot;Failed to add upgrade.&amp;quot;, thePlayer )&lt;br /&gt;
            end&lt;br /&gt;
        else&lt;br /&gt;
            outputConsole ( &amp;quot;You must be in a vehicle!&amp;quot;, thePlayer )&lt;br /&gt;
        end&lt;br /&gt;
end&lt;br /&gt;
-- add the function as a handler for the &amp;quot;addupgrade&amp;quot; command&lt;br /&gt;
addCommandHandler ( &amp;quot;addupgrade&amp;quot;, consoleAddUpgrade )&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;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This client-side script gives vehicles a nitro upgrade whenever they pass through a certain collision shape:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- create a collision shape&lt;br /&gt;
local nitroColShape = createColSphere ( 1337, 100, 12, 2 )&lt;br /&gt;
&lt;br /&gt;
-- attach the collision shape to an 'onClientColShapeHit' event&lt;br /&gt;
function onNitroColShapeHit ( hitElement, matchingDimension )&lt;br /&gt;
    if ( getElementType ( hitElement ) == &amp;quot;vehicle&amp;quot; ) then&lt;br /&gt;
        -- add a nitro upgrade if the element that hit the colshape is a vehicle&lt;br /&gt;
        addVehicleUpgrade ( hitElement, 1010 )&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onClientColShapeHit&amp;quot;, nitroColShape, onNitroColShapeHit )&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>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36682</id>
		<title>SetElementDimension</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36682"/>
		<updated>2013-07-15T12:16:09Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Returns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the [[dimension]] of any element. The dimension determines what/who the element is visible to.&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 setElementDimension ( element theElement, int dimension )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theElement:''' The element in which you'd like to set the dimension of.&lt;br /&gt;
*'''dimension:''' An integer representing the dimension ID&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if '''theElement''' and '''dimension''' are valid, ''false'' otherwise.&lt;br /&gt;
Also returns false if '''theElement''' is a player and it's not alive.&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;
In this example the player's dimension is set to ID 1 when they enter a vehicle, and set back to dimension 0 when they exit the 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;
      if ( getElementDimension ( source ) == 0 ) then    -- if the player is in dimension 0&lt;br /&gt;
            setElementDimension ( source, 1 )            -- set his dimension to 1&lt;br /&gt;
            setElementDimension ( theVehicle, 1 )        -- set his vehicle's dimension to 1 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement ( ), onPlayerEnterVehicle )&lt;br /&gt;
&lt;br /&gt;
function onPlayerExitVehicle ( theVehicle, seat, jacker )&lt;br /&gt;
      if ( getElementDimension ( source ) == 1 ) then    -- if the player is in dimension 1&lt;br /&gt;
            setElementDimension ( source, 0 )            -- set his dimension back to 0&lt;br /&gt;
            setElementDimension ( theVehicle, 0 )        -- set his vehicle's dimension back to 0 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleExit&amp;quot;, getRootElement ( ), onPlayerExitVehicle )&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;br /&gt;
&lt;br /&gt;
[[de:setElementDimension]]&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36681</id>
		<title>SetElementDimension</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36681"/>
		<updated>2013-07-15T12:14:46Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Returns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the [[dimension]] of any element. The dimension determines what/who the element is visible to.&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 setElementDimension ( element theElement, int dimension )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theElement:''' The element in which you'd like to set the dimension of.&lt;br /&gt;
*'''dimension:''' An integer representing the dimension ID&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if '''theElement''' and '''dimension''' are valid, ''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;
In this example the player's dimension is set to ID 1 when they enter a vehicle, and set back to dimension 0 when they exit the 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;
      if ( getElementDimension ( source ) == 0 ) then    -- if the player is in dimension 0&lt;br /&gt;
            setElementDimension ( source, 1 )            -- set his dimension to 1&lt;br /&gt;
            setElementDimension ( theVehicle, 1 )        -- set his vehicle's dimension to 1 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement ( ), onPlayerEnterVehicle )&lt;br /&gt;
&lt;br /&gt;
function onPlayerExitVehicle ( theVehicle, seat, jacker )&lt;br /&gt;
      if ( getElementDimension ( source ) == 1 ) then    -- if the player is in dimension 1&lt;br /&gt;
            setElementDimension ( source, 0 )            -- set his dimension back to 0&lt;br /&gt;
            setElementDimension ( theVehicle, 0 )        -- set his vehicle's dimension back to 0 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleExit&amp;quot;, getRootElement ( ), onPlayerExitVehicle )&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;br /&gt;
&lt;br /&gt;
[[de:setElementDimension]]&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36680</id>
		<title>SetElementDimension</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36680"/>
		<updated>2013-07-15T12:14:23Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Returns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the [[dimension]] of any element. The dimension determines what/who the element is visible to.&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 setElementDimension ( element theElement, int dimension )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theElement:''' The element in which you'd like to set the dimension of.&lt;br /&gt;
*'''dimension:''' An integer representing the dimension ID&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if '''theElement''' and '''dimension''' are valid, and if '''theElement''' is a player, then it has to be alive, ''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;
In this example the player's dimension is set to ID 1 when they enter a vehicle, and set back to dimension 0 when they exit the 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;
      if ( getElementDimension ( source ) == 0 ) then    -- if the player is in dimension 0&lt;br /&gt;
            setElementDimension ( source, 1 )            -- set his dimension to 1&lt;br /&gt;
            setElementDimension ( theVehicle, 1 )        -- set his vehicle's dimension to 1 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement ( ), onPlayerEnterVehicle )&lt;br /&gt;
&lt;br /&gt;
function onPlayerExitVehicle ( theVehicle, seat, jacker )&lt;br /&gt;
      if ( getElementDimension ( source ) == 1 ) then    -- if the player is in dimension 1&lt;br /&gt;
            setElementDimension ( source, 0 )            -- set his dimension back to 0&lt;br /&gt;
            setElementDimension ( theVehicle, 0 )        -- set his vehicle's dimension back to 0 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleExit&amp;quot;, getRootElement ( ), onPlayerExitVehicle )&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;br /&gt;
&lt;br /&gt;
[[de:setElementDimension]]&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36679</id>
		<title>SetElementDimension</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36679"/>
		<updated>2013-07-15T12:13:37Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Returns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the [[dimension]] of any element. The dimension determines what/who the element is visible to.&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 setElementDimension ( element theElement, int dimension )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theElement:''' The element in which you'd like to set the dimension of.&lt;br /&gt;
*'''dimension:''' An integer representing the dimension ID&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if '''theElement''' and '''dimension''' are valid, and if '''theElement''' is a player and is alive, ''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;
In this example the player's dimension is set to ID 1 when they enter a vehicle, and set back to dimension 0 when they exit the 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;
      if ( getElementDimension ( source ) == 0 ) then    -- if the player is in dimension 0&lt;br /&gt;
            setElementDimension ( source, 1 )            -- set his dimension to 1&lt;br /&gt;
            setElementDimension ( theVehicle, 1 )        -- set his vehicle's dimension to 1 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement ( ), onPlayerEnterVehicle )&lt;br /&gt;
&lt;br /&gt;
function onPlayerExitVehicle ( theVehicle, seat, jacker )&lt;br /&gt;
      if ( getElementDimension ( source ) == 1 ) then    -- if the player is in dimension 1&lt;br /&gt;
            setElementDimension ( source, 0 )            -- set his dimension back to 0&lt;br /&gt;
            setElementDimension ( theVehicle, 0 )        -- set his vehicle's dimension back to 0 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleExit&amp;quot;, getRootElement ( ), onPlayerExitVehicle )&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;br /&gt;
&lt;br /&gt;
[[de:setElementDimension]]&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36678</id>
		<title>SetElementDimension</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36678"/>
		<updated>2013-07-15T12:09:33Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Returns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the [[dimension]] of any element. The dimension determines what/who the element is visible to.&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 setElementDimension ( element theElement, int dimension )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theElement:''' The element in which you'd like to set the dimension of.&lt;br /&gt;
*'''dimension:''' An integer representing the dimension ID&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if '''theElement''' and '''dimension''' are valid, ''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;
In this example the player's dimension is set to ID 1 when they enter a vehicle, and set back to dimension 0 when they exit the 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;
      if ( getElementDimension ( source ) == 0 ) then    -- if the player is in dimension 0&lt;br /&gt;
            setElementDimension ( source, 1 )            -- set his dimension to 1&lt;br /&gt;
            setElementDimension ( theVehicle, 1 )        -- set his vehicle's dimension to 1 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement ( ), onPlayerEnterVehicle )&lt;br /&gt;
&lt;br /&gt;
function onPlayerExitVehicle ( theVehicle, seat, jacker )&lt;br /&gt;
      if ( getElementDimension ( source ) == 1 ) then    -- if the player is in dimension 1&lt;br /&gt;
            setElementDimension ( source, 0 )            -- set his dimension back to 0&lt;br /&gt;
            setElementDimension ( theVehicle, 0 )        -- set his vehicle's dimension back to 0 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleExit&amp;quot;, getRootElement ( ), onPlayerExitVehicle )&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;br /&gt;
&lt;br /&gt;
[[de:setElementDimension]]&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36677</id>
		<title>SetElementDimension</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36677"/>
		<updated>2013-07-15T12:09:06Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Returns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the [[dimension]] of any element. The dimension determines what/who the element is visible to.&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 setElementDimension ( element theElement, int dimension )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theElement:''' The element in which you'd like to set the dimension of.&lt;br /&gt;
*'''dimension:''' An integer representing the dimension ID&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if '''theElement''' and '''dimension''' are valid, ''false'' otherwise.&amp;lt;/br&amp;gt;&lt;br /&gt;
'''Note:''' If '''theElement''' is a player, then it has to be alive to be able to change its dimension.&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;
In this example the player's dimension is set to ID 1 when they enter a vehicle, and set back to dimension 0 when they exit the 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;
      if ( getElementDimension ( source ) == 0 ) then    -- if the player is in dimension 0&lt;br /&gt;
            setElementDimension ( source, 1 )            -- set his dimension to 1&lt;br /&gt;
            setElementDimension ( theVehicle, 1 )        -- set his vehicle's dimension to 1 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement ( ), onPlayerEnterVehicle )&lt;br /&gt;
&lt;br /&gt;
function onPlayerExitVehicle ( theVehicle, seat, jacker )&lt;br /&gt;
      if ( getElementDimension ( source ) == 1 ) then    -- if the player is in dimension 1&lt;br /&gt;
            setElementDimension ( source, 0 )            -- set his dimension back to 0&lt;br /&gt;
            setElementDimension ( theVehicle, 0 )        -- set his vehicle's dimension back to 0 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleExit&amp;quot;, getRootElement ( ), onPlayerExitVehicle )&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;br /&gt;
&lt;br /&gt;
[[de:setElementDimension]]&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36676</id>
		<title>SetElementDimension</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetElementDimension&amp;diff=36676"/>
		<updated>2013-07-15T12:08:31Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Returns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the [[dimension]] of any element. The dimension determines what/who the element is visible to.&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 setElementDimension ( element theElement, int dimension )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theElement:''' The element in which you'd like to set the dimension of.&lt;br /&gt;
*'''dimension:''' An integer representing the dimension ID&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if '''theElement''' and '''dimension''' are valid, ''false'' otherwise.&lt;br /&gt;
'''Note:''' If '''theElement''' is a player, then it has to be alive to be able to change its dimension.&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;
In this example the player's dimension is set to ID 1 when they enter a vehicle, and set back to dimension 0 when they exit the 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;
      if ( getElementDimension ( source ) == 0 ) then    -- if the player is in dimension 0&lt;br /&gt;
            setElementDimension ( source, 1 )            -- set his dimension to 1&lt;br /&gt;
            setElementDimension ( theVehicle, 1 )        -- set his vehicle's dimension to 1 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement ( ), onPlayerEnterVehicle )&lt;br /&gt;
&lt;br /&gt;
function onPlayerExitVehicle ( theVehicle, seat, jacker )&lt;br /&gt;
      if ( getElementDimension ( source ) == 1 ) then    -- if the player is in dimension 1&lt;br /&gt;
            setElementDimension ( source, 0 )            -- set his dimension back to 0&lt;br /&gt;
            setElementDimension ( theVehicle, 0 )        -- set his vehicle's dimension back to 0 as well&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleExit&amp;quot;, getRootElement ( ), onPlayerExitVehicle )&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;br /&gt;
&lt;br /&gt;
[[de:setElementDimension]]&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CreateProjectile&amp;diff=36597</id>
		<title>CreateProjectile</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CreateProjectile&amp;diff=36597"/>
		<updated>2013-07-10T17:01:05Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Required Arguments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function creates a projectile of the specified type on the specified coordinates.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
projectile createProjectile ( element creator, int weaponType [, float posX, float posY, float posZ, float force = 1.0, element target = nil, float rotX, float rotY, float rotZ, float velX, float velY, float velZ, int model ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''creator:''' The [[element]] representing creator of the projectile. In case you want the projectile to be synced for everybody creator must be the local player or his vehicle.&lt;br /&gt;
*'''weaponType:''' [[int]] representing the projectile weaponType (characteristics). Valid IDs are:&lt;br /&gt;
{{Projectiles}}&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''posX''','''posY''','''posZ''': [[float]] starting coordinates for the projectile. They are coordinates of creator by default.&lt;br /&gt;
*'''force''': [[float]] representing the starting force of the projectile.&lt;br /&gt;
*'''target''': [[element]] target used for heat seeking rockets.&lt;br /&gt;
*'''rotX''','''rotY''','''rotZ''': [[float]] starting rotation for the projectile.&lt;br /&gt;
*'''velX''','''velY''','''velZ''': [[float]] starting velocity for the projectile.&lt;br /&gt;
*'''model''': Integer representing the projectile's model, uses default model for weaponType if not specified.&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns a ''[[projectile]]'' element if [[projectile]] creation was succesfull. Returns ''false'' if unable to create a [[projectile]] (wrong weapon ID or projectiles limit was reached).&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example makes a rocket minigun (minigun shooting with rockets).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- This function gets triggered everytime player shoots.&lt;br /&gt;
function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement)&lt;br /&gt;
	if weapon == 38 then -- if source is a local player and he uses minigun...&lt;br /&gt;
                x,y,z = getElementPosition(getLocalPlayer())&lt;br /&gt;
		if not createProjectile(getLocalPlayer(),19,x,y,z,200) then -- then we either create a projectile...&lt;br /&gt;
			outputChatBox ( &amp;quot;Rocket minigun overheated! Give it a rest pal!&amp;quot;, source ) -- or if projectile limit is reached we output player a chat message&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire.&lt;br /&gt;
addEventHandler(&amp;quot;onClientPlayerWeaponFire&amp;quot;, getLocalPlayer(), onClientPlayerWeaponFireFunc)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Client projectile functions}}&lt;br /&gt;
&lt;br /&gt;
[[it:createProjectile]]&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=36594</id>
		<title>GetElementMatrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=36594"/>
		<updated>2013-07-10T12:31:03Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function gets an element's transform matrix. This contains 16 float values that multiplied to a point will give you the point transformed. It is most useful for matrix calculations such as calculating offsets. For further information, please refer to a tutorial of matrices in computer graphics programming.&lt;br /&gt;
{{Note|The matrix returned by this function is [http://bugs.mtasa.com/view.php?id{{=}}6984 not setup correctly for some calculations.] unless the '''legacy''' argument is set to '''false'''}}&lt;br /&gt;
{{Tip|''For matrix manipulation which goes beyond the basic examples given on this page, see the [[Lua matrix library]].''}}&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table getElementMatrix ( element theElement [, bool legacy = true ] )       &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theElement:''' The element which you wish to retrieve the matrix for&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''legacy :''' Set to false to return correctly setup matrix. (i.e. Last column in the first 3 rows set to zero.)&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a multi-dimensional array containing a 4x4 matrix. Returns false if the element is not streamed in, and not a vehicle or ped.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example creates a utility function that turns an offset into a position that is relative to the specified element.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getPositionFromElementOffset(element,offX,offY,offZ)&lt;br /&gt;
	local m = getElementMatrix ( element )  -- Get the matrix&lt;br /&gt;
	local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  -- Apply transform&lt;br /&gt;
	local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]&lt;br /&gt;
	local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]&lt;br /&gt;
	return x, y, z                               -- Return the transformed point&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 3 units to the left of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,3,0,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 2 units in front of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,2,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 1 unit above the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,0,1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example creates some more matrix utility functions&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getMatrixLeft(m)&lt;br /&gt;
        return m[1][1], m[1][2], m[1][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixForward(m)&lt;br /&gt;
        return m[2][1], m[2][2], m[2][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixUp(m)&lt;br /&gt;
        return m[3][1], m[3][2], m[3][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixPosition(m)&lt;br /&gt;
        return m[4][1], m[4][2], m[4][3]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element)  -- Get the matrix&lt;br /&gt;
x,y,z = getMatrixLeft(mat)     -- Get the matrix left direction&lt;br /&gt;
x,y,z = getMatrixForward(mat)  -- Get the matrix forward direction&lt;br /&gt;
x,y,z = getMatrixUp(mat)       -- Get the matrix up direction&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example function allows you to get the element matrix of an element that is outside your stream range.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Override normal getElementMatrix with our own version&lt;br /&gt;
function getElementMatrix(element)&lt;br /&gt;
	local rx, ry, rz = getElementRotation(element, &amp;quot;ZXY&amp;quot;)&lt;br /&gt;
	rx, ry, rz = math.rad(rx), math.rad(ry), math.rad(rz)&lt;br /&gt;
	local matrix = {}&lt;br /&gt;
	matrix[1] = {}&lt;br /&gt;
	matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][3] = -math.cos(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][4] = 1&lt;br /&gt;
	&lt;br /&gt;
	matrix[2] = {}&lt;br /&gt;
	matrix[2][1] = -math.cos(rx)*math.sin(rz)&lt;br /&gt;
	matrix[2][2] = math.cos(rz)*math.cos(rx)&lt;br /&gt;
	matrix[2][3] = math.sin(rx)&lt;br /&gt;
	matrix[2][4] = 1&lt;br /&gt;
	&lt;br /&gt;
	matrix[3] = {}&lt;br /&gt;
	matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx)&lt;br /&gt;
	matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx)&lt;br /&gt;
	matrix[3][3] = math.cos(rx)*math.cos(ry)&lt;br /&gt;
	matrix[3][4] = 1&lt;br /&gt;
	&lt;br /&gt;
	matrix[4] = {}&lt;br /&gt;
	matrix[4][1], matrix[4][2], matrix[4][3] = getElementPosition(element) -- this is kinda useless but is used to have the same structure as getElementMatrix&lt;br /&gt;
	matrix[4][4] = 1&lt;br /&gt;
	&lt;br /&gt;
	return matrix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element) -- this gives the same result as normal getElementMatrix(element), except that it also works if the element is not streamed in&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.3.0-9.04186|Added legacy argument}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_element_functions}}&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=36593</id>
		<title>GetElementMatrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=36593"/>
		<updated>2013-07-10T12:26:03Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function gets an element's transform matrix. This contains 16 float values that multiplied to a point will give you the point transformed. It is most useful for matrix calculations such as calculating offsets. For further information, please refer to a tutorial of matrices in computer graphics programming.&lt;br /&gt;
{{Note|The matrix returned by this function is [http://bugs.mtasa.com/view.php?id{{=}}6984 not setup correctly for some calculations.] unless the '''legacy''' argument is set to '''false'''}}&lt;br /&gt;
{{Tip|''For matrix manipulation which goes beyond the basic examples given on this page, see the [[Lua matrix library]].''}}&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table getElementMatrix ( element theElement [, bool legacy = true ] )       &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theElement:''' The element which you wish to retrieve the matrix for&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''legacy :''' Set to false to return correctly setup matrix. (i.e. Last column in the first 3 rows set to zero.)&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a multi-dimensional array containing a 4x4 matrix. Returns false if the element is not streamed in, and not a vehicle or ped.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example creates a utility function that turns an offset into a position that is relative to the specified element.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getPositionFromElementOffset(element,offX,offY,offZ)&lt;br /&gt;
	local m = getElementMatrix ( element )  -- Get the matrix&lt;br /&gt;
	local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  -- Apply transform&lt;br /&gt;
	local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]&lt;br /&gt;
	local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]&lt;br /&gt;
	return x, y, z                               -- Return the transformed point&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 3 units to the left of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,3,0,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 2 units in front of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,2,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 1 unit above the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,0,1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example creates some more matrix utility functions&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getMatrixLeft(m)&lt;br /&gt;
        return m[1][1], m[1][2], m[1][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixForward(m)&lt;br /&gt;
        return m[2][1], m[2][2], m[2][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixUp(m)&lt;br /&gt;
        return m[3][1], m[3][2], m[3][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixPosition(m)&lt;br /&gt;
        return m[4][1], m[4][2], m[4][3]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element)  -- Get the matrix&lt;br /&gt;
x,y,z = getMatrixLeft(mat)     -- Get the matrix left direction&lt;br /&gt;
x,y,z = getMatrixForward(mat)  -- Get the matrix forward direction&lt;br /&gt;
x,y,z = getMatrixUp(mat)       -- Get the matrix up direction&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example function allows you to get the element matrix of an element that is outside your stream range.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Override normal getElementMatrix with our own version&lt;br /&gt;
function getElementMatrix(element)&lt;br /&gt;
	local rx, ry, rz = getElementRotation(element, &amp;quot;ZXY&amp;quot;)&lt;br /&gt;
	rx, ry, rz = math.rad(rx), math.rad(ry), math.rad(rz)&lt;br /&gt;
	local matrix = {}&lt;br /&gt;
	matrix[1] = {}&lt;br /&gt;
	matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][3] = -math.cos(rx)*math.sin(ry)&lt;br /&gt;
	&lt;br /&gt;
	matrix[2] = {}&lt;br /&gt;
	matrix[2][1] = -math.cos(rx)*math.sin(rz)&lt;br /&gt;
	matrix[2][2] = math.cos(rz)*math.cos(rx)&lt;br /&gt;
	matrix[2][3] = math.sin(rx)&lt;br /&gt;
	&lt;br /&gt;
	matrix[3] = {}&lt;br /&gt;
	matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx)&lt;br /&gt;
	matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx)&lt;br /&gt;
	matrix[3][3] = math.cos(rx)*math.cos(ry)&lt;br /&gt;
	&lt;br /&gt;
	matrix[4] = {}&lt;br /&gt;
	matrix[4][1], matrix[4][2], matrix[4][3] = getElementPosition(element) -- this is kinda useless but is used to have the same structure as getElementMatrix&lt;br /&gt;
	&lt;br /&gt;
	return matrix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element) -- this gives the same result as normal getElementMatrix(element), except that it also works if the element is not streamed in&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.3.0-9.04186|Added legacy argument}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_element_functions}}&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=36592</id>
		<title>GetElementMatrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=36592"/>
		<updated>2013-07-10T12:25:11Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function gets an element's transform matrix. This contains 16 float values that multiplied to a point will give you the point transformed. It is most useful for matrix calculations such as calculating offsets. For further information, please refer to a tutorial of matrices in computer graphics programming.&lt;br /&gt;
{{Note|The matrix returned by this function is [http://bugs.mtasa.com/view.php?id{{=}}6984 not setup correctly for some calculations.] unless the '''legacy''' argument is set to '''false'''}}&lt;br /&gt;
{{Tip|''For matrix manipulation which goes beyond the basic examples given on this page, see the [[Lua matrix library]].''}}&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table getElementMatrix ( element theElement [, bool legacy = true ] )       &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theElement:''' The element which you wish to retrieve the matrix for&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''legacy :''' Set to false to return correctly setup matrix. (i.e. Last column in the first 3 rows set to zero.)&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a multi-dimensional array containing a 4x4 matrix. Returns false if the element is not streamed in, and not a vehicle or ped.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example creates a utility function that turns an offset into a position that is relative to the specified element.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getPositionFromElementOffset(element,offX,offY,offZ)&lt;br /&gt;
	local m = getElementMatrix ( element )  -- Get the matrix&lt;br /&gt;
	local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  -- Apply transform&lt;br /&gt;
	local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]&lt;br /&gt;
	local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]&lt;br /&gt;
	return x, y, z                               -- Return the transformed point&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 3 units to the left of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,3,0,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 2 units in front of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,2,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 1 unit above the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,0,1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example creates some more matrix utility functions&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getMatrixLeft(m)&lt;br /&gt;
        return m[1][1], m[1][2], m[1][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixForward(m)&lt;br /&gt;
        return m[2][1], m[2][2], m[2][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixUp(m)&lt;br /&gt;
        return m[3][1], m[3][2], m[3][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixPosition(m)&lt;br /&gt;
        return m[4][1], m[4][2], m[4][3]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element)  -- Get the matrix&lt;br /&gt;
x,y,z = getMatrixLeft(mat)     -- Get the matrix left direction&lt;br /&gt;
x,y,z = getMatrixForward(mat)  -- Get the matrix forward direction&lt;br /&gt;
x,y,z = getMatrixUp(mat)       -- Get the matrix up direction&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example allows you to get the element matrix of an element that is outside your stream range.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Override normal getElementMatrix with our own version&lt;br /&gt;
function getElementMatrix(element)&lt;br /&gt;
	local rx, ry, rz = getElementRotation(element, &amp;quot;ZXY&amp;quot;)&lt;br /&gt;
	rx, ry, rz = math.rad(rx), math.rad(ry), math.rad(rz)&lt;br /&gt;
	local matrix = {}&lt;br /&gt;
	matrix[1] = {}&lt;br /&gt;
	matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][3] = -math.cos(rx)*math.sin(ry)&lt;br /&gt;
	&lt;br /&gt;
	matrix[2] = {}&lt;br /&gt;
	matrix[2][1] = -math.cos(rx)*math.sin(rz)&lt;br /&gt;
	matrix[2][2] = math.cos(rz)*math.cos(rx)&lt;br /&gt;
	matrix[2][3] = math.sin(rx)&lt;br /&gt;
	&lt;br /&gt;
	matrix[3] = {}&lt;br /&gt;
	matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx)&lt;br /&gt;
	matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx)&lt;br /&gt;
	matrix[3][3] = math.cos(rx)*math.cos(ry)&lt;br /&gt;
	&lt;br /&gt;
	matrix[4] = {}&lt;br /&gt;
	matrix[4][1], matrix[4][2], matrix[4][3] = getElementPosition(element) -- this is kinda useless but is used to have the same structure as getElementMatrix&lt;br /&gt;
	&lt;br /&gt;
	return matrix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element) -- this gives the same result as normal getElementMatrix(element), except that it also works if the element is not streamed in&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.3.0-9.04186|Added legacy argument}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_element_functions}}&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=36220</id>
		<title>GetElementMatrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=36220"/>
		<updated>2013-05-27T02:51:04Z</updated>

		<summary type="html">&lt;p&gt;Arezu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function gets an element's transform matrix. This contains 16 float values that multiplied to a point will give you the point transformed. It is most useful for matrix calculations such as calculating offsets. For further information, please refer to a tutorial of matrices in computer graphics programming.&lt;br /&gt;
{{Note|The matrix returned by this function is [http://bugs.mtasa.com/view.php?id{{=}}6984 not setup correctly for some calculations.] unless the '''legacy''' argument is set to '''false'''}}&lt;br /&gt;
{{Tip|''For matrix manipulation which goes beyond the basic examples given on this page, see the [[Lua matrix library]].''}}&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table getElementMatrix ( element theElement [, bool legacy = true ] )       &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theElement:''' The element which you wish to retrieve the matrix for&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''legacy :''' Set to false to return correctly setup matrix. (i.e. Last column in the first 3 rows set to zero.)&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a multi-dimensional array containing a 4x4 matrix. Returns false if the element is not streamed in, and not a vehicle or ped.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example creates a utility function that turns an offset into a position that is relative to the specified element.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getPositionFromElementOffset(element,offX,offY,offZ)&lt;br /&gt;
	local m = getElementMatrix ( element )  -- Get the matrix&lt;br /&gt;
	local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  -- Apply transform&lt;br /&gt;
	local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]&lt;br /&gt;
	local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]&lt;br /&gt;
	return x, y, z                               -- Return the transformed point&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 3 units to the left of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,3,0,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 2 units in front of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,2,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 1 unit above the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,0,1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example creates some more matrix utility functions&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getMatrixLeft(m)&lt;br /&gt;
        return m[1][1], m[1][2], m[1][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixForward(m)&lt;br /&gt;
        return m[2][1], m[2][2], m[2][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixUp(m)&lt;br /&gt;
        return m[3][1], m[3][2], m[3][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixPosition(m)&lt;br /&gt;
        return m[4][1], m[4][2], m[4][3]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element)  -- Get the matrix&lt;br /&gt;
x,y,z = getMatrixLeft(mat)     -- Get the matrix left direction&lt;br /&gt;
x,y,z = getMatrixForward(mat)  -- Get the matrix forward direction&lt;br /&gt;
x,y,z = getMatrixUp(mat)       -- Get the matrix up direction&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example allows you to get the element matrix of an element that is outside your stream range.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Override normal getElementMatrix with our own version&lt;br /&gt;
function getElementMatrix(element)&lt;br /&gt;
	local rx, ry, rz = getElementRotation(element, &amp;quot;ZXY&amp;quot;)&lt;br /&gt;
	local rx, ry, rz = math.rad(rotX), math.rad(rotY), math.rad(rotZ)&lt;br /&gt;
	local matrix = {}&lt;br /&gt;
	matrix[1] = {}&lt;br /&gt;
	matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][3] = -math.cos(rx)*math.sin(ry)&lt;br /&gt;
	&lt;br /&gt;
	matrix[2] = {}&lt;br /&gt;
	matrix[2][1] = -math.cos(rx)*math.sin(rz)&lt;br /&gt;
	matrix[2][2] = math.cos(rz)*math.cos(rx)&lt;br /&gt;
	matrix[2][3] = math.sin(rx)&lt;br /&gt;
	&lt;br /&gt;
	matrix[3] = {}&lt;br /&gt;
	matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx)&lt;br /&gt;
	matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx)&lt;br /&gt;
	matrix[3][3] = math.cos(rx)*math.cos(ry)&lt;br /&gt;
	&lt;br /&gt;
	matrix[4] = {}&lt;br /&gt;
	matrix[4][1], matrix[4][2], matrix[4][3] = getElementPosition(element) -- this is kinda useless but is used to have the same structure as getElementMatrix&lt;br /&gt;
	&lt;br /&gt;
	return matrix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element) -- this gives the same result as normal getElementMatrix(element), except that it also works if the element is not streamed in&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.3.0-9.04186|Added legacy argument}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_element_functions}}&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=36219</id>
		<title>GetElementMatrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=36219"/>
		<updated>2013-05-27T02:49:19Z</updated>

		<summary type="html">&lt;p&gt;Arezu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function gets an element's transform matrix. This contains 16 float values that multiplied to a point will give you the point transformed. It is most useful for matrix calculations such as calculating offsets. For further information, please refer to a tutorial of matrices in computer graphics programming.&lt;br /&gt;
{{Note|The matrix returned by this function is [http://bugs.mtasa.com/view.php?id{{=}}6984 not setup correctly for some calculations.] unless the '''legacy''' argument is set to '''false'''}}&lt;br /&gt;
{{Tip|''For matrix manipulation which goes beyond the basic examples given on this page, see the [[Lua matrix library]].''}}&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table getElementMatrix ( element theElement [, bool legacy = true ] )       &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theElement:''' The element which you wish to retrieve the matrix for&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''legacy :''' Set to false to return correctly setup matrix. (i.e. Last column in the first 3 rows set to zero.)&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a multi-dimensional array containing a 4x4 matrix. Returns false if the element is not streamed in, and not a vehicle or ped.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example creates a utility function that turns an offset into a position that is relative to the specified element.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getPositionFromElementOffset(element,offX,offY,offZ)&lt;br /&gt;
	local m = getElementMatrix ( element )  -- Get the matrix&lt;br /&gt;
	local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  -- Apply transform&lt;br /&gt;
	local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]&lt;br /&gt;
	local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]&lt;br /&gt;
	return x, y, z                               -- Return the transformed point&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 3 units to the left of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,3,0,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 2 units in front of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,2,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 1 unit above the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,0,1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example creates some more matrix utility functions&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getMatrixLeft(m)&lt;br /&gt;
        return m[1][1], m[1][2], m[1][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixForward(m)&lt;br /&gt;
        return m[2][1], m[2][2], m[2][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixUp(m)&lt;br /&gt;
        return m[3][1], m[3][2], m[3][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixPosition(m)&lt;br /&gt;
        return m[4][1], m[4][2], m[4][3]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element)  -- Get the matrix&lt;br /&gt;
x,y,z = getMatrixLeft(mat)     -- Get the matrix left direction&lt;br /&gt;
x,y,z = getMatrixForward(mat)  -- Get the matrix forward direction&lt;br /&gt;
x,y,z = getMatrixUp(mat)       -- Get the matrix up direction&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example allows you to get the element matrix of an element that is outside your stream range.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getElementMatrix(element)&lt;br /&gt;
	local rx, ry, rz = getElementRotation(element, &amp;quot;ZXY&amp;quot;)&lt;br /&gt;
	local rx, ry, rz = math.rad(rotX), math.rad(rotY), math.rad(rotZ)&lt;br /&gt;
	local matrix = {}&lt;br /&gt;
	matrix[1] = {}&lt;br /&gt;
	matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][3] = -math.cos(rx)*math.sin(ry)&lt;br /&gt;
	&lt;br /&gt;
	matrix[2] = {}&lt;br /&gt;
	matrix[2][1] = -math.cos(rx)*math.sin(rz)&lt;br /&gt;
	matrix[2][2] = math.cos(rz)*math.cos(rx)&lt;br /&gt;
	matrix[2][3] = math.sin(rx)&lt;br /&gt;
	&lt;br /&gt;
	matrix[3] = {}&lt;br /&gt;
	matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx)&lt;br /&gt;
	matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx)&lt;br /&gt;
	matrix[3][3] = math.cos(rx)*math.cos(ry)&lt;br /&gt;
	&lt;br /&gt;
	matrix[4] = {}&lt;br /&gt;
	matrix[4][1], matrix[4][2], matrix[4][3] = getElementPosition(element) -- this is kinda useless but is used to have the same structure as getElementMatrix&lt;br /&gt;
	&lt;br /&gt;
	return matrix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element) -- this gives the same result as normal getElementMatrix(element), except that it also works if the element is not streamed in&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.3.0-9.04186|Added legacy argument}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_element_functions}}&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=AddCommandHandler&amp;diff=33355</id>
		<title>AddCommandHandler</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=AddCommandHandler&amp;diff=33355"/>
		<updated>2012-09-11T15:24:02Z</updated>

		<summary type="html">&lt;p&gt;Arezu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
{{Note_box|It is strongly advised that you do not use the same name for your handler function as the command name, as this can lead to confusion if multiple handler functions are used. Use a name that describes your handler's purpose more specifically.}}&lt;br /&gt;
This function will attach a scripting function (handler) to a console command, so that whenever a player or administrator uses the command the function is called.&lt;br /&gt;
'''Note:''' You cannot use &amp;quot;list&amp;quot; or &amp;quot;test&amp;quot; as command name.&lt;br /&gt;
&lt;br /&gt;
Multiple command handlers can be attached to a single command, and they will be called in the order that the handlers were attached. Equally, multiple commands can be handled by a single function, and the ''commandName'' parameter used to decide the course of action.&lt;br /&gt;
&lt;br /&gt;
For users, a command is in the format:&lt;br /&gt;
&lt;br /&gt;
''commandName'' ''argument1'' ''argument2''&lt;br /&gt;
&lt;br /&gt;
This can be triggered from the player's console or directly from the chat box by prefixing the message with a forward slash (''/''). For server side handlers, the server admin is also able to trigger these directly from the server's console in the same way as they are triggered from a player's console.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&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 addCommandHandler ( string commandName, function handlerFunction, [bool restricted = false, bool caseSensitive = true] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''commandName:''' This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function.&lt;br /&gt;
*'''handlerFunction:''' This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional.&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''restricted:''' Specify whether or not this command should be restricted by default. Use this on commands that should be inaccessible to everyone as default except special users specified in the ACL (Access Control List). This is to make sure admin commands such as ie. 'punish' won't be available to everyone if a server administrator forgets masking it in ACL. Make sure to add the command to your ACL under the proper group for it to be usefull (i.e &amp;lt;right name=&amp;quot;command.killEveryone&amp;quot; access=&amp;quot;true&amp;quot;&amp;gt;&amp;lt;/right&amp;gt;). This argument defaults to false if nothing is specified.&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*'''caseSensitive:''' Specifies if the command handler will ignore the case for this command name.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool addCommandHandler ( string commandName, function handlerFunction, [bool caseSensitive = true] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''commandName:''' This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function.&lt;br /&gt;
*'''handlerFunction:''' This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional.&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*'''caseSensitive:''' Specifies if the command handler will ignore the case for this command name.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Handler function parameters====&lt;br /&gt;
These are the parameters for the handler function that is called when the command is used.&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;player playerSource, string commandName, [string arg1, string arg2, ...] &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''playerSource:''' The player who triggered the command. If not triggered by a player (e.g. by admin), this will be ''false''.&lt;br /&gt;
* '''commandName:''' The name of the command triggered. This is useful if multiple commands go through one function.&lt;br /&gt;
* '''arg1, arg2, ...:''' Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain [[nil]]. You can deal with a variable number of arguments using the vararg expression, as shown in '''Server Example 2''' below.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; string commandName, [string arg1, string arg2, ...] &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''commandName:''' The name of the command triggered. This is useful if multiple commands go through one function.&lt;br /&gt;
* '''arg1, arg2, ...:''' Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain [[nil]]. You can deal with a variable number of arguments using the vararg expression, as shown in '''Server Example 2''' below.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the command handler was added successfully, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Examples== &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;
'''Example 1:''' This example defines a command handler for the command ''createmarker''. This will create a red marker at the position of the player player who uses it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Define our function that will handle this command&lt;br /&gt;
function consoleCreateMarker ( playerSource )&lt;br /&gt;
	-- If a player triggered it (rather than the admin) then&lt;br /&gt;
	if ( playerSource ) then&lt;br /&gt;
		-- Get that player's position&lt;br /&gt;
		local x, y, z = getElementPosition ( playerSource )&lt;br /&gt;
		-- Create a size 2, red checkpoint marker at their position&lt;br /&gt;
		createMarker ( x, y, z, &amp;quot;checkpoint&amp;quot;, 2, 255, 0, 0, 255 )&lt;br /&gt;
		-- Output it in his chat box&lt;br /&gt;
		outputChatBox ( &amp;quot;You got a red marker&amp;quot;, playerSource )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
-- Attach the 'consoleCreateMarker' function to the &amp;quot;createmarker&amp;quot; command&lt;br /&gt;
addCommandHandler ( &amp;quot;createmarker&amp;quot;, consoleCreateMarker )&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;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;hide&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 2:''' This example makes use of Lua's vararg expression to implement a ''check_parameters'' command to count the number of parameters passed, merge them all into a single string and output it. This is also shows you how you can use table.concat to merge all the passed arguments. This is particularly useful when you want to read in a sentence of text passed from the user. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Define our function that will handle this command (which can accept a variable number of arguments after commandName)&lt;br /&gt;
function consoleCheckParameters ( playerSource, commandName, ... )&lt;br /&gt;
	-- If a player, not an admin, triggered it,&lt;br /&gt;
	if playerSource then&lt;br /&gt;
		local arg = {...}&lt;br /&gt;
		-- Get the number of arguments in the arg table (arg table is the same as: {...})&lt;br /&gt;
		local parameterCount = #arg&lt;br /&gt;
		-- Output it to the player's chatbox&lt;br /&gt;
		outputChatBox ( &amp;quot;Number of parameters: &amp;quot; .. parameterCount, playerSource )&lt;br /&gt;
		-- Join them together in a single comma-separated string&lt;br /&gt;
		local stringWithAllParameters = table.concat( arg, &amp;quot;, &amp;quot; )&lt;br /&gt;
		-- Output this parameter list to the player's chatbox&lt;br /&gt;
		outputChatBox ( &amp;quot;Parameters passed: &amp;quot; .. stringWithAllParameters, playerSource )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
-- Attach the 'consoleCheckParameters' function to the &amp;quot;check_parameters&amp;quot; command&lt;br /&gt;
addCommandHandler ( &amp;quot;check_parameters&amp;quot;, consoleCheckParameters )&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;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;hide&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 3:''' This example shows using a single function to handle multiple command handlers. This isn't advised for general usage, as it makes code harder to understand, but where multiple command handlers share some logic, it can be a useful way of reducing duplicated code. Generally, it would be preferable to put this shared logic in a separate function instead, as this gives you more control over the flow.&lt;br /&gt;
&amp;lt;!-- commands are case sensitive by default, in this example too --&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- make the function&lt;br /&gt;
function moneyCmd(player, cmd, amount)&lt;br /&gt;
    if getElementData(player, &amp;quot;canUseMoneyFunctions&amp;quot;) then -- the shared logic&lt;br /&gt;
        if cmd == &amp;quot;givemoney&amp;quot; then&lt;br /&gt;
            amount  = tonumber(amount)&lt;br /&gt;
            if amount then&lt;br /&gt;
                givePlayerMoney(player, amount)&lt;br /&gt;
            else&lt;br /&gt;
                outputChatBox(&amp;quot;[usage] /givemoney [amount]&amp;quot;, player)&lt;br /&gt;
            end&lt;br /&gt;
        else if cmd == &amp;quot;takemoney&amp;quot; then&lt;br /&gt;
            amount = tonumber(amount)&lt;br /&gt;
            if amount then&lt;br /&gt;
                takePlayerMoney(player, amount)&lt;br /&gt;
            else&lt;br /&gt;
                outputChatBox(&amp;quot;[usage] /takemoney [amount]&amp;quot;, player)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(&amp;quot;You aren't able to use this command&amp;quot;, player)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
addCommandHandler(&amp;quot;givemoney&amp;quot;, moneyCmd);&lt;br /&gt;
addCommandHandler(&amp;quot;takemoney&amp;quot;, moneyCmd);&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;false&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 1:''' This example warps the local player to a random nearby location (useful for when a player gets stuck somewhere).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function escapeMe ()&lt;br /&gt;
	local x, y, z = getElementPosition ( localPlayer ) --Get player's position&lt;br /&gt;
	setElementPosition ( localPlayer, x+(math.random(-10,10)), y+(math.random(-10,10)), z+(math.random(1,15)) ) --Move a player randomly to a nearby location. X is current x + a number between -10, 10 and so on.&lt;br /&gt;
end    &lt;br /&gt;
addCommandHandler ( &amp;quot;escape&amp;quot;, escapeMe ) --When player types &amp;quot;/escape&amp;quot; in chatbox or &amp;quot;escape&amp;quot; in console&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>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=AddCommandHandler&amp;diff=33354</id>
		<title>AddCommandHandler</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=AddCommandHandler&amp;diff=33354"/>
		<updated>2012-09-11T15:23:44Z</updated>

		<summary type="html">&lt;p&gt;Arezu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
{{Note_box|It is strongly advised that you do not use the same name for your handler function as the command name, as this can lead to confusion if multiple handler functions are used. Use a name that describes your handler's purpose more specifically.}}&lt;br /&gt;
This function will attach a scripting function (handler) to a console command, so that whenever a player or administrator uses the command the function is called.&lt;br /&gt;
'''Note:''' You cannot use &amp;quot;list&amp;quot; or &amp;quot;test&amp;quot; as a command name.&lt;br /&gt;
&lt;br /&gt;
Multiple command handlers can be attached to a single command, and they will be called in the order that the handlers were attached. Equally, multiple commands can be handled by a single function, and the ''commandName'' parameter used to decide the course of action.&lt;br /&gt;
&lt;br /&gt;
For users, a command is in the format:&lt;br /&gt;
&lt;br /&gt;
''commandName'' ''argument1'' ''argument2''&lt;br /&gt;
&lt;br /&gt;
This can be triggered from the player's console or directly from the chat box by prefixing the message with a forward slash (''/''). For server side handlers, the server admin is also able to trigger these directly from the server's console in the same way as they are triggered from a player's console.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&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 addCommandHandler ( string commandName, function handlerFunction, [bool restricted = false, bool caseSensitive = true] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''commandName:''' This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function.&lt;br /&gt;
*'''handlerFunction:''' This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional.&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''restricted:''' Specify whether or not this command should be restricted by default. Use this on commands that should be inaccessible to everyone as default except special users specified in the ACL (Access Control List). This is to make sure admin commands such as ie. 'punish' won't be available to everyone if a server administrator forgets masking it in ACL. Make sure to add the command to your ACL under the proper group for it to be usefull (i.e &amp;lt;right name=&amp;quot;command.killEveryone&amp;quot; access=&amp;quot;true&amp;quot;&amp;gt;&amp;lt;/right&amp;gt;). This argument defaults to false if nothing is specified.&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*'''caseSensitive:''' Specifies if the command handler will ignore the case for this command name.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool addCommandHandler ( string commandName, function handlerFunction, [bool caseSensitive = true] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''commandName:''' This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function.&lt;br /&gt;
*'''handlerFunction:''' This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional.&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*'''caseSensitive:''' Specifies if the command handler will ignore the case for this command name.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Handler function parameters====&lt;br /&gt;
These are the parameters for the handler function that is called when the command is used.&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;player playerSource, string commandName, [string arg1, string arg2, ...] &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''playerSource:''' The player who triggered the command. If not triggered by a player (e.g. by admin), this will be ''false''.&lt;br /&gt;
* '''commandName:''' The name of the command triggered. This is useful if multiple commands go through one function.&lt;br /&gt;
* '''arg1, arg2, ...:''' Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain [[nil]]. You can deal with a variable number of arguments using the vararg expression, as shown in '''Server Example 2''' below.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; string commandName, [string arg1, string arg2, ...] &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''commandName:''' The name of the command triggered. This is useful if multiple commands go through one function.&lt;br /&gt;
* '''arg1, arg2, ...:''' Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain [[nil]]. You can deal with a variable number of arguments using the vararg expression, as shown in '''Server Example 2''' below.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the command handler was added successfully, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Examples== &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;
'''Example 1:''' This example defines a command handler for the command ''createmarker''. This will create a red marker at the position of the player player who uses it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Define our function that will handle this command&lt;br /&gt;
function consoleCreateMarker ( playerSource )&lt;br /&gt;
	-- If a player triggered it (rather than the admin) then&lt;br /&gt;
	if ( playerSource ) then&lt;br /&gt;
		-- Get that player's position&lt;br /&gt;
		local x, y, z = getElementPosition ( playerSource )&lt;br /&gt;
		-- Create a size 2, red checkpoint marker at their position&lt;br /&gt;
		createMarker ( x, y, z, &amp;quot;checkpoint&amp;quot;, 2, 255, 0, 0, 255 )&lt;br /&gt;
		-- Output it in his chat box&lt;br /&gt;
		outputChatBox ( &amp;quot;You got a red marker&amp;quot;, playerSource )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
-- Attach the 'consoleCreateMarker' function to the &amp;quot;createmarker&amp;quot; command&lt;br /&gt;
addCommandHandler ( &amp;quot;createmarker&amp;quot;, consoleCreateMarker )&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;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;hide&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 2:''' This example makes use of Lua's vararg expression to implement a ''check_parameters'' command to count the number of parameters passed, merge them all into a single string and output it. This is also shows you how you can use table.concat to merge all the passed arguments. This is particularly useful when you want to read in a sentence of text passed from the user. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Define our function that will handle this command (which can accept a variable number of arguments after commandName)&lt;br /&gt;
function consoleCheckParameters ( playerSource, commandName, ... )&lt;br /&gt;
	-- If a player, not an admin, triggered it,&lt;br /&gt;
	if playerSource then&lt;br /&gt;
		local arg = {...}&lt;br /&gt;
		-- Get the number of arguments in the arg table (arg table is the same as: {...})&lt;br /&gt;
		local parameterCount = #arg&lt;br /&gt;
		-- Output it to the player's chatbox&lt;br /&gt;
		outputChatBox ( &amp;quot;Number of parameters: &amp;quot; .. parameterCount, playerSource )&lt;br /&gt;
		-- Join them together in a single comma-separated string&lt;br /&gt;
		local stringWithAllParameters = table.concat( arg, &amp;quot;, &amp;quot; )&lt;br /&gt;
		-- Output this parameter list to the player's chatbox&lt;br /&gt;
		outputChatBox ( &amp;quot;Parameters passed: &amp;quot; .. stringWithAllParameters, playerSource )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
-- Attach the 'consoleCheckParameters' function to the &amp;quot;check_parameters&amp;quot; command&lt;br /&gt;
addCommandHandler ( &amp;quot;check_parameters&amp;quot;, consoleCheckParameters )&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;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;hide&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 3:''' This example shows using a single function to handle multiple command handlers. This isn't advised for general usage, as it makes code harder to understand, but where multiple command handlers share some logic, it can be a useful way of reducing duplicated code. Generally, it would be preferable to put this shared logic in a separate function instead, as this gives you more control over the flow.&lt;br /&gt;
&amp;lt;!-- commands are case sensitive by default, in this example too --&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- make the function&lt;br /&gt;
function moneyCmd(player, cmd, amount)&lt;br /&gt;
    if getElementData(player, &amp;quot;canUseMoneyFunctions&amp;quot;) then -- the shared logic&lt;br /&gt;
        if cmd == &amp;quot;givemoney&amp;quot; then&lt;br /&gt;
            amount  = tonumber(amount)&lt;br /&gt;
            if amount then&lt;br /&gt;
                givePlayerMoney(player, amount)&lt;br /&gt;
            else&lt;br /&gt;
                outputChatBox(&amp;quot;[usage] /givemoney [amount]&amp;quot;, player)&lt;br /&gt;
            end&lt;br /&gt;
        else if cmd == &amp;quot;takemoney&amp;quot; then&lt;br /&gt;
            amount = tonumber(amount)&lt;br /&gt;
            if amount then&lt;br /&gt;
                takePlayerMoney(player, amount)&lt;br /&gt;
            else&lt;br /&gt;
                outputChatBox(&amp;quot;[usage] /takemoney [amount]&amp;quot;, player)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(&amp;quot;You aren't able to use this command&amp;quot;, player)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
addCommandHandler(&amp;quot;givemoney&amp;quot;, moneyCmd);&lt;br /&gt;
addCommandHandler(&amp;quot;takemoney&amp;quot;, moneyCmd);&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;false&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 1:''' This example warps the local player to a random nearby location (useful for when a player gets stuck somewhere).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function escapeMe ()&lt;br /&gt;
	local x, y, z = getElementPosition ( localPlayer ) --Get player's position&lt;br /&gt;
	setElementPosition ( localPlayer, x+(math.random(-10,10)), y+(math.random(-10,10)), z+(math.random(1,15)) ) --Move a player randomly to a nearby location. X is current x + a number between -10, 10 and so on.&lt;br /&gt;
end    &lt;br /&gt;
addCommandHandler ( &amp;quot;escape&amp;quot;, escapeMe ) --When player types &amp;quot;/escape&amp;quot; in chatbox or &amp;quot;escape&amp;quot; in console&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>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=AddCommandHandler&amp;diff=33353</id>
		<title>AddCommandHandler</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=AddCommandHandler&amp;diff=33353"/>
		<updated>2012-09-11T15:23:12Z</updated>

		<summary type="html">&lt;p&gt;Arezu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
{{Note_box|It is strongly advised that you do not use the same name for your handler function as the command name, as this can lead to confusion if multiple handler functions are used. Use a name that describes your handler's purpose more specifically.}}&lt;br /&gt;
This function will attach a scripting function (handler) to a console command, so that whenever a player or administrator uses the command the function is called.&lt;br /&gt;
''Note:'' You cannot use &amp;quot;list&amp;quot; or &amp;quot;test&amp;quot; as a command name.&lt;br /&gt;
&lt;br /&gt;
Multiple command handlers can be attached to a single command, and they will be called in the order that the handlers were attached. Equally, multiple commands can be handled by a single function, and the ''commandName'' parameter used to decide the course of action.&lt;br /&gt;
&lt;br /&gt;
For users, a command is in the format:&lt;br /&gt;
&lt;br /&gt;
''commandName'' ''argument1'' ''argument2''&lt;br /&gt;
&lt;br /&gt;
This can be triggered from the player's console or directly from the chat box by prefixing the message with a forward slash (''/''). For server side handlers, the server admin is also able to trigger these directly from the server's console in the same way as they are triggered from a player's console.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&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 addCommandHandler ( string commandName, function handlerFunction, [bool restricted = false, bool caseSensitive = true] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''commandName:''' This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function.&lt;br /&gt;
*'''handlerFunction:''' This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional.&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''restricted:''' Specify whether or not this command should be restricted by default. Use this on commands that should be inaccessible to everyone as default except special users specified in the ACL (Access Control List). This is to make sure admin commands such as ie. 'punish' won't be available to everyone if a server administrator forgets masking it in ACL. Make sure to add the command to your ACL under the proper group for it to be usefull (i.e &amp;lt;right name=&amp;quot;command.killEveryone&amp;quot; access=&amp;quot;true&amp;quot;&amp;gt;&amp;lt;/right&amp;gt;). This argument defaults to false if nothing is specified.&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*'''caseSensitive:''' Specifies if the command handler will ignore the case for this command name.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool addCommandHandler ( string commandName, function handlerFunction, [bool caseSensitive = true] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''commandName:''' This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function.&lt;br /&gt;
*'''handlerFunction:''' This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional.&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*'''caseSensitive:''' Specifies if the command handler will ignore the case for this command name.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Handler function parameters====&lt;br /&gt;
These are the parameters for the handler function that is called when the command is used.&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;player playerSource, string commandName, [string arg1, string arg2, ...] &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''playerSource:''' The player who triggered the command. If not triggered by a player (e.g. by admin), this will be ''false''.&lt;br /&gt;
* '''commandName:''' The name of the command triggered. This is useful if multiple commands go through one function.&lt;br /&gt;
* '''arg1, arg2, ...:''' Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain [[nil]]. You can deal with a variable number of arguments using the vararg expression, as shown in '''Server Example 2''' below.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; string commandName, [string arg1, string arg2, ...] &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''commandName:''' The name of the command triggered. This is useful if multiple commands go through one function.&lt;br /&gt;
* '''arg1, arg2, ...:''' Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain [[nil]]. You can deal with a variable number of arguments using the vararg expression, as shown in '''Server Example 2''' below.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the command handler was added successfully, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Examples== &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;
'''Example 1:''' This example defines a command handler for the command ''createmarker''. This will create a red marker at the position of the player player who uses it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Define our function that will handle this command&lt;br /&gt;
function consoleCreateMarker ( playerSource )&lt;br /&gt;
	-- If a player triggered it (rather than the admin) then&lt;br /&gt;
	if ( playerSource ) then&lt;br /&gt;
		-- Get that player's position&lt;br /&gt;
		local x, y, z = getElementPosition ( playerSource )&lt;br /&gt;
		-- Create a size 2, red checkpoint marker at their position&lt;br /&gt;
		createMarker ( x, y, z, &amp;quot;checkpoint&amp;quot;, 2, 255, 0, 0, 255 )&lt;br /&gt;
		-- Output it in his chat box&lt;br /&gt;
		outputChatBox ( &amp;quot;You got a red marker&amp;quot;, playerSource )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
-- Attach the 'consoleCreateMarker' function to the &amp;quot;createmarker&amp;quot; command&lt;br /&gt;
addCommandHandler ( &amp;quot;createmarker&amp;quot;, consoleCreateMarker )&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;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;hide&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 2:''' This example makes use of Lua's vararg expression to implement a ''check_parameters'' command to count the number of parameters passed, merge them all into a single string and output it. This is also shows you how you can use table.concat to merge all the passed arguments. This is particularly useful when you want to read in a sentence of text passed from the user. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Define our function that will handle this command (which can accept a variable number of arguments after commandName)&lt;br /&gt;
function consoleCheckParameters ( playerSource, commandName, ... )&lt;br /&gt;
	-- If a player, not an admin, triggered it,&lt;br /&gt;
	if playerSource then&lt;br /&gt;
		local arg = {...}&lt;br /&gt;
		-- Get the number of arguments in the arg table (arg table is the same as: {...})&lt;br /&gt;
		local parameterCount = #arg&lt;br /&gt;
		-- Output it to the player's chatbox&lt;br /&gt;
		outputChatBox ( &amp;quot;Number of parameters: &amp;quot; .. parameterCount, playerSource )&lt;br /&gt;
		-- Join them together in a single comma-separated string&lt;br /&gt;
		local stringWithAllParameters = table.concat( arg, &amp;quot;, &amp;quot; )&lt;br /&gt;
		-- Output this parameter list to the player's chatbox&lt;br /&gt;
		outputChatBox ( &amp;quot;Parameters passed: &amp;quot; .. stringWithAllParameters, playerSource )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
-- Attach the 'consoleCheckParameters' function to the &amp;quot;check_parameters&amp;quot; command&lt;br /&gt;
addCommandHandler ( &amp;quot;check_parameters&amp;quot;, consoleCheckParameters )&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;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;hide&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 3:''' This example shows using a single function to handle multiple command handlers. This isn't advised for general usage, as it makes code harder to understand, but where multiple command handlers share some logic, it can be a useful way of reducing duplicated code. Generally, it would be preferable to put this shared logic in a separate function instead, as this gives you more control over the flow.&lt;br /&gt;
&amp;lt;!-- commands are case sensitive by default, in this example too --&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- make the function&lt;br /&gt;
function moneyCmd(player, cmd, amount)&lt;br /&gt;
    if getElementData(player, &amp;quot;canUseMoneyFunctions&amp;quot;) then -- the shared logic&lt;br /&gt;
        if cmd == &amp;quot;givemoney&amp;quot; then&lt;br /&gt;
            amount  = tonumber(amount)&lt;br /&gt;
            if amount then&lt;br /&gt;
                givePlayerMoney(player, amount)&lt;br /&gt;
            else&lt;br /&gt;
                outputChatBox(&amp;quot;[usage] /givemoney [amount]&amp;quot;, player)&lt;br /&gt;
            end&lt;br /&gt;
        else if cmd == &amp;quot;takemoney&amp;quot; then&lt;br /&gt;
            amount = tonumber(amount)&lt;br /&gt;
            if amount then&lt;br /&gt;
                takePlayerMoney(player, amount)&lt;br /&gt;
            else&lt;br /&gt;
                outputChatBox(&amp;quot;[usage] /takemoney [amount]&amp;quot;, player)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(&amp;quot;You aren't able to use this command&amp;quot;, player)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
addCommandHandler(&amp;quot;givemoney&amp;quot;, moneyCmd);&lt;br /&gt;
addCommandHandler(&amp;quot;takemoney&amp;quot;, moneyCmd);&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;false&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 1:''' This example warps the local player to a random nearby location (useful for when a player gets stuck somewhere).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function escapeMe ()&lt;br /&gt;
	local x, y, z = getElementPosition ( localPlayer ) --Get player's position&lt;br /&gt;
	setElementPosition ( localPlayer, x+(math.random(-10,10)), y+(math.random(-10,10)), z+(math.random(1,15)) ) --Move a player randomly to a nearby location. X is current x + a number between -10, 10 and so on.&lt;br /&gt;
end    &lt;br /&gt;
addCommandHandler ( &amp;quot;escape&amp;quot;, escapeMe ) --When player types &amp;quot;/escape&amp;quot; in chatbox or &amp;quot;escape&amp;quot; in console&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>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GuiCreateWindow&amp;diff=33174</id>
		<title>GuiCreateWindow</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GuiCreateWindow&amp;diff=33174"/>
		<updated>2012-09-07T08:15:18Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function is for creating a new GUI window.  This provides a base for other gui elements to be created within.  However, windows do not have a parent and cannot be created in any GUI elements.&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 guiCreateWindow ( float x, float y, float width, float height, string titleBarText, bool relative )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''x:''' A float of the 2D x position of the GUI window on a player's screen.  This is affected by the ''relative'' argument.&lt;br /&gt;
*'''y:''' A float of the 2D y position of the GUI window on a player's screen. This is affected by the ''relative'' argument.&lt;br /&gt;
*'''width:''' A float of the width of the GUI window. This is affected by the ''relative'' argument.&lt;br /&gt;
*'''height:''' A float of the height of the GUI window. This is affected by the ''relative'' argument.&lt;br /&gt;
*'''titleBarText:''' A string of the text that will be displayed in the title bar of the window.&lt;br /&gt;
*'''relative:''' This is whether sizes and positioning are relative.  If this is ''true'', then all x,y,width,height floats must be between 0 and 1, representing sizes/positions as a fraction of the screen size. If ''false'', then the size and co-ordinates are based on client's resolution, accessible using [[guiGetScreenSize]].&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a gui window element if it was created successfully, false otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
'''Example 1:''' This example creates a information window and adds two tabs to a &amp;quot;tabPanel&amp;quot; tabpanel, and adds some other gui elements to it.&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;
'''Example 2:''' This example creates a weapon selection screen, complete with a window, gridlist and a button. Users can select a shotgun or a machine gun. The window is not movable or sizable.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--Setup some tables&lt;br /&gt;
&lt;br /&gt;
shotguns = {&lt;br /&gt;
      &amp;quot;chrome&amp;quot;,&lt;br /&gt;
      &amp;quot;sawn-off&amp;quot;,&lt;br /&gt;
      &amp;quot;combat&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
machineGun = {&lt;br /&gt;
      &amp;quot;m4&amp;quot;,&lt;br /&gt;
      &amp;quot;ak-47&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function setupWeaponSelection ( theResource )&lt;br /&gt;
      -- getResourceRootElement(getThisResource()) at the bottom means it will only create the gui on this resource start&lt;br /&gt;
      -- Create a window for our spawnscreen, with the title &amp;quot;Select your weapons&amp;quot;.&lt;br /&gt;
      spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, &amp;quot;Select your weapons&amp;quot;, true )&lt;br /&gt;
      -- create an OK button to allow the user to confirm their selections, and attach it to the confirmSelection function&lt;br /&gt;
      spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, &amp;quot;OK&amp;quot;, true, spawnScreenMenu )&lt;br /&gt;
      -- ensure the user can't move or resize our spawnscreen.&lt;br /&gt;
      guiWindowSetMovable ( spawnScreenMenu, false )&lt;br /&gt;
      guiWindowSetSizable ( spawnScreenMenu, false )&lt;br /&gt;
      -- create our gridlist, which fills up most of the window.&lt;br /&gt;
      spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu )&lt;br /&gt;
      guiGridListSetSelectionMode ( spawnScreenGridList, 2 ) -- ensure the selection mode is one per column&lt;br /&gt;
      -- Since we have 2 sets of weapons, create a column for shotguns and one for machine guns&lt;br /&gt;
      guiGridListAddColumn ( spawnScreenGridList, &amp;quot;Shotguns&amp;quot;, 0.3 )&lt;br /&gt;
      guiGridListAddColumn ( spawnScreenGridList, &amp;quot;Machine guns&amp;quot;, 0.3 )&lt;br /&gt;
      -- next, we loop through our handguns table to add handgun items to the gridlist&lt;br /&gt;
      for key,weaponName in pairs(shotguns) do&lt;br /&gt;
            -- add a new row to our gridlist each time&lt;br /&gt;
            local row = guiGridListAddRow ( spawnScreenGridList )&lt;br /&gt;
            -- next, we set that row's text to the weapon name. Column is 1 since the &amp;quot;Shotguns&amp;quot; column was created first.&lt;br /&gt;
            guiGridListSetItemText ( spawnScreenGridList, row, 1, weaponName, false, false )&lt;br /&gt;
      end&lt;br /&gt;
      -- we repeat the process for other weapon list, changing the column number&lt;br /&gt;
      row = 0&lt;br /&gt;
      for key,weaponName in pairs(machineGun) do&lt;br /&gt;
            -- we don't need to create new rows as that was done in the previous loop&lt;br /&gt;
            -- we just set the row's text to the weapon name. Column is 2 since the &amp;quot;Machine guns&amp;quot; column was created second.&lt;br /&gt;
            guiGridListSetItemText ( spawnScreenGridList, row, 2, weaponName, false, false )&lt;br /&gt;
            row = row + 1 -- increase the row number&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onClientResourceStart&amp;quot;, getResourceRootElement(getThisResource()), setupWeaponSelection )&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>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GuiCreateWindow&amp;diff=33173</id>
		<title>GuiCreateWindow</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GuiCreateWindow&amp;diff=33173"/>
		<updated>2012-09-07T08:14:48Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function is for creating a new GUI window.  This provides a base for other gui elements to be created within.  However, windows do not have a parent and cannot be created in any GUI elements.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
gui-window guiCreateWindow ( float x, float y, float width, float height, string titleBarText, bool relative )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''x:''' A float of the 2D x position of the GUI window on a player's screen.  This is affected by the ''relative'' argument.&lt;br /&gt;
*'''y:''' A float of the 2D y position of the GUI window on a player's screen. This is affected by the ''relative'' argument.&lt;br /&gt;
*'''width:''' A float of the width of the GUI window. This is affected by the ''relative'' argument.&lt;br /&gt;
*'''height:''' A float of the height of the GUI window. This is affected by the ''relative'' argument.&lt;br /&gt;
*'''titleBarText:''' A string of the text that will be displayed in the title bar of the window.&lt;br /&gt;
*'''relative:''' This is whether sizes and positioning are relative.  If this is ''true'', then all x,y,width,height floats must be between 0 and 1, representing sizes/positions as a fraction of the screen size. If ''false'', then the size and co-ordinates are based on client's resolution, accessible using [[guiGetScreenSize]].&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a gui window element if it was created successfully, false otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
'''Example 1:''' This example creates a information window and adds two tabs to a &amp;quot;tabPanel&amp;quot; tabpanel, and adds some other gui elements to it.&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;
'''Example 2:''' This example creates a weapon selection screen, complete with a window, gridlist and a button. Users can select a shotgun or a machine gun. The window is not movable or sizable.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--Setup some tables&lt;br /&gt;
&lt;br /&gt;
shotguns = {&lt;br /&gt;
      &amp;quot;chrome&amp;quot;,&lt;br /&gt;
      &amp;quot;sawn-off&amp;quot;,&lt;br /&gt;
      &amp;quot;combat&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
machineGun = {&lt;br /&gt;
      &amp;quot;m4&amp;quot;,&lt;br /&gt;
      &amp;quot;ak-47&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function setupWeaponSelection ( theResource )&lt;br /&gt;
      -- getResourceRootElement(getThisResource()) at the bottom means it will only create the gui on this resource start&lt;br /&gt;
      -- Create a window for our spawnscreen, with the title &amp;quot;Select your weapons&amp;quot;.&lt;br /&gt;
      spawnScreenMenu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, &amp;quot;Select your weapons&amp;quot;, true )&lt;br /&gt;
      -- create an OK button to allow the user to confirm their selections, and attach it to the confirmSelection function&lt;br /&gt;
      spawnScreenOKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, &amp;quot;OK&amp;quot;, true, spawnScreenMenu )&lt;br /&gt;
      -- ensure the user can't move or resize our spawnscreen.&lt;br /&gt;
      guiWindowSetMovable ( spawnScreenMenu, false )&lt;br /&gt;
      guiWindowSetSizable ( spawnScreenMenu, false )&lt;br /&gt;
      -- create our gridlist, which fills up most of the window.&lt;br /&gt;
      spawnScreenGridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, spawnScreenMenu )&lt;br /&gt;
      guiGridListSetSelectionMode ( spawnScreenGridList, 2 ) -- ensure the selection mode is one per column&lt;br /&gt;
      -- Since we have 2 sets of weapons, create a column for shotguns and one for machine guns&lt;br /&gt;
      guiGridListAddColumn ( spawnScreenGridList, &amp;quot;Shotguns&amp;quot;, 0.3 )&lt;br /&gt;
      guiGridListAddColumn ( spawnScreenGridList, &amp;quot;Machine guns&amp;quot;, 0.3 )&lt;br /&gt;
      -- next, we loop through our handguns table to add handgun items to the gridlist&lt;br /&gt;
      for key,weaponName in pairs(shotguns) do&lt;br /&gt;
            -- add a new row to our gridlist each time&lt;br /&gt;
            local row = guiGridListAddRow ( spawnScreenGridList )&lt;br /&gt;
            -- next, we set that row's text to the weapon name. Column is 1 since the &amp;quot;Shotguns&amp;quot; column was created first.&lt;br /&gt;
            guiGridListSetItemText ( spawnScreenGridList, row, 1, weaponName, false, false )&lt;br /&gt;
      end&lt;br /&gt;
      -- we repeat the process for other weapon list, changing the column number&lt;br /&gt;
      row = 0&lt;br /&gt;
      for key,weaponName in pairs(machineGun) do&lt;br /&gt;
            -- we don't need to create new rows as that was done in the previous loop&lt;br /&gt;
            -- we just set the row's text to the weapon name. Column is 2 since the &amp;quot;Machine guns&amp;quot; column was created second.&lt;br /&gt;
            guiGridListSetItemText ( spawnScreenGridList, row, 2, weaponName, false, false )&lt;br /&gt;
            row = row + 1 -- increase the row number&lt;br /&gt;
      end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onClientResourceStart&amp;quot;, getResourceRootElement(getThisResource()), setupWeaponSelection )&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>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementsByType&amp;diff=33172</id>
		<title>GetElementsByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementsByType&amp;diff=33172"/>
		<updated>2012-09-07T07:56:40Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Required Arguments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server_client_function}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function is used to retrieve a list of all elements of the specified type. This can be useful, as it disregards ''where'' in the element tree it is. It can be used with either the built in types (listed below) or with any custom type used in a .map file. For example, if there is an element of type &amp;quot;flag&amp;quot; (e.g. &amp;lt;flag /&amp;gt;) in the .map file, the using &amp;quot;flag&amp;quot; as the type argument would find 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;&lt;br /&gt;
table getElementsByType ( string theType, [ element startat=getRootElement() ] ) &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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table getElementsByType ( string theType, [ element startat=getRootElement(), bool streamedIn=false ] ) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theType:''' The type of element you want a list of. This is the same as the tag name in the .map file, so this can be used with a custom element type if desired. Built in types are:&lt;br /&gt;
**'''&amp;quot;player&amp;quot;:''' A player connected to the server&lt;br /&gt;
**'''&amp;quot;ped&amp;quot;:''' A ped&lt;br /&gt;
**'''&amp;quot;water&amp;quot;:''' A water polygon&lt;br /&gt;
**'''&amp;quot;sound&amp;quot;:''' A playing sound&lt;br /&gt;
**'''&amp;quot;vehicle&amp;quot;:''' A vehicle&lt;br /&gt;
**'''&amp;quot;object&amp;quot;:''' An object&lt;br /&gt;
**'''&amp;quot;pickup&amp;quot;:''' A pickup&lt;br /&gt;
**'''&amp;quot;marker&amp;quot;:''' A marker&lt;br /&gt;
**'''&amp;quot;colshape&amp;quot;:''' A collision shape&lt;br /&gt;
**'''&amp;quot;blip&amp;quot;:''' A blip&lt;br /&gt;
**'''&amp;quot;radararea&amp;quot;:''' A radar area&lt;br /&gt;
**'''&amp;quot;team&amp;quot;:''' A team&lt;br /&gt;
**'''&amp;quot;spawnpoint&amp;quot;:''' A spawnpoint&lt;br /&gt;
**'''&amp;quot;remoteclient&amp;quot;:''' A remote client connected to the server&lt;br /&gt;
**'''&amp;quot;console&amp;quot;:''' The server Console&lt;br /&gt;
**'''&amp;quot;projectile&amp;quot;:''' A projectile&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''startat:''' The [[element]] the search should start at. Children of this element are searched, siblings or parents will not be found. By default, this is the root element which should suit most uses.&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;
*'''streamedIn:''' If true, function will only return elements that are streamed in.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a ''table'' containing all the elements of the specified type. Returns an empty ''table'' if there are no elements of the specified type. Returns ''false'' if the string specified is invalid (or not a string).&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
'''Example 1:''' This example retrieves a table of the players in the server, and checks whether or not each one is in a vehicle:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local players = getElementsByType ( &amp;quot;player&amp;quot; ) -- get a table of all the players in the server&lt;br /&gt;
for theKey,thePlayer in ipairs(players) do -- use a generic for loop to step through each player&lt;br /&gt;
   if ( isPlayerInVehicle ( thePlayer ) ) then -- if the player is in a vehicle, announce it&lt;br /&gt;
      outputChatBox ( getPlayerName ( thePlayer ) .. &amp;quot; is in a vehicle&amp;quot; )&lt;br /&gt;
   else -- if the player isn't in a vehicle, announce that he/she is on foot&lt;br /&gt;
      outputChatBox ( getPlayerName ( thePlayer ) .. &amp;quot; is on foot&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This example retrieves a table of the teams in the server, and display them in chat:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local teams = getElementsByType(&amp;quot;team&amp;quot;)&lt;br /&gt;
for i,team in ipairs(teams) do&lt;br /&gt;
   local teamName = getTeamName(team) -- get the team name&lt;br /&gt;
   outputChatBox(teamName) -- display the team name in chat&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 3:''' This shows how you could create a new element to describe a gas station:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createGasStations(below)&lt;br /&gt;
    local gasstations = getElementsByType ( &amp;quot;gasstation&amp;quot;, below ) -- get a table of all the gas station elements in the element tree&lt;br /&gt;
    for theKey,theGasStation in ipairs(gasstations) do &lt;br /&gt;
        local x = getElementData(theGasStation, &amp;quot;posX&amp;quot;) -- get the position of the element&lt;br /&gt;
        local y = getElementData(theGasStation, &amp;quot;posY&amp;quot;)&lt;br /&gt;
        local z = getElementData(theGasStation, &amp;quot;posZ&amp;quot;)&lt;br /&gt;
        setElementParent(createColSphere(x, y, z, 10), theGasStation) -- create a colshape for the gas station at the gas station's position&lt;br /&gt;
        addEventHandler(&amp;quot;onColShapeHit&amp;quot;, theGasStation, giveGas) -- when the player hits&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function mapLoad()&lt;br /&gt;
    createGasStations(source) -- create gas stations for the map that's just loaded&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, getRootElement(), mapLoad)&lt;br /&gt;
&lt;br /&gt;
function giveGas(hittingElement)&lt;br /&gt;
    local theGasStation = source&lt;br /&gt;
    if getElementType(hittingElement) == &amp;quot;vehicle&amp;quot; then&lt;br /&gt;
        local gas_left = getElementData(theGasStation, &amp;quot;amount&amp;quot;)&lt;br /&gt;
        local gas_speed = getElementData(theGasStation, &amp;quot;speed&amp;quot;)&lt;br /&gt;
        if gas_left &amp;gt; 0 then&lt;br /&gt;
&lt;br /&gt;
            local gas_to_remove = gas_speed &lt;br /&gt;
            if gas_left &amp;lt; gas_speed then&lt;br /&gt;
                gas_to_remove = gas_left&lt;br /&gt;
&lt;br /&gt;
            local current_vehicle_gas = getElementData(hittingElement, &amp;quot;gas&amp;quot;)&lt;br /&gt;
            current_vehicle_gas = current_vehicle_gas + gas_to_remove&lt;br /&gt;
            gas_left = gas_left - gas_to_remove&lt;br /&gt;
&lt;br /&gt;
            setElementData(hittingElement, &amp;quot;gas&amp;quot;, current_vehicle_gas)&lt;br /&gt;
            setElementData(theGasStation, &amp;quot;amount&amp;quot;, gas_left)&lt;br /&gt;
        else&lt;br /&gt;
            outputChatBox(&amp;quot;Pump is out of gas!&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Element_functions}}&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CreateWeapon&amp;diff=33094</id>
		<title>CreateWeapon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CreateWeapon&amp;diff=33094"/>
		<updated>2012-09-03T02:56:44Z</updated>

		<summary type="html">&lt;p&gt;Arezu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
Creates a custom weapon that can fire bullets not related to player held weapons.&lt;br /&gt;
'''Note:''' All weapon types does not work.&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;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theType:''' The weapon type such as M4.&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 custom weapon element type and creates a simulated weapon at that position.&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.3.0-4555|1.3.0-4555|}}&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>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CreateWeapon&amp;diff=33093</id>
		<title>CreateWeapon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CreateWeapon&amp;diff=33093"/>
		<updated>2012-09-03T02:56:23Z</updated>

		<summary type="html">&lt;p&gt;Arezu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
Creates a custom weapon that can fire bullets not related to player held weapons.&lt;br /&gt;
'''Note:''' All weapons does not work.&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;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theType:''' The weapon type such as M4.&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 custom weapon element type and creates a simulated weapon at that position.&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.3.0-4555|1.3.0-4555|}}&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>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CreateWeapon&amp;diff=33092</id>
		<title>CreateWeapon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CreateWeapon&amp;diff=33092"/>
		<updated>2012-09-03T02:56:13Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Required Arguments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
Creates a custom weapon that can fire bullets not related to player held weapons.&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;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theType:''' The weapon type such as M4.&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 custom weapon element type and creates a simulated weapon at that position.&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.3.0-4555|1.3.0-4555|}}&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>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CreateWeapon&amp;diff=33091</id>
		<title>CreateWeapon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CreateWeapon&amp;diff=33091"/>
		<updated>2012-09-03T02:55:52Z</updated>

		<summary type="html">&lt;p&gt;Arezu: /* Required Arguments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
Creates a custom weapon that can fire bullets not related to player held weapons.&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;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theType:''' The weapon type such as M4. '''Note:''' All weapons does not work.&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 custom weapon element type and creates a simulated weapon at that position.&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.3.0-4555|1.3.0-4555|}}&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>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=32989</id>
		<title>GetElementMatrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=32989"/>
		<updated>2012-08-30T21:49:06Z</updated>

		<summary type="html">&lt;p&gt;Arezu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function gets an element's transform matrix. This contains 16 float values that multiplied to a point will give you the point transformed. It is most useful for matrix calculations such as calculating offsets. For further information, please refer to a tutorial of matrices in computer graphics programming.&lt;br /&gt;
&lt;br /&gt;
Note that the matrix returned by this function is [http://bugs.mtasa.com/view.php?id=6984 not setup correctly for some calculations.]&lt;br /&gt;
&lt;br /&gt;
''For matrix manipulation which goes beyond the basic examples given on this page, see the [[Lua matrix library]].''&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table getElementMatrix ( element theElement )       &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theElement:''' The element which you wish to retrieve the matrix for&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a multi-dimensional array containing a 4x4 matrix. Returns false if the element is not streamed in.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example creates a utility function that turns an offset into a position that is relative to the specified element.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getPositionFromElementOffset(element,offX,offY,offZ)&lt;br /&gt;
	local m = getElementMatrix ( element )  -- Get the matrix&lt;br /&gt;
	local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  -- Apply transform&lt;br /&gt;
	local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]&lt;br /&gt;
	local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]&lt;br /&gt;
	return x, y, z                               -- Return the transformed point&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 3 units to the left of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,3,0,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 2 units in front of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,2,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 1 unit above the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,0,1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example creates some more matrix utility functions&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getMatrixLeft(m)&lt;br /&gt;
        return m[1][1], m[1][2], m[1][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixForward(m)&lt;br /&gt;
        return m[2][1], m[2][2], m[2][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixUp(m)&lt;br /&gt;
        return m[3][1], m[3][2], m[3][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixPosition(m)&lt;br /&gt;
        return m[4][1], m[4][2], m[4][3]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element)  -- Get the matrix&lt;br /&gt;
x,y,z = getMatrixLeft(mat)     -- Get the matrix left direction&lt;br /&gt;
x,y,z = getMatrixForward(mat)  -- Get the matrix forward direction&lt;br /&gt;
x,y,z = getMatrixUp(mat)       -- Get the matrix up direction&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example allows you to get the element matrix of an element that is outside your stream range.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getMatrix(posX, posY, posZ, rotX, rotY, rotZ)&lt;br /&gt;
	local rx, ry, rz = math.rad(rotX), math.rad(rotY), math.rad(rotZ)&lt;br /&gt;
	local matrix = {}&lt;br /&gt;
	matrix[1] = {}&lt;br /&gt;
	matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry)&lt;br /&gt;
	matrix[1][3] = -math.cos(rx)*math.sin(ry)&lt;br /&gt;
	&lt;br /&gt;
	matrix[2] = {}&lt;br /&gt;
	matrix[2][1] = -math.cos(rx)*math.sin(rz)&lt;br /&gt;
	matrix[2][2] = math.cos(rz)*math.cos(rx)&lt;br /&gt;
	matrix[2][3] = math.sin(rx)&lt;br /&gt;
	&lt;br /&gt;
	matrix[3] = {}&lt;br /&gt;
	matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx)&lt;br /&gt;
	matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx)&lt;br /&gt;
	matrix[3][3] = math.cos(rx)*math.cos(ry)&lt;br /&gt;
	&lt;br /&gt;
	matrix[4] = {}&lt;br /&gt;
	matrix[4][1], matrix[4][2], matrix[4][3] = posX, posY, posZ -- this is kinda useless but is used to have the same structure as getElementMatrix&lt;br /&gt;
	&lt;br /&gt;
	return matrix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local posX, posY, posZ = getElementPosition(element)&lt;br /&gt;
local rotX, rotY, rotZ = getElementRotation(element)&lt;br /&gt;
local mat = getMatrix(posX, posY, posZ, rotX, rotY, rotZ) -- this gives the same result as getElementMatrix(element), but also works if the element is not streamed in&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_element_functions}}&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=32988</id>
		<title>GetElementMatrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementMatrix&amp;diff=32988"/>
		<updated>2012-08-30T21:42:03Z</updated>

		<summary type="html">&lt;p&gt;Arezu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function gets an element's transform matrix. This contains 16 float values that multiplied to a point will give you the point transformed. It is most useful for matrix calculations such as calculating offsets. For further information, please refer to a tutorial of matrices in computer graphics programming.&lt;br /&gt;
&lt;br /&gt;
Note that the matrix returned by this function is [http://bugs.mtasa.com/view.php?id=6984 not setup correctly for some calculations.]&lt;br /&gt;
&lt;br /&gt;
''For matrix manipulation which goes beyond the basic examples given on this page, see the [[Lua matrix library]].''&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table getElementMatrix ( element theElement )       &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theElement:''' The element which you wish to retrieve the matrix for&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a multi-dimensional array containing a 4x4 matrix. Returns false if the element is not streamed in.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example creates a utility function that turns an offset into a position that is relative to the specified element.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getPositionFromElementOffset(element,offX,offY,offZ)&lt;br /&gt;
	local m = getElementMatrix ( element )  -- Get the matrix&lt;br /&gt;
	local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  -- Apply transform&lt;br /&gt;
	local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]&lt;br /&gt;
	local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]&lt;br /&gt;
	return x, y, z                               -- Return the transformed point&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 3 units to the left of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,3,0,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 2 units in front of the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,2,0)&lt;br /&gt;
&lt;br /&gt;
-- Get the position of a point 1 unit above the element:&lt;br /&gt;
x,y,z = getPositionFromElementOffset(element,0,0,1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example creates some more matrix utility functions&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getMatrixLeft(m)&lt;br /&gt;
        return m[1][1], m[1][2], m[1][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixForward(m)&lt;br /&gt;
        return m[2][1], m[2][2], m[2][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixUp(m)&lt;br /&gt;
        return m[3][1], m[3][2], m[3][3]&lt;br /&gt;
end&lt;br /&gt;
function getMatrixPosition(m)&lt;br /&gt;
        return m[4][1], m[4][2], m[4][3]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local mat = getElementMatrix(element)  -- Get the matrix&lt;br /&gt;
x,y,z = getMatrixLeft(mat)     -- Get the matrix left direction&lt;br /&gt;
x,y,z = getMatrixForward(mat)  -- Get the matrix forward direction&lt;br /&gt;
x,y,z = getMatrixUp(mat)       -- Get the matrix up direction&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_element_functions}}&lt;/div&gt;</summary>
		<author><name>Arezu</name></author>
	</entry>
</feed>