<?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=Paul+Cortez</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=Paul+Cortez"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Paul_Cortez"/>
	<updated>2026-05-31T20:13:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Hibakeres%C3%A9s&amp;diff=22579</id>
		<title>Hibakeresés</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Hibakeres%C3%A9s&amp;diff=22579"/>
		<updated>2010-03-07T13:10:11Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: isTimer is a MTA function these days&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;While scripting you will often come across problems that are not immediately apparent. This page tries to point out some basic strategies to locate the error.&lt;br /&gt;
&lt;br /&gt;
==Debug console==&lt;br /&gt;
MTA features a built-in debug console that shows debug messages output from MTA functions or from scripts. You can open it by typing ''debugscript x'' in console, while ''x'' is the debug level:&lt;br /&gt;
* '''1:''' only errors&lt;br /&gt;
* '''2:''' errors and warnings&lt;br /&gt;
* '''3:''' errors, warnings and info messages&lt;br /&gt;
Thus, by typing ''debugscript 3'' all messages are visible, that or level 2 are recommended for most occasions. You should have debugscript enabled most of the time you are testing your scripts, this will help you detect typos or other simple issues and solve them easily.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
This example snippet has two errors:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
if (getPlayerName(player) == &amp;quot;Fedor&amp;quot;)&lt;br /&gt;
	outputChatbox(&amp;quot;Hello Fedor&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
When the script this piece of code is in is tried to be loaded, debugscript will output something similiar to this:&lt;br /&gt;
{{Debug info|Loading script failed: C:\&amp;lt;server path&amp;gt;\mods\deathmatch\resources\myResource\script.lua:15: 'then' expected near ´outputChatbox'}}&lt;br /&gt;
This means the script could not be parsed, because there was a syntax error. It shows the path of the script, so you can also see what resource it is in ('myResource' in this case) and of course the name of the script. After the filename it shows the line number and again after that what was wrong. Easy to solve now, we just forgot the 'then' keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
if (getPlayerName(player) == &amp;quot;Fedor&amp;quot;) then&lt;br /&gt;
	outputChatbox(&amp;quot;Hello Fedor&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now the script will load fine and won't output any errors, until a player with the name 'Fedor' enters this section of the script. Then, debugscript will output:&lt;br /&gt;
{{Debug error|C:\&amp;lt;server path&amp;gt;\mods\deathmatch\resources\d\script.lua:15: attempt to call global 'outputChatbox' (a nil value)}}&lt;br /&gt;
This means the called function does not exist, which can be easily explained since the functions' name is ''outputChatBox'' (with a capital ''B''):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
if (getPlayerName(player) == &amp;quot;Fedor&amp;quot;) then&lt;br /&gt;
	outputChatBox(&amp;quot;Hello Fedor&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is of course just an example, there are plenty of other messages and scenarios, but you should get the idea.&lt;br /&gt;
&lt;br /&gt;
==Debug logging==&lt;br /&gt;
You can also turn debug message logging on by editing ''coreconfig.xml'' in your GTA\MTA folder. You should find the following tag:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;debugfile/&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace that with a tag specifying the file you want to log messages to (file path is relative from the GTA folder):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;debugfile&amp;gt;MTA\debugscript.log&amp;lt;/debugfile&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All debug messages will be appended to the specified file from now on. To turn logging off, replace that line with an empty tag again.&lt;br /&gt;
&lt;br /&gt;
==Debug strategies==&lt;br /&gt;
There are several strategies that support finding errors, apart from going through the code of course. Most of them include outputting debug messages, with differing information depending on the situtation.&lt;br /&gt;
&lt;br /&gt;
===Useful functions===&lt;br /&gt;
First of all some functions that may come in handy for debugging.&lt;br /&gt;
* [[outputDebugString]] or [[outputChatBox]] for outputting any information&lt;br /&gt;
* [http://www.lua.org/manual/5.1/manual.html#pdf-tostring tostring()] on a variable to turn it into a string, for example when it contains a boolean value&lt;br /&gt;
* [[getElementType]] to check an MTA Element for its type&lt;br /&gt;
&lt;br /&gt;
===Add debugmessages to check ''if'', ''when'' or ''how often'' a section of code is executed===&lt;br /&gt;
A typical example would be verify whether an ''if''-section is executed or not. To do that, just add any message you will recognize later within the ''if''-section.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
if (variable1 == variable2) then&lt;br /&gt;
	outputDebugString(&amp;quot;entered if&amp;quot;)&lt;br /&gt;
	-- do anything&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another application would be to check when variable values are modified. First search for all occurences of the variable being edited and add a message just beside it.&lt;br /&gt;
&lt;br /&gt;
===Add debugmessages to check the ''value'' of a variable===&lt;br /&gt;
Let's say you want to create a marker, but it doesn't appear at the position you expect it to be. The first thing you might want to do is check if the [[createMarker]] function is executed. But while doing this, you can also check the values being used in the [[createMarker]] function in one run.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
outputChatBox(tostring(x)..&amp;quot; &amp;quot;..tostring(y)..&amp;quot; &amp;quot;..tostring(z))&lt;br /&gt;
createMarker(x,y,z)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This would output all three variables that are used as coordinates for the marker. Assuming you read those from a map file, you can now compare the debug output to the desired values. The [http://www.lua.org/manual/5.1/manual.html#pdf-tostring tostring()] will ensure that the variables' value can be put together as a string, even if it's a boolean value for example.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
Imagine you created a colshape (collision shape) somewhere and you want a player to stay 10 seconds in it, then perform some action.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function colShapeHit(player)&lt;br /&gt;
	-- set a timer to output a message (could as well execute another function)&lt;br /&gt;
	-- store the timer id in a table, using the player as index&lt;br /&gt;
	colshapeTimer[player] = setTimer(outputChatBox,10000,1,&amp;quot;The player stayed 10 seconds in the colshape!&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onColShapeHit&amp;quot;,getRootElement(),colShapeHit)&lt;br /&gt;
&lt;br /&gt;
function colShapeLeave(player)&lt;br /&gt;
	-- kill the timer when the player leaves the colshape&lt;br /&gt;
	killTimer(colshapeTimer[player])&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onColShapeLeave&amp;quot;,getRootElement(),colShapeLeave)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
When a player enters the colshape, debugscript outputs the following message:&lt;br /&gt;
{{Debug error|..[path]: attempt to index global 'colshapeTimer' (a nil value)}}&lt;br /&gt;
This means you tried to index a table that does not exist. In the example above, this is done when storing the timer id in the table. We need to add a check if the table exists and if not create it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function colShapeHit(player)&lt;br /&gt;
	if (colshapeTimer == nil) then&lt;br /&gt;
		colshapeTimer = {}&lt;br /&gt;
	end&lt;br /&gt;
	-- set a timer to output a message (could as well execute another function)&lt;br /&gt;
	-- store the timer id in a table, using the player as index&lt;br /&gt;
	colshapeTimer[player] = setTimer(outputChatBox,10000,1,&amp;quot;The player stayed 10 seconds in the colshape!&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onColShapeHit&amp;quot;,getRootElement(),colShapeHit)&lt;br /&gt;
&lt;br /&gt;
function colShapeLeave(player)&lt;br /&gt;
	-- kill the timer when the player leaves the colshape&lt;br /&gt;
	killTimer(colshapeTimer[player])&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onColShapeLeave&amp;quot;,getRootElement(),colShapeLeave)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we still get a warning when a player enters the colshape, waits for the message and leaves it again:&lt;br /&gt;
&lt;br /&gt;
{{Debug warning|[..]: Bad argument @ 'killTimer' Line: ..}}&lt;br /&gt;
&lt;br /&gt;
Except for that (we will talk about that later) everything seems to work fine. A player enters the colshape, the timer is started, if he stays the message occurs, if he leaves the timer is killed.&lt;br /&gt;
&lt;br /&gt;
===A more inconspicuous error===&lt;br /&gt;
But for some reason the message gets outputted twice when you stay in the colcircle while in a vehicle. Since it would appear some code is executed twice, we add debug messages to check this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function colShapeHit(player)&lt;br /&gt;
	if (colshapeTimer == nil) then&lt;br /&gt;
		colshapeTimer = {}&lt;br /&gt;
	end&lt;br /&gt;
	-- add a debug message&lt;br /&gt;
	outputDebugString(&amp;quot;colShapeHit&amp;quot;)&lt;br /&gt;
	-- set a timer to output a message (could as well execute another function)&lt;br /&gt;
	-- store the timer id in a table, using the player as index&lt;br /&gt;
	colshapeTimer[player] = setTimer(outputChatBox,10000,1,&amp;quot;The player stayed 10 seconds in the colshape!&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onColShapeHit&amp;quot;,getRootElement(),colShapeHit)&lt;br /&gt;
&lt;br /&gt;
function colShapeLeave(player)&lt;br /&gt;
	-- add a debug message&lt;br /&gt;
	outputDebugString(&amp;quot;colShapeLeave&amp;quot;)&lt;br /&gt;
	-- kill the timer when the player leaves the colshape&lt;br /&gt;
	killTimer(colshapeTimer[player])&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onColShapeLeave&amp;quot;,getRootElement(),colShapeLeave)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we notice that both handler functions get executed twice when we are in a vehicle, but only once when we are on-foot. It would appear the vehicle triggers the colshape as well. To confirm this theory, we check the ''player'' variable that '''should''' contain a player element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function colShapeHit(player)&lt;br /&gt;
	if (colshapeTimer == nil) then&lt;br /&gt;
		colshapeTimer = {}&lt;br /&gt;
	end&lt;br /&gt;
	-- add a debug message, with the element type&lt;br /&gt;
	outputDebugString(&amp;quot;colShapeHit &amp;quot;..getElementType(player))&lt;br /&gt;
	-- set a timer to output a message (could as well execute another function)&lt;br /&gt;
	-- store the timer id in a table, using the player as index&lt;br /&gt;
	colshapeTimer[player] = setTimer(outputChatBox,10000,1,&amp;quot;The player stayed 10 seconds in the colshape!&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onColShapeHit&amp;quot;,getRootElement(),colShapeHit)&lt;br /&gt;
&lt;br /&gt;
function colShapeLeave(player)&lt;br /&gt;
	-- add a debug message, with the element type&lt;br /&gt;
	outputDebugString(&amp;quot;colShapeLeave &amp;quot;..getElementType(player))&lt;br /&gt;
	-- kill the timer when the player leaves the colshape&lt;br /&gt;
	killTimer(colshapeTimer[player])&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onColShapeLeave&amp;quot;,getRootElement(),colShapeLeave)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The debug messages tell us that one of the ''player'' variables is a player, the other one a vehicle element. Since we only want to react when a player enters the colshape, we add an ''if'' that will end the execution of the function if it's '''not''' an player element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function colShapeHit(player)&lt;br /&gt;
	if (colshapeTimer == nil) then&lt;br /&gt;
		colshapeTimer = {}&lt;br /&gt;
	end&lt;br /&gt;
	-- add a check for the element type&lt;br /&gt;
	if (getElementType(player) ~= &amp;quot;player&amp;quot;) then return end&lt;br /&gt;
	-- add a debug message, with the element type&lt;br /&gt;
	outputDebugString(&amp;quot;colShapeHit &amp;quot;..getElementType(player))&lt;br /&gt;
	-- set a timer to output a message (could as well execute another function)&lt;br /&gt;
	-- store the timer id in a table, using the player as index&lt;br /&gt;
	colshapeTimer[player] = setTimer(outputChatBox,10000,1,&amp;quot;The player stayed 10 seconds in the colshape!&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onColShapeHit&amp;quot;,getRootElement(),colShapeHit)&lt;br /&gt;
&lt;br /&gt;
function colShapeLeave(player)&lt;br /&gt;
	-- add a check for the element type&lt;br /&gt;
	if (getElementType(player) ~= &amp;quot;player&amp;quot;) then return end&lt;br /&gt;
	-- add a debug message, with the element type&lt;br /&gt;
	outputDebugString(&amp;quot;colShapeLeave &amp;quot;..getElementType(player))&lt;br /&gt;
	-- kill the timer when the player leaves the colshape&lt;br /&gt;
	killTimer(colshapeTimer[player])&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onColShapeLeave&amp;quot;,getRootElement(),colShapeLeave)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now the script should work as desired, but will still output the warning mentioned above. This happens because the timer we try to kill when a player leaves the colshape will not exist anymore when it reached the 10 seconds and is executed. There are different ways to get rid of that warning (since you know that the timer might not exist anymore and you only want to kill it if it is there). One way would be to check if the timer referenced in the table really exists. To do this, we need to use [[isTimer]], which we will use when we kill the timer:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
if (isTimer(colshapeTimer[player])) then&lt;br /&gt;
	killTimer(colshapeTimer[player])&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So the complete working code would be:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function colShapeHit(player)&lt;br /&gt;
	if (colshapeTimer == nil) then&lt;br /&gt;
		colshapeTimer = {}&lt;br /&gt;
	end&lt;br /&gt;
	-- add a check for the element type&lt;br /&gt;
	if (getElementType(player) ~= &amp;quot;player&amp;quot;) then return end&lt;br /&gt;
	-- add a debug message, with the element type&lt;br /&gt;
	outputDebugString(&amp;quot;colShapeHit &amp;quot;..getElementType(player))&lt;br /&gt;
	-- set a timer to output a message (could as well execute another function)&lt;br /&gt;
	-- store the timer id in a table, using the player as index&lt;br /&gt;
	colshapeTimer[player] = setTimer(outputChatBox,10000,1,&amp;quot;The player stayed 10 seconds in the colshape!&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onColShapeHit&amp;quot;,getRootElement(),colShapeHit)&lt;br /&gt;
&lt;br /&gt;
function colShapeLeave(player)&lt;br /&gt;
	-- add a check for the element type&lt;br /&gt;
	if (getElementType(player) ~= &amp;quot;player&amp;quot;) then return end&lt;br /&gt;
	-- add a debug message, with the element type&lt;br /&gt;
	outputDebugString(&amp;quot;colShapeLeave &amp;quot;..getElementType(player))&lt;br /&gt;
	-- kill the timer when the player leaves the colshape&lt;br /&gt;
	if (isTimer(colshapeTimer[player])) then&lt;br /&gt;
		killTimer(colshapeTimer[player])&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onColShapeLeave&amp;quot;,getRootElement(),colShapeLeave)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[it:Guida al Debug]]&lt;br /&gt;
[[Category:Scripting Concepts]]&lt;br /&gt;
[[ru:Debugging]]&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetRadioChannel&amp;diff=22497</id>
		<title>SetRadioChannel</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetRadioChannel&amp;diff=22497"/>
		<updated>2010-02-26T13:52:35Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function sets the currently active radio channel.&lt;br /&gt;
&lt;br /&gt;
This function also works while not in a vehicle.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setRadioChannel ( int ID )             &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''ID:''' The ID of the radio station you want to play.&lt;br /&gt;
&lt;br /&gt;
{{SoundID}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if channel was set successfully, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example adds a command ''setradio'' which can be used to change the current radio station by ID.&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;
addCommandHandler ( &amp;quot;setradio&amp;quot;,&lt;br /&gt;
    function ( command, stationID )&lt;br /&gt;
        local result = setRadioChannel ( tonumber( stationID ) )&lt;br /&gt;
        if result then -- if we had a valid ID&lt;br /&gt;
            outputChatBox ( &amp;quot;Changed your radio station to &amp;quot; .. getRadioChannelName ( tonumber ( stationID ) ) .. &amp;quot;!&amp;quot; )&lt;br /&gt;
        else&lt;br /&gt;
            outputChatBox ( &amp;quot;Invalid radio station ID, valid ones are 0-12.&amp;quot; )&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
{{Client_audio_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetRadioChannel&amp;diff=22496</id>
		<title>SetRadioChannel</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetRadioChannel&amp;diff=22496"/>
		<updated>2010-02-26T13:51:01Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Believe it or not, this DOES work outside of a vehicle&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function sets the currently active radio channel.&lt;br /&gt;
&lt;br /&gt;
This function also works while not in a vehicle.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setRadioChannel ( int ID )             &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''ID:''' The ID of the radio station you want to play.&lt;br /&gt;
&lt;br /&gt;
{{SoundID}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if channel was set successfully, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example adds a command ''setradio'' which can be used to change the current radio station by ID.&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;
addCommandHandler ( &amp;quot;setradio&amp;quot;,&lt;br /&gt;
    function ( command, stationID )&lt;br /&gt;
        local result = setRadioChannel ( tonumber( stationID ) )&lt;br /&gt;
        if result then -- if we had a valid ID&lt;br /&gt;
            outputChatBox ( &amp;quot;Changed your radio station to &amp;quot; .. getRadioChannelName ( tonumber ( stationID ) ) .. &amp;quot;!&amp;quot; )&lt;br /&gt;
        else&lt;br /&gt;
            outputChatBox ( &amp;quot;Invalid radio station ID, valid ones are 0-13.&amp;quot; )&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
{{Client_audio_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GuiGridListSetItemData&amp;diff=22485</id>
		<title>GuiGridListSetItemData</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GuiGridListSetItemData&amp;diff=22485"/>
		<updated>2010-02-25T17:22:24Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: guiGridListSetItemData doesn't accept anything but strings&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function sets a Item Data associated to a grid list item.&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 guiGridListSetItemData ( element gridList, int rowIndex, int columnIndex, string data )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''gridList:''' A gridlist element of the data you wish to set to&lt;br /&gt;
*'''rowIndex:''' The row of the item you wish to set to&lt;br /&gt;
*'''columnIndex:''' The column of the item you wish to set to&lt;br /&gt;
*'''data:''' The data you wish to set to the item.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the data was set successfully, false otherwise&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This page lacks an example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--Add an example here&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{GUI functions}}&lt;br /&gt;
[[Category:Needs Example]]&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnPlayerBan&amp;diff=22484</id>
		<title>OnPlayerBan</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnPlayerBan&amp;diff=22484"/>
		<updated>2010-02-25T16:17:09Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server event}}&lt;br /&gt;
This event is triggered when a player added a ban (like onBan).&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
ban banPointer, player responsibleElement&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''banPointer''': The ban pointer which was added.&lt;br /&gt;
*'''responsibleElement''': The player who added the ban&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[player]] who was banned.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example outputs the responsible element and the banned player's name when a ban takes place.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function outputBan ( banPointer, responsibleElement ) -- Define the banner and the ban pointer in the function.&lt;br /&gt;
	local banner = getPlayerName( responsibleElement ) or &amp;quot;Console&amp;quot; -- Get the banner's name.&lt;br /&gt;
	&lt;br /&gt;
	outputChatBox ( banner ..&amp;quot; has banned &amp;quot;.. getPlayerName( source ) ..&amp;quot;.&amp;quot;, getRootElement(), 255, 0, 0 ) -- Output the ban.&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerBan&amp;quot;, getRootElement(), outputBan ) -- Trigger the function when there is a ban.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{See also/Server event|Player events}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetBans&amp;diff=22483</id>
		<title>GetBans</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetBans&amp;diff=22483"/>
		<updated>2010-02-25T16:07:21Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: This has a lot more chance to work&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function will return a table over all the [[ban]] values in the server.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table getBans ()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a [[table]] over all the [[ban]] pointers.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example lists every ban when somebody types &amp;quot;/bans&amp;quot;. WARNING: This will spam chat (for the player that executed the command) if the server has a lot of bans.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function listBans ()&lt;br /&gt;
	local bansList = getBans() -- Return a table of all the bans.&lt;br /&gt;
	&lt;br /&gt;
	for banID, ban in ipairs ( banList ) do -- For every ban do the following...&lt;br /&gt;
		local nick = getBanNick ( ban ) -- Get the IP of the ban&lt;br /&gt;
		&lt;br /&gt;
		if nick then&lt;br /&gt;
			outputChatBox ( &amp;quot;Ban #&amp;quot; .. banID .. &amp;quot;: &amp;quot; .. nick, source, 255, 0, 0 ) -- Output the ban.&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;bans&amp;quot;, listBans ) -- Add &amp;quot;/bans&amp;quot; as the trigger for the function.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Admin functions}}&lt;br /&gt;
[[ru:getBans]]&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=StartResource&amp;diff=22458</id>
		<title>StartResource</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=StartResource&amp;diff=22458"/>
		<updated>2010-02-22T11:13:17Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: This has more chance of actually working&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function starts a resource either persistently or as a dependency of the current resource. If you start the resource persistently, the resource will run until stopped either using [[stopResource]] or by the server admin. A resource started as a dependency will stop when your resource stops, if no other resources have it as a depdendency. This is the same effect as using an ''include'' in your [[meta.xml]] file.&lt;br /&gt;
&lt;br /&gt;
The function also allows you to specify a number of boolean options. These allow you to disable the loading of various aspects of the resource. This is generally useful for editors rather than for actual gamemodes. It could also be used as a way to preview a resource before enabling the scripting aspects, though this could produce unreliable results. There is no way for a resource to tell if it is being run with any of these booleans set.&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 startResource ( resource resourceToStart, [bool persistent = false, bool startIncludedResources = true, bool loadServerConfigs = true, bool loadMaps = true, bool loadServerScripts = true, bool loadHTML = true, bool loadClientConfigs = true, bool loadClientScripts = true, bool loadFiles = true] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''resourceToStart:''' The resource that should be started.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''persistent:''' A boolean specifying if the resource should continue to run even after this resource has been stopped or not. If this is ''true'' then the resource will run until another resource or user terminates it or the server shuts down.&lt;br /&gt;
*'''startIncludedResources:''' A boolean specifying if the resource's included/dependant resources will be started.&lt;br /&gt;
*'''loadServerConfigs:''' A boolean specifying if server side config (XML) files should be loaded with the resource.  &lt;br /&gt;
*'''loadMaps:''' A boolean specifying if any .map files will be started with the resource.&lt;br /&gt;
*'''loadServerScripts:''' A boolean specifying if server side script files should be started alongside the resource.&lt;br /&gt;
*'''loadHTML:''' A boolean specifying if HTML files should be started alongside the resource.&lt;br /&gt;
*'''loadClientConfigs:''' A boolean specifying if client configs should be loaded alongside the resource.&lt;br /&gt;
*'''loadClientScripts:''' A boolean specifying if client scripts should be loaded and started alongside the resource.&lt;br /&gt;
*'''loadFiles:''' A boolean specifying if client-side files should be loaded alongside the resource.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the resource has been started successfully, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example starts a specified resource with the command; &amp;quot;/resource-start&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function startTheResource ( thePlayer, command, resource )&lt;br /&gt;
	if ( resource ) then -- Check if they specified a resource name&lt;br /&gt;
		resource = getResourceFromName ( resource ) -- Get the resource&lt;br /&gt;
		&lt;br /&gt;
		local start = startResource ( resource ) -- Start the resource&lt;br /&gt;
		if ( start ) then -- If it was successfully started...&lt;br /&gt;
			outputChatBox ( resource .. &amp;quot; was started successfully.&amp;quot;, thePlayer, 255, 0, 0 )&lt;br /&gt;
		else -- If it wasn't successfully started...&lt;br /&gt;
			outputChatBox ( &amp;quot;This resource doesn't exist.&amp;quot;, thePlayer, 255, 0, 0 )&lt;br /&gt;
		end&lt;br /&gt;
	else -- If they didn't put a resource name...&lt;br /&gt;
		outputChatBox ( &amp;quot;Please specify a resource to start.&amp;quot;, thePlayer, 255, 0, 0 )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;resource-start&amp;quot;, startTheResource ) -- Make it trigger when somebody types &amp;quot;/resource-start&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Resource_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=IsDebugViewActive&amp;diff=22441</id>
		<title>IsDebugViewActive</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsDebugViewActive&amp;diff=22441"/>
		<updated>2010-02-21T09:55:43Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Removed &amp;quot;Needs example&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function returns whether the ingame debug window is visible or not. This is the debugwindow visible using the &amp;quot;debugscript &amp;lt;level&amp;gt;&amp;quot; command.&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 isDebugViewActive ()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the debug view is visible, ''false'' if not.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example makes a /debug command to check if the client's debugscript is on or off.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function checkDebug () -- The function header&lt;br /&gt;
	if ( isDebugViewActive() ) then -- Check if debugscript is active...&lt;br /&gt;
		outputChatBox ( &amp;quot;You currently have debugscript on.&amp;quot; ) -- If it is, output that it is&lt;br /&gt;
	else -- If it returns anything else (that it's not active)...&lt;br /&gt;
		outputChatBox ( &amp;quot;You currently have debugscript off.&amp;quot; ) -- Output that they haven't got it on.&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;debug&amp;quot;, checkDebug ) -- Execute the script when the client types &amp;quot;/debug&amp;quot;&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>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=IsMainMenuActive&amp;diff=22440</id>
		<title>IsMainMenuActive</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsMainMenuActive&amp;diff=22440"/>
		<updated>2010-02-21T09:55:29Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Removed &amp;quot;Needs example&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function returns whether the user is in the mainmenu or not.&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 isMainMenuActive ()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the mainmenu is visible, ''false'' if not.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example check if the player is afk.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function isLocalPlayerActive ()&lt;br /&gt;
   if isMainMenuActive() then&lt;br /&gt;
      setElementData(getLocalPlayer(),&amp;quot;status&amp;quot;,&amp;quot;afk&amp;quot;)&lt;br /&gt;
   else&lt;br /&gt;
      setElementData(getLocalPlayer(),&amp;quot;status&amp;quot;,&amp;quot;playing&amp;quot;)&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;
{{GUI_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetPedRotation&amp;diff=22342</id>
		<title>GetPedRotation</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetPedRotation&amp;diff=22342"/>
		<updated>2010-01-30T10:25:05Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Undo revision 22341 by Sebassje (Talk) - Revision doesn't make any sense&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
Gets the rotation of a ped.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float getPedRotation ( ped thePed )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed:''' the ped to retrieve the rotation of.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the rotation of the ped, in degrees: 0 means facing north, higher values go counter clockwise. Returns ''false'' if an invalid element was passed.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This code adds a ''getrot'' command to get a player's current rotation.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function outputPlayerRotation ( sourcePlayer )&lt;br /&gt;
	-- if the command was triggered by an ingame player&lt;br /&gt;
	if ( sourcePlayer ) then&lt;br /&gt;
		-- if he is in a vehicle&lt;br /&gt;
		if isPedInVehicle ( sourcePlayer ) then&lt;br /&gt;
			-- store the vehicle element&lt;br /&gt;
			local playerVehicle = getPedOccupiedVehicle ( sourcePlayer )&lt;br /&gt;
			-- and output its rotation&lt;br /&gt;
			local x,y,z = getElementRotation ( playerVehicle )&lt;br /&gt;
			outputChatBox ( &amp;quot;Your vehicle's rotation is: &amp;quot; .. z, sourcePlayer )&lt;br /&gt;
		-- if he is on foot&lt;br /&gt;
		else&lt;br /&gt;
			-- output the player's rotation&lt;br /&gt;
			outputChatBox ( &amp;quot;Your rotation is: &amp;quot; .. getPedRotation ( sourcePlayer ), sourcePlayer )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- register outputPlayerRotation as a handler for the getrot command&lt;br /&gt;
addCommandHandler ( &amp;quot;getrot&amp;quot;, outputPlayerRotation )&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;
{{Ped functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=AttachElements&amp;diff=22334</id>
		<title>AttachElements</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=AttachElements&amp;diff=22334"/>
		<updated>2010-01-27T14:04:29Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Sounds also appear to be compatible - check if the list is complete&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function attaches one element to another, so that the first one follows the second whenever it moves. &lt;br /&gt;
&lt;br /&gt;
If an attempt is made to attach two elements that are already attached the opposite way (eg theElement becomes theAttachToElement and vice versa), the 1st attachment order is automatically detached in favor of the 2nd attachment order. For example, if carA was attached to carB, now carB is attached to carA. Also, an element cannot be attached to two separate elements at one time. For example, two cars can be attached to one single car, but one single car cannot be attached to two separate cars. If you attempt to do this, the existing attachment will automatically be dropped in favor of the new attachment. For example, if carA is asked to attached to carB then carC, it is only attached to carC.&lt;br /&gt;
&lt;br /&gt;
This is not compatible with all elements.  The following elements are compatible:&lt;br /&gt;
* [[Marker]]s&lt;br /&gt;
* [[Blip]]s&lt;br /&gt;
* [[Object]]s&lt;br /&gt;
* [[Player]]s&lt;br /&gt;
* [[Vehicle]]s&lt;br /&gt;
* [[Sound]]s&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 attachElements ( element theElement, element theAttachToElement, [ float xPosOffset, float yPosOffset, float zPosOffset, float xRotOffset, float yRotOffset, float zRotOffset ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theElement:''' The element to be attached.&lt;br /&gt;
*'''theAttachToElement:''' The element to attach the first to.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''xPosOffset:''' The x offset, if you want the elements to be a certain distance from one another (default 0).&lt;br /&gt;
*'''yPosOffset:''' The y offset (default 0).&lt;br /&gt;
*'''zPosOffset:''' The z offset (default 0).&lt;br /&gt;
*'''xRotOffset:''' The x rotation offset (default 0).&lt;br /&gt;
*'''yRotOffset:''' The y rotation offset (default 0).&lt;br /&gt;
*'''zRotOffset:''' The z rotation offset (default 0).&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the attaching process was successful, ''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;
'''Example 1:''' This example attaches a marker to the player who steals the Mr. Whoopee:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- create the vehicle&lt;br /&gt;
local vehicleMrWhoopee = createVehicle ( 423, 237.472 -54.225 1.518, 0, 354.488, 0 )&lt;br /&gt;
&lt;br /&gt;
function onMrWhoopeeEnter ( thePlayer, seat, jackedPlayer )&lt;br /&gt;
    outputChatBox ( getPlayerName ( thePlayer ) .. &amp;quot; stole the Whoopee!&amp;quot;, getRootElement(), 255, 0, 0 )&lt;br /&gt;
    -- create the marker to attach&lt;br /&gt;
    local arrowMarker = createMarker ( 0, 0, 0, &amp;quot;arrow&amp;quot;, .75, 255, 0, 0, 170 )&lt;br /&gt;
    -- attach the marker to the player with a vertical offset of 2 units&lt;br /&gt;
    attachElements ( arrowMarker, thePlayer, 0, 0, 2 )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- attach it to an event&lt;br /&gt;
addEventHandler ( &amp;quot;onVehicleEnter&amp;quot;, vehicleMrWhoopee, onMrWhoopeeEnter )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''Example 2:''' This function adds a tank on top of a player (for extra defense):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function tankHat ( source, commandName )&lt;br /&gt;
      local x, y, z = getElementPosition ( source ) --Get the players position&lt;br /&gt;
      local tank = createVehicle ( 432, x, y, z + 5 ) --Create a tank&lt;br /&gt;
      attachElements ( tank, source, 0, 0, 5 ) --Attach the tank to the player.&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;hat&amp;quot;, tankHat )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 3:''' This function adds a tank on top of a player (for extra defense), clientside.  This means it will be invisible to other players.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function tankHat ( commandName )&lt;br /&gt;
      local x, y, z = getElementPosition ( source ) --Get the players position&lt;br /&gt;
      local tank = createVehicle ( 432, x, y, z + 5 ) --Create a tank&lt;br /&gt;
      attachElements ( tank, source, 0, 0, 5 ) --Attach the tank to the player.&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler( &amp;quot;hat&amp;quot;, tankHat )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Element functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CloneElement&amp;diff=22158</id>
		<title>CloneElement</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CloneElement&amp;diff=22158"/>
		<updated>2010-01-03T11:34:04Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: This is more likely to work, and a check can't hurt&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function clones (creates an exact copy of) an already existing element. The root node, and player elements, cannot be cloned. If a player element is a child of an element that is cloned, it will be skipped, along with the elements that exist as a child to the player element.&lt;br /&gt;
&lt;br /&gt;
Players are not the only elements that cannot be cloned. This list also includes remoteclients, and console elements.&lt;br /&gt;
&lt;br /&gt;
The cloned element will be placed on the element tree as a child of the same parent as the cloned element.&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 cloneElement ( element theElement, [ float xPos = 0, float yPos = 0, float zPos = 0, bool cloneChildren = false ] )  &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theElement:''' The element that you wish to clone.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
* '''xPos''': A floating point number representing the X coordinate on the map.&lt;br /&gt;
* '''yPos''': A floating point number representing the Y coordinate on the map.&lt;br /&gt;
* '''zPos''': A floating point number representing the Z coordinate on the map.&lt;br /&gt;
* '''cloneChildren''': A boolean value representing whether or not the element's children will be cloned.&lt;br /&gt;
'''Note: if 'cloneChildren' is true, the position floats will be offsets from the cloned element's position.'''&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the handle of the new cloned element of the parent, ''false'' if invalid arguments were passed.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example clones the vehicle a player is in.  This allows carrying over of the current state of the vehicle, including mods, for example.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function cloneVehicle ( thePlayer, commandName )&lt;br /&gt;
	local occupiedVehicle = getPlayerOccupiedVehicle ( thePlayer ) -- get the player's vehicle&lt;br /&gt;
	if occupiedVehicle then -- If the player is actually in a vehicle&lt;br /&gt;
		local x, y, z = getElementPosition ( occupiedVehicle )   -- get the vehicle's position&lt;br /&gt;
		local clone = cloneElement ( occupiedVehicle, x+5, y, z ) -- create a clone of the vehicle near it&lt;br /&gt;
	else&lt;br /&gt;
		outputChatBox ( &amp;quot;You can't clone a vehicle if you're not in a vehicle&amp;quot;, thePlayer, 255, 0, 0 )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;clone&amp;quot;, cloneVehicle )&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>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&amp;diff=21835</id>
		<title>Template:Useful Functions</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&amp;diff=21835"/>
		<updated>2009-11-06T12:59:01Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Added var_dump to the useful functions list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[callClientFunction]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to call any clientside function from the server's side.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[callServerFunction]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to call any server-side function from the client's side.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[Check]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function checks if it's arguments are of the right types and calls the error-function if one isn't.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[doForAllElements]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function can be used to execute a specified function for all elements of a specified type.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[findRotation]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Takes two points and returns the direction from point A to point B.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[FormatDate]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Formats a date on the basis of a format string and returns it.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getPointFromDistanceRotation]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Finds a point based on a starting point, direction and distance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[GetTimestamp]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» With this function you can get the [http://en.wikipedia.org/wiki/Unix_time UNIX timestamp].&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[IfElse]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Returns one of two values based on a boolean expression.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[IsYearALeapYear]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Checks if the given year is a leap year.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[math.round]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Rounds a number whereas the number of decimals to keep and the method may be set.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[setTableProtected]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Protects a table and makes it read-only.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[string.explode]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function splits a string at a given separator pattern and returns a table with the pieces.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[table.copy]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function copies a whole table and all the tables in that table.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[table.map]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[table.size]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Finds the absolute size of a table.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[var_dump]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;»This function outputs information about one or more variables using outputConsole(). &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Useful Functions]]&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User_talk:Dzzagy&amp;diff=21746</id>
		<title>User talk:Dzzagy</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User_talk:Dzzagy&amp;diff=21746"/>
		<updated>2009-10-16T08:10:07Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Important note to Dzzagy&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;nowiki&amp;gt;*ahem* In case you didn't yet notice, your recent changes are meant to be English. The Russian homepage redirects to it since there's no Russian page for it yet. Only translate pages with the prefix &amp;quot;RU/&amp;quot; to Russian!&amp;lt;/nowiki&amp;gt; --[[User:Paul Cortez|Paul Cortez]] 08:10, 16 October 2009 (UTC)&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetCameraClip&amp;diff=21636</id>
		<title>SetCameraClip</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetCameraClip&amp;diff=21636"/>
		<updated>2009-10-02T15:45:12Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Just made the description a -bit- more useful. Probably needs some correcting.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}} &lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function sets if the camera will &amp;quot;collide&amp;quot; with any objects or vehicles in its way. This means that if object clip is enabled an object is in the way of where the camera actually wants to be, the camera will try to be in front of it. This function can disable that.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This function doesn't fix the issue of camera clip not working on objects out of world bounds.&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 setCameraClip ( bool objects, bool vehicles ) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''objects:''' Sets if you want the camera to clip on objects.&lt;br /&gt;
*'''vehicles:''' Sets if you want the camera to clip on vehicles.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Always returns ''true''.&lt;br /&gt;
&lt;br /&gt;
==Example== &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;
-- TODO&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client camera functions}}&lt;br /&gt;
[[Category:Needs_Example]]&lt;br /&gt;
[[Category:Incomplete]]&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetSlotFromWeapon&amp;diff=21535</id>
		<title>GetSlotFromWeapon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetSlotFromWeapon&amp;diff=21535"/>
		<updated>2009-09-14T18:41:42Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Why is this marked server-only if it also works client-side? D:&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function allows you to identify the weapon slot that a weapon belongs 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;
int getSlotFromWeapon ( int weaponid )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''weaponid:''' The weapon ID to find the weapon slot of.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns an integer representing the given weapon ID's associated weapon slot, ''false'' if the ID was invalid.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This will output to the chatbox what weapon slot a given weapon number belongs to when entered into the console (i.e. 'getWeaponSlot 10').&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function outputWeaponSlot ( source, commandName, weaponID )&lt;br /&gt;
	local weaponSlot = getSlotFromWeapon ( weaponID )&lt;br /&gt;
	&lt;br /&gt;
	if (weaponSlot) then&lt;br /&gt;
	    outputChatBox ( &amp;quot;Weapon ID &amp;quot; .. weaponID ..  &amp;quot; is in weapon slot &amp;quot; .. weaponSlot)&lt;br /&gt;
	else&lt;br /&gt;
	    outputChatBox ( &amp;quot;Invalid weapon ID&amp;quot; )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;getWeaponSlot&amp;quot;, outputWeaponSlot )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
[[Weapons|Weapon IDs]]&lt;br /&gt;
{{Weapon_functions}}&lt;br /&gt;
[[ru:getSlotFromWeapon]]&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Modules/SebasIRC/ircRaw&amp;diff=21530</id>
		<title>Modules/SebasIRC/ircRaw</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Modules/SebasIRC/ircRaw&amp;diff=21530"/>
		<updated>2009-09-13T12:35:28Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Created page with '{{ml_irc}} __NOTOC__ {{ModuleFunction|SebasIRC}}  This function sends a raw message to the IRC server, with which you can perform actions  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; bool ircRaw( s…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ml_irc}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{ModuleFunction|SebasIRC}}&lt;br /&gt;
&lt;br /&gt;
This function sends a raw message to the IRC server, with which you can perform actions&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 ircRaw( string message )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''message :''' String containing a command to make the IRC server perform an action for you.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the message was send successfully, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Example here&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Modules/SebasIRC/Functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Modules/SebasIRC/onIRCRaw&amp;diff=21529</id>
		<title>Modules/SebasIRC/onIRCRaw</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Modules/SebasIRC/onIRCRaw&amp;diff=21529"/>
		<updated>2009-09-13T12:31:48Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Created page with '{{ml_irc}} __NOTOC__  This event triggers when raw data is sent from the IRC server to the module. Thanks to this, scripts can know when something has happened on IRC. (i.e. chat…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ml_irc}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
This event triggers when raw data is sent from the IRC server to the module. Thanks to this, scripts can know when something has happened on IRC. (i.e. chatting)&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string content&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''content''': The raw command that has been sent to the module&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[root element]].&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
[[Category:Needs Example]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Modules/SebasIRC/Events}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CreateMarker&amp;diff=21512</id>
		<title>CreateMarker</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CreateMarker&amp;diff=21512"/>
		<updated>2009-09-12T14:12:56Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: updated as asked on Mantis&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function creates a marker. A marker is a 3D model in the world that can highlight a particular point or area, often used to instruct players where to go to perform actions such as entering buildings.&lt;br /&gt;
&lt;br /&gt;
There are various limits that govern the maximum number of each type that can be visible at once. These are:&lt;br /&gt;
* Coronas: 32&lt;br /&gt;
* Checkpoints, Rings, Cylinders and Arrows combined: 32&lt;br /&gt;
&lt;br /&gt;
You are able to create as many markers as you wish (memory and element limit permitting), but the player will only be able to see the nearest ones up to the limit.&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;
marker createMarker ( float x, float y, float z, [string theType, float size, int r, int g, int b, int a, visibleTo = getRootElement()] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''x''': A floating point number representing the X coordinate on the map.&lt;br /&gt;
* '''y''': A floating point number representing the Y coordinate on the map.&lt;br /&gt;
* '''z''': A floating point number representing the Z coordinate on the map.&lt;br /&gt;
&lt;br /&gt;
===Optional arguments===&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
* '''theType''': The visual type of the marker to be created. Possible values:&lt;br /&gt;
{{Marker_types}}&lt;br /&gt;
* '''size''': The diameter of the marker to be created, in meters.&lt;br /&gt;
* '''r''': An integer number representing the amount of red to use in the colouring of the marker (0 - 255).&lt;br /&gt;
* '''g''': An integer number representing the amount of green to use in the colouring of the marker (0 - 255).&lt;br /&gt;
* '''b''': An integer number representing the amount of blue to use in the colouring of the marker (0 - 255).&lt;br /&gt;
* '''a''': An integer number representing the amount of alpha to use in the colouring of the marker (0 - 255 where 0 is transparent and 255 is opaque).&lt;br /&gt;
* '''visibleTo''': Every element that is a child of this element can see the marker. See [[visibility]].&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
marker createMarker ( float x, float y, float z, [string theType, float size, int r, int g, int b, int a] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''x''': A floating point number representing the X coordinate on the map.&lt;br /&gt;
* '''y''': A floating point number representing the Y coordinate on the map.&lt;br /&gt;
* '''z''': A floating point number representing the Z coordinate on the map.&lt;br /&gt;
&lt;br /&gt;
===Optional arguments===&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
* '''theType''': The visual type of the marker to be created. Possible values:&lt;br /&gt;
{{Marker_types}}&lt;br /&gt;
* '''size''': The diameter of the marker to be created, in meters.&lt;br /&gt;
* '''r''': An integer number representing the amount of red to use in the colouring of the marker (0 - 255).&lt;br /&gt;
* '''g''': An integer number representing the amount of green to use in the colouring of the marker (0 - 255).&lt;br /&gt;
* '''b''': An integer number representing the amount of blue to use in the colouring of the marker (0 - 255).&lt;br /&gt;
* '''a''': An integer number representing the amount of alpha to use in the colouring of the marker (0 - 255 where 0 is transparent and 255 is opaque).&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the [[marker]] element that was created, or ''false'' if the arguments are incorrect.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 1&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example creates a marker next to the player when they type 'createmarker':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- this function is called whenever someone types 'createmarker' in the console:&lt;br /&gt;
function consoleCreateMarker ( thePlayer, commandName )&lt;br /&gt;
   if ( thePlayer ) then&lt;br /&gt;
      local x, y, z = getElementPosition ( thePlayer ) -- get the player's position&lt;br /&gt;
      -- create a cylindrical marker next to the player:&lt;br /&gt;
      local theMarker = createMarker ( x + 2, y + 2, z, &amp;quot;cylinder&amp;quot;, 1.5, 255, 255, 0, 170 )&lt;br /&gt;
      if ( theMarker ) then -- check if the marker was created successfully&lt;br /&gt;
         outputConsole ( &amp;quot;Marker created successfully&amp;quot;, thePlayer )&lt;br /&gt;
      else&lt;br /&gt;
         outputConsole ( &amp;quot;Failed to create marker&amp;quot;, thePlayer )&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end&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;Example 2&amp;quot; class=&amp;quot;both&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
Create a marker at the coordinates 0, 0, 20:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
createMarker ( 0, 0, 20 )&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;
{{Marker functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Resource:Missiontimer&amp;diff=21487</id>
		<title>Resource:Missiontimer</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Resource:Missiontimer&amp;diff=21487"/>
		<updated>2009-09-09T17:53:47Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: We want it to show up on the resource catalogue, don't we?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Resource page}}&lt;br /&gt;
Missiontimer is a resource used to easily create timers that count down or up in your resources.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;deathmatch&amp;quot; gamemode is an example use of missiontimer.  It uses the &amp;quot;createMissionTimer&amp;quot; function to create a timer, and then the onMissionTimerElapsed event to trigger at the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;    g_MissionTimer = exports.missiontimer:createMissionTimer (g_TimeLimit,true,true,0.5,20,true,&amp;quot;default-bold&amp;quot;,1)&lt;br /&gt;
    addEventHandler ( &amp;quot;onMissionTimerElapsed&amp;quot;, g_MissionTimer, onTimeElapsed )&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you use the onTimeElapsed function that you attached to the handler at the end of the timer.&lt;br /&gt;
&lt;br /&gt;
The arguments for createMissionTimer as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;createMissionTimer ( duration, countdown, showCS, x, y, bg, font, scale )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* duration - The time in milliseconds&lt;br /&gt;
* countdown - A bool of whether to countdown or count up.  Setting it to true will count down from the duration, setting it to false will count up to the duration (latter isnt tested yet)&lt;br /&gt;
* showCS - A bool of whether to show Centiseconds.  true shows them, false hides them.  Showing centi seconds means its in the format of MM:SS:CS (e.g. 12:31:10), hiding them means its in the format of MM:SS (12:31)&lt;br /&gt;
* x,y - Position on the screen, this uses &amp;quot;smart positioning&amp;quot;.  It can be relative or absolute - the deathmatch gamemode creates it at 0.5,20.  This means the x value is in the centre, the y is 20pixels from the top.  If you specify a negative value it draws the other way, i.e. -20 would be 20pixels from the bottom rather than the top.  The same can be done for x.&lt;br /&gt;
* bg - Whether to draw the default rounded-rectangle behind the timer.  Setting this to false will hide it&lt;br /&gt;
* font - The font of the timer.  Looks best in default-bold&lt;br /&gt;
* scale - The size of the text/bg.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are also some other exported functions that you may or may not need:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; &lt;br /&gt;
setMissionTimerTime ( missionTimer, time ) --Sets the countdown/countup target time&lt;br /&gt;
getMissionTimerTime ( missionTimer ) --Gets the number currently on the clock&lt;br /&gt;
setMissionTimerFrozen ( missionTimer, frozen )   --Freeze the timer&lt;br /&gt;
isMissionTimerFrozen ( missionTimer )&lt;br /&gt;
 &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To remove a missiontimer from the screen, use [[destroyElement]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Missiontimer is only compatible with MTASA 1.0.&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnPlayerConnect&amp;diff=21457</id>
		<title>OnPlayerConnect</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnPlayerConnect&amp;diff=21457"/>
		<updated>2009-09-07T14:48:53Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server event}}&lt;br /&gt;
This event is triggered when a player attempts to connect to the server.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string playerNick, string playerIP, string playerUsername, string playerSerial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''playerNick''': The player's current nickname.&lt;br /&gt;
*'''playerIP''': The player's current IP.&lt;br /&gt;
*'''playerUsername''': The player's community username.&lt;br /&gt;
*'''playerSerial''': The player's serial number.&lt;br /&gt;
&lt;br /&gt;
==Cancel effect==&lt;br /&gt;
If this event is [[Event system#Canceling|canceled]], the player will be disconnected with an error message saying the reason specified in cancelEvent or &amp;quot;Disconnected: server refused the connection&amp;quot; if none was specified.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;!-- Explain what the example is in a single sentance --&amp;gt;&lt;br /&gt;
This example cancels connection attempts of people who use the nick &amp;quot;Player&amp;quot; or outputs some data about the connecting player otherwise.&lt;br /&gt;
&amp;lt;!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--when a player connects&lt;br /&gt;
function playerConnect (playerNick, playerIP, playerUsername, playerSerial)&lt;br /&gt;
    if playerNick == &amp;quot;Player&amp;quot; then --check if his nick is &amp;quot;Player&amp;quot;&lt;br /&gt;
        cancelEvent(true,&amp;quot;The nick \&amp;quot;Player\&amp;quot; is not allowed, please change it to something else. You can change your nick in Settings menu Multiplayer tab.&amp;quot;) --in that case refuse the connection&lt;br /&gt;
    else&lt;br /&gt;
        --output some data about the player&lt;br /&gt;
        outputChatBox (playerNick..&amp;quot; just connected to the server.&amp;quot;)&lt;br /&gt;
        outputChatBox (&amp;quot;IP: &amp;quot;..playerIP..&amp;quot; Username: &amp;quot;..playerUsername..&amp;quot; Serial: &amp;quot;..playerSerial)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--add the playerConnect function as a handler for onPlayerConnect&lt;br /&gt;
addEventHandler (&amp;quot;onPlayerConnect&amp;quot;, getRootElement(), playerConnect)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{See also/Server event|Player events}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Modules/SebasIRC/ircChangeNick&amp;diff=20862</id>
		<title>Modules/SebasIRC/ircChangeNick</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Modules/SebasIRC/ircChangeNick&amp;diff=20862"/>
		<updated>2009-07-25T21:49:05Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Created page with '{{ml_irc}} __NOTOC__ {{ModuleFunction|SebasIRC}}  Changes the name of your bot.  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; bool ircSay(string newNick) &amp;lt;/syntaxhighlight&amp;gt;  ===Required arguments=== * '''newNi…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ml_irc}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{ModuleFunction|SebasIRC}}&lt;br /&gt;
&lt;br /&gt;
Changes the name of your bot.&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 ircSay(string newNick)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''newNick:''' How you want your bot to be called.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns true if the nick was changed successfully, false otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Example here&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Modules/SebasIRC/Functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Modules/SebasIRC/ircDisconnect&amp;diff=20861</id>
		<title>Modules/SebasIRC/ircDisconnect</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Modules/SebasIRC/ircDisconnect&amp;diff=20861"/>
		<updated>2009-07-25T21:45:04Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Created page with '{{ml_irc}} __NOTOC__ {{ModuleFunction|SebasIRC}}  This function disconnects the server from the IRC server it's connected to.  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; bool ircDisconnect() &amp;lt;/cod…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ml_irc}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{ModuleFunction|SebasIRC}}&lt;br /&gt;
&lt;br /&gt;
This function disconnects the server from the IRC server it's connected 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 ircDisconnect()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if successfully disconnected from the server, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Example here&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Modules/SebasIRC/Functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetElementCollisionsEnabled&amp;diff=20851</id>
		<title>SetElementCollisionsEnabled</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetElementCollisionsEnabled&amp;diff=20851"/>
		<updated>2009-07-25T11:57:52Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}} &lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function can disable or enable an element's collisions. An element without collisions does not interact with the physical environment and remains static.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Note:''' This function has unwanted effects on vehicles with drivers at the moment. &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 setElementCollisionsEnabled ( element theElement, bool enabled ) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theElement:''' The element you wish to set the collisions of&lt;br /&gt;
*'''enabled:''' A boolean to indicate whether collisions are enabled (''true'') or disabled (''false'')&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the collisions were set succesfully, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example disables collisions for all vehicles within a certain radius of a player:&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function disableVehicleCollisionsNearPlayer(thePlayer, maxDistance)&lt;br /&gt;
	local playerX, playerY, playerZ = getElementPosition(thePlayer)&lt;br /&gt;
	local vehicles = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
	for k,v in ipairs(vehicles) do&lt;br /&gt;
		local vehicleX, vehicleY, vehicleZ = getElementPosition(v)&lt;br /&gt;
		-- get the distance between the player and the vehicle:&lt;br /&gt;
		local distance = math.sqrt((vehicleX - playerX)^2 + (vehicleY - playerY)^2 + (vehicleZ - playerZ)^2)&lt;br /&gt;
		if (distance &amp;lt;= maxDistance) then&lt;br /&gt;
			-- disable collisions for the vehicle&lt;br /&gt;
			setElementCollisionsEnabled(v, false)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Element_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User:Paul_Cortez&amp;diff=20819</id>
		<title>User:Paul Cortez</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User:Paul_Cortez&amp;diff=20819"/>
		<updated>2009-07-21T12:09:25Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Replaced content with 'I'm also known as Gamesnert.'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I'm also known as Gamesnert.&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetScreenFromWorldPosition&amp;diff=19814</id>
		<title>GetScreenFromWorldPosition</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetScreenFromWorldPosition&amp;diff=19814"/>
		<updated>2009-06-07T12:19:44Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Added default values for optional arguments.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function gets the screen position of a point in the world. This is useful for attaching 2D gui elements to parts of the world (e.g. players) or detecting if a point is on the screen (though it does not check if it is actually visible, you should use [[processLineOfSight]] for that).&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float float getScreenFromWorldPosition ( float x, float y, float z [, float edgeTolerance=0, bool relative=false] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''x:''' A float value indicating the x position in the world.&lt;br /&gt;
*'''y:''' A float value indicating the y position in the world.&lt;br /&gt;
*'''z:''' A float value indicating the z position in the world.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*'''edgeTolerance:''' A float value indicating the tolerance which is used to calculate the screen position of positions that are slightly off-screen&lt;br /&gt;
*'''relative:''' Bool that indicates if the returned x/y positions are relative to the screen size &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns two ''x'', ''y'' [[float]]s indicating the screen position if successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_world_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetScreenFromWorldPosition&amp;diff=19813</id>
		<title>GetScreenFromWorldPosition</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetScreenFromWorldPosition&amp;diff=19813"/>
		<updated>2009-06-07T12:16:49Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Updated the page a little. Still needs checking I think.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function gets the screen position of a point in the world. This is useful for attaching 2D gui elements to parts of the world (e.g. players) or detecting if a point is on the screen (though it does not check if it is actually visible, you should use [[processLineOfSight]] for that).&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float float getScreenFromWorldPosition ( float x, float y, float z [, float edgeTolerance, bool relative] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''x:''' A float value indicating the x position in the world.&lt;br /&gt;
*'''y:''' A float value indicating the y position in the world.&lt;br /&gt;
*'''z:''' A float value indicating the z position in the world.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*'''edgeTolerance:''' A float value indicating the tolerance which is used to calculate the screen position of positions that are slightly off-screen&lt;br /&gt;
*'''relative:''' Bool that indicates if the returned x/y positions are relative to the screen size &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns two ''x'', ''y'' [[float]]s indicating the screen position if successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_world_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Template:GUI_events&amp;diff=18686</id>
		<title>Template:GUI events</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Template:GUI_events&amp;diff=18686"/>
		<updated>2009-03-20T16:34:23Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Same as previous, but now involves an event added in that same revision&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[onClientGUIClick]]&lt;br /&gt;
*[[onClientGUIDoubleClick]]&lt;br /&gt;
*[[onClientGUIChanged]]&lt;br /&gt;
*[[onClientGUIAccepted]]&lt;br /&gt;
*[[onClientGUIScroll]]&lt;br /&gt;
*[[onClientClick]]&lt;br /&gt;
*[[onClientDoubleClick]]&lt;br /&gt;
*[[onClientMouseEnter]]&lt;br /&gt;
*[[onClientMouseLeave]]&lt;br /&gt;
*[[onClientMouseMove]]&lt;br /&gt;
*[[onClientMouseWheel]]&lt;br /&gt;
*[[onClientCursorMove]]&lt;br /&gt;
*[[onClientGUIMove]]&lt;br /&gt;
*[[onClientGUISize]]&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*[[onClientGUITabSwitch]]&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Template:GUI_functions&amp;diff=18685</id>
		<title>Template:GUI functions</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Template:GUI_functions&amp;diff=18685"/>
		<updated>2009-03-20T16:30:41Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Functions added in r471, but weren't added on the wiki yet.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
* [[guiGetAlpha]]&lt;br /&gt;
* [[guiGetInputEnabled]]&lt;br /&gt;
* [[guiGetPosition]]&lt;br /&gt;
* [[guiGetProperties]]&lt;br /&gt;
* [[guiGetProperty]]&lt;br /&gt;
* [[guiGetScreenSize]]&lt;br /&gt;
* [[guiGetSize]]&lt;br /&gt;
* [[guiGetText]]&lt;br /&gt;
* [[guiGetFont]]&lt;br /&gt;
* [[guiGetVisible]]&lt;br /&gt;
* [[guiGetEnabled]]&lt;br /&gt;
&lt;br /&gt;
* [[guiSetAlpha]]&lt;br /&gt;
* [[guiSetInputEnabled]]&lt;br /&gt;
* [[guiSetPosition]]&lt;br /&gt;
* [[guiSetProperty]]&lt;br /&gt;
* [[guiSetSize]]&lt;br /&gt;
* [[guiSetText]]&lt;br /&gt;
* [[guiSetFont]]&lt;br /&gt;
* [[guiSetVisible]]&lt;br /&gt;
* [[guiSetEnabled]]&lt;br /&gt;
&lt;br /&gt;
* [[guiBringToFront]]&lt;br /&gt;
* [[guiMoveToBack]]&lt;br /&gt;
&lt;br /&gt;
* [[isChatBoxInputActive]]&lt;br /&gt;
* [[isConsoleActive]]&lt;br /&gt;
* [[isDebugViewActive]]&lt;br /&gt;
* [[isMainMenuActive]]&lt;br /&gt;
* [[isMTAWindowActive]]&lt;br /&gt;
* [[isTransferBoxActive]]&lt;br /&gt;
&lt;br /&gt;
===Buttons===&lt;br /&gt;
* [[guiCreateButton]]&lt;br /&gt;
&lt;br /&gt;
===Checkboxes===&lt;br /&gt;
* [[guiCreateCheckBox]]&lt;br /&gt;
* [[guiCheckBoxGetSelected]]&lt;br /&gt;
* [[guiCheckBoxSetSelected]]&lt;br /&gt;
&lt;br /&gt;
===Edit fields===&lt;br /&gt;
* [[guiCreateEdit]]&lt;br /&gt;
{{Deprecated_feature|3|1.0|&lt;br /&gt;
* [[guiEditSetCaratIndex]]&lt;br /&gt;
}}&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
* [[guiEditSetCaretIndex]]&lt;br /&gt;
}}&lt;br /&gt;
* [[guiEditSetMasked]]&lt;br /&gt;
* [[guiEditSetMaxLength]]&lt;br /&gt;
* [[guiEditSetReadOnly]]&lt;br /&gt;
&lt;br /&gt;
===Gridlists===&lt;br /&gt;
* [[guiCreateGridList]]&lt;br /&gt;
* [[guiGridListAutoSizeColumn]]&lt;br /&gt;
* [[guiGridListAddColumn]]&lt;br /&gt;
* [[guiGridListAddRow]]&lt;br /&gt;
* [[guiGridListClear]]&lt;br /&gt;
* [[guiGridListGetItemData]]&lt;br /&gt;
* [[guiGridListGetItemText]]&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
* [[guiGridListGetSelectedCount]]&lt;br /&gt;
* [[guiGridListGetSelectedItems]]&lt;br /&gt;
}}&lt;br /&gt;
* [[guiGridListGetSelectedItem]]&lt;br /&gt;
* [[guiGridListGetRowCount]]&lt;br /&gt;
* [[guiGridListInsertRowAfter]]&lt;br /&gt;
* [[guiGridListRemoveColumn]]&lt;br /&gt;
* [[guiGridListRemoveRow]]&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
* [[guiGridListSetColumnWidth]]&lt;br /&gt;
}}&lt;br /&gt;
* [[guiGridListSetScrollBars]]&lt;br /&gt;
* [[guiGridListSetSortingEnabled]]&lt;br /&gt;
* [[guiGridListSetItemData]]&lt;br /&gt;
* [[guiGridListSetItemText]]&lt;br /&gt;
* [[guiGridListSetSelectedItem]]&lt;br /&gt;
* [[guiGridListSetSelectionMode]]&lt;br /&gt;
&lt;br /&gt;
===Memos===&lt;br /&gt;
* [[guiCreateMemo]]&lt;br /&gt;
{{Deprecated_feature|3|1.0|&lt;br /&gt;
* [[guiMemoSetCaratIndex]]&lt;br /&gt;
}}&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
* [[guiMemoSetCaretIndex]]&lt;br /&gt;
}}&lt;br /&gt;
* [[guiMemoSetReadOnly]]&lt;br /&gt;
&lt;br /&gt;
===Progress bars===&lt;br /&gt;
* [[guiCreateProgressBar]]&lt;br /&gt;
* [[guiProgressBarGetProgress]]&lt;br /&gt;
* [[guiProgressBarSetProgress]]&lt;br /&gt;
&lt;br /&gt;
===Radio buttons===&lt;br /&gt;
* [[guiCreateRadioButton]]&lt;br /&gt;
* [[guiRadioButtonGetSelected]]&lt;br /&gt;
* [[guiRadioButtonSetSelected]]&lt;br /&gt;
&lt;br /&gt;
===Scrollbars===&lt;br /&gt;
* [[guiCreateScrollBar]]&lt;br /&gt;
* [[guiScrollBarSetScrollPosition]]&lt;br /&gt;
* [[guiScrollBarGetScrollPosition]]&lt;br /&gt;
&lt;br /&gt;
===Scroll panes===&lt;br /&gt;
* [[guiCreateScrollPane]]&lt;br /&gt;
* [[guiScrollPaneSetScrollBars]]&lt;br /&gt;
* [[guiScrollPaneSetHorizontalScrollPosition]]&lt;br /&gt;
* [[guiScrollPaneSetVerticalScrollPosition]]&lt;br /&gt;
* [[guiScrollPaneGetHorizontalScrollPosition]]&lt;br /&gt;
* [[guiScrollPaneGetVerticalScrollPosition]]&lt;br /&gt;
&lt;br /&gt;
===Static images===&lt;br /&gt;
* [[guiCreateStaticImage]]&lt;br /&gt;
* [[guiStaticImageLoadImage]]&lt;br /&gt;
&lt;br /&gt;
===Tab panels===&lt;br /&gt;
* [[guiCreateTabPanel]]&lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
* [[guiSetSelectedTab]]&lt;br /&gt;
* [[guiGetSelectedTab]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Tabs===&lt;br /&gt;
* [[guiCreateTab]]&lt;br /&gt;
* [[guiDeleteTab]]&lt;br /&gt;
&lt;br /&gt;
===Text labels===&lt;br /&gt;
* [[guiCreateLabel]]&lt;br /&gt;
* [[guiLabelSetColor]]&lt;br /&gt;
* [[guiLabelSetVerticalAlign]]&lt;br /&gt;
* [[guiLabelSetHorizontalAlign]]&lt;br /&gt;
* [[guiLabelGetTextExtent]]&lt;br /&gt;
* [[guiLabelGetFontHeight]]&lt;br /&gt;
&lt;br /&gt;
===Windows===&lt;br /&gt;
* [[guiCreateWindow]]&lt;br /&gt;
* [[guiWindowSetMovable]]&lt;br /&gt;
* [[guiWindowSetSizable]]&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=IsPlayerNametagShowing&amp;diff=18116</id>
		<title>IsPlayerNametagShowing</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsPlayerNametagShowing&amp;diff=18116"/>
		<updated>2009-01-05T16:12:49Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Also added client-side according to Google Code.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
{{New feature|3|1.0|Serverside only in DP2.x}}&lt;br /&gt;
&amp;lt;!-- Describe in plain english what this function does. Don't go into details, just give an overview --&amp;gt;&lt;br /&gt;
This function will allow you to determine if a player's name tag is currently showing.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool isPlayerNametagShowing ( player thePlayer )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
&amp;lt;!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --&amp;gt;&lt;br /&gt;
*'''thePlayer:''' The player whose current name tag condition you want to check&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
&amp;lt;!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --&amp;gt;&lt;br /&gt;
Returns ''true'' if the player's name tag is being shown, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;!-- Explain what the example is in a single sentance --&amp;gt;&lt;br /&gt;
This example toggles a player's nametag. If no playername is given, it toggles the nametag of the player who entered the command.&lt;br /&gt;
&amp;lt;!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function toggleNametag(sourcePlayer, command, who)&lt;br /&gt;
	local tplayer = sourcePlayer                -- by default, toggle the name tag of the player who issued the command&lt;br /&gt;
	if ( who ) then                             -- if there was a nick entered in the command&lt;br /&gt;
		tplayer = getPlayerFromNick(who)    -- search for the player&lt;br /&gt;
	else&lt;br /&gt;
		whoNick = getClientName(sourcePlayer)&lt;br /&gt;
	end&lt;br /&gt;
	if (tplayer ~= false) then                               -- if the player was found (or no playername was entered)&lt;br /&gt;
		if isPlayerNametagShowing(tplayer) then          -- if the nametag is shown&lt;br /&gt;
			setPlayerNametagShowing(tplayer, false)  -- hide it&lt;br /&gt;
			outputChatBox(who .. &amp;quot;'s nametag is now hidden&amp;quot;, sourcePlayer)  -- output a message to the player who entered the command&lt;br /&gt;
		else                                             -- if the nametag is not shown&lt;br /&gt;
			setPlayerNametagShowing(tplayer, true)   -- show it&lt;br /&gt;
			outputChatBox(who .. &amp;quot;'s nametag is now showing&amp;quot;, sourcePlayer) -- output a message to the player who entered the command&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		outputChatBox(&amp;quot;Player not found.&amp;quot;, sourcePlayer)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;toggleNametag&amp;quot;, toggleNametag)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&amp;lt;!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --&amp;gt;&lt;br /&gt;
{{Player_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=ProcessLineOfSight&amp;diff=17771</id>
		<title>ProcessLineOfSight</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ProcessLineOfSight&amp;diff=17771"/>
		<updated>2008-10-25T11:43:04Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: It's in pixels, not relative.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function checks if there is anything between 2 points in the world, and if there is, tells you where and what.  The two positions '''must''' be within the local player's draw distance as the collision data is not loaded outside this area.&lt;br /&gt;
&lt;br /&gt;
This function is useful for checking for collisions and for editor-style scripts. If you wish to get an element that's positioned at a particular point on the screen, use this function combined with [[getWorldFromScreenPosition]].&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 float float float element processLineOfSight ( float startX, float startY, float startZ, float endX, float endY, float endZ, [ bool checkBuildings = true, bool checkVehicles = true, bool checkPlayers = true, bool checkObjects = true, bool checkDummies = true, bool seeThroughStuff = false, bool ignoreSomeObjectsForCamera = false, bool shootThroughStuff = false, element ignoredElement = nil ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''startX:''' The start ''x'' position&lt;br /&gt;
*'''startY:''' The start ''y'' position&lt;br /&gt;
*'''startZ:''' The start ''z'' position&lt;br /&gt;
*'''endX:''' The end ''x'' position&lt;br /&gt;
*'''endY:''' The end ''y'' position&lt;br /&gt;
*'''endZ:''' The end ''z'' position&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''checkBuildings:''' Allow the line of sight to be blocked by GTA's internally placed buildings, i.e. the world map.&lt;br /&gt;
*'''checkVehicles:''' Allow the line of sight to be blocked by [[Vehicle|vehicles]].&lt;br /&gt;
*'''checkPlayers:''' Allow the line of sight to be blocked by [[Player|players]].&lt;br /&gt;
*'''checkObjects:''' Allow the line of sight to be blocked by [[Object|objects]].&lt;br /&gt;
*'''checkDummies:''' Allow the line of sight to be blocked by GTA's internal dummies.  These are not used in the current MTA version so this argument can be set to ''false''.&lt;br /&gt;
*'''seeThroughStuff:''' Allow the line of sight to be blocked by translucent game objects, e.g. glass.&lt;br /&gt;
*'''ignoreSomeObjectsForCamera:''' Allow the line of sight to be blocked by certain objects.&lt;br /&gt;
*'''shootThroughStuff:''' Allow the line of sight to be blocked by things that can be shot through&lt;br /&gt;
*'''ignoredElement:''' Allow the line of sight to pass through a certain specified element. &lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
If there is a collision, the function will return ''true'', the collision position and MTA element hit. If no element is hit, the element return value will be ''nil''. If there is no collision the function will return ''false''.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example shows how you can tell what position and element the camera is looking at, up to 50 units away.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local w, h = guiGetScreenSize ()&lt;br /&gt;
local tx, ty, tz = getWorldFromScreenPosition ( w/2, h/2, 50 )&lt;br /&gt;
local px, py, pz = getCameraPosition()&lt;br /&gt;
hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, tx, ty, tz )&lt;br /&gt;
if hit then&lt;br /&gt;
    outputChatBox ( &amp;quot;Looking at &amp;quot; .. x .. &amp;quot;, &amp;quot; .. y .. &amp;quot;, &amp;quot; ..  z )&lt;br /&gt;
    if elementHit then&lt;br /&gt;
        outputChatBox ( &amp;quot;Hit element &amp;quot; .. getElementType(elementHit) )&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;
{{Client world functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetWorldFromScreenPosition&amp;diff=17770</id>
		<title>GetWorldFromScreenPosition</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetWorldFromScreenPosition&amp;diff=17770"/>
		<updated>2008-10-25T11:39:55Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: It's in pixels, it's not relative.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}} &lt;br /&gt;
This function allows you to retrieve the world position corresponding to the 2D position on the screen, at a certain depth.&lt;br /&gt;
&lt;br /&gt;
If you want to detect what element is at a particular point on the screen, use [[processLineOfSight]] between the camera position and the position returned from this function when passed a high depth value (100 or so, depending how far away you want to detect elements at).&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float, float, float getWorldFromScreenPosition ( float x, float y, float depth )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''x:''' A float value indicating the x position on the screen, in pixels.&lt;br /&gt;
*'''y:''' A float value indicating the y position on the screen, in pixels.&lt;br /&gt;
*'''depth:''' A float value indicating the distance from the camera of the point whose coordinates we are retrieving, in units.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns three ''x'', ''y'', ''z'' [[float]]s indicating the world position if successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example binds the local player's &amp;quot;'''i'''&amp;quot; key to a function that creates an explosion in the middle of the screen.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function explosion ()&lt;br /&gt;
  local w, h = guiGetScreenSize ()&lt;br /&gt;
  local x, y, z = getWorldFromScreenPosition ( w/2, h/2, 10 )&lt;br /&gt;
  createExplosion ( x, y, z, 11 )&lt;br /&gt;
end&lt;br /&gt;
bindKey ( &amp;quot;i&amp;quot;, &amp;quot;down&amp;quot;, explosion )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_world_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User:Paul_Cortez&amp;diff=17618</id>
		<title>User:Paul Cortez</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User:Paul_Cortez&amp;diff=17618"/>
		<updated>2008-08-11T18:39:06Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: Like to have me own page. Wondered what happened if I clicked my name. :P&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Information==&lt;br /&gt;
&lt;br /&gt;
Real name: None of your business ^^&lt;br /&gt;
Age: 14&lt;br /&gt;
Also known as: Gamesnert (Paul_Cortez is my RP name ^^)&lt;br /&gt;
&lt;br /&gt;
==Current employment==&lt;br /&gt;
&lt;br /&gt;
IRL: Nothing really&lt;br /&gt;
Scripting for: VNRP and on requests, topics and ofcourse for myself. But those scripts '''can''' go to VNRP or online too.&lt;br /&gt;
&lt;br /&gt;
==Scripting==&lt;br /&gt;
&lt;br /&gt;
If I rate MYSELF from 1 to 10, I would rate myself... Ehm... A 6. Overall I'm not extremely good, it's just a hobby. :P&lt;br /&gt;
&lt;br /&gt;
I don't have any extremely special scripts. I more am a kind of: &amp;quot;Make what someone needs and that's quite it&amp;quot; kind of guy, and do not script too difficult things.&lt;br /&gt;
&lt;br /&gt;
What I have done:&lt;br /&gt;
 -I made a script to make Parachutes and Sweepers more useful with a &amp;quot;Mine system&amp;quot;. Parachutes drop 'em, Sweepers sweep 'em. ^^&lt;br /&gt;
 -I made a few missions scripts for VNRP, making the 3rd right now.&lt;br /&gt;
 -I also made something else for VNRP, but am not allowed to tell what. :D&lt;br /&gt;
 -And ofcourse I made alot of other unimportant scripts.&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction&amp;diff=17616</id>
		<title>Scripting Introduction</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction&amp;diff=17616"/>
		<updated>2008-08-10T21:05:14Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources are a key part of MTA. A resource is essentially a folder or zip file that contains a collection of files, plus a meta file that describes to the server how the resource should be loaded and what files it does contain. A resource can be seen as being partly equivalent to a program running in an operating system - it can be started and stopped, and multiple resources can run at once.&lt;br /&gt;
&lt;br /&gt;
Everything that has to do with scripting happens in resources, what a resource does defines if it is a gamemode, a map or anything else. MTA comes with resources that you can optionally use in your gamemodes, such as maplimits to keep playings within a playing area or deathpickups to create weapon pickups.&lt;br /&gt;
&lt;br /&gt;
'''Your first step to begin Lua scripting should be using an Lua editor. This makes scripting much easier. We recommend [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.luaforge.net/ LuaEdit].'''&lt;br /&gt;
&lt;br /&gt;
==Creating a working script==&lt;br /&gt;
We will first learn how to make a basic script that lets the player walk around in the city, step by step.&lt;br /&gt;
===Where are all the scripts?===&lt;br /&gt;
Let's take a look at the script's file structure. Go to your MTA Server folder, and follow the path below:&lt;br /&gt;
&lt;br /&gt;
	/Your MTA Server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
You will see a lot of .zip files, which are the packaged sample scripts shipped with MTA DM. Each file is a &amp;quot;resource&amp;quot;, and they will all be unzipped and loaded by the server when it starts. To create your own resource, simply make a folder with your preferred name. We'll use &amp;quot;myserver&amp;quot; for this tutorial.&lt;br /&gt;
&lt;br /&gt;
Now you should be under this directory: &lt;br /&gt;
&lt;br /&gt;
	/Your MTA Server/modes/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identifying your resource===&lt;br /&gt;
In order to let the server know what's in the resource, a ''meta.xml'' file must be created to list the resource's content. It must be located in the resource's root directory, which is the &amp;quot;myserver&amp;quot; folder in our case. So create a text file and name it &amp;quot;meta.xml&amp;quot;, and open it with notepad.&lt;br /&gt;
&lt;br /&gt;
Enter the following codes in the ''meta.xml'' file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
     &amp;lt;info author=&amp;quot;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA DM server&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;script src=&amp;quot;script.lua&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In the ''&amp;lt;info /&amp;gt;'' tag, there's a &amp;quot;type&amp;quot; field which indicates that the resource is a ''gamemode'' instead of a regular include or a ''map'', which will be explained later. A gamemode is what you need to make a stand-alone server. &lt;br /&gt;
&lt;br /&gt;
The ''&amp;lt;script /&amp;gt;'' tag indicates the script files contained in the resource, which we will create next.&lt;br /&gt;
===Creating a simple script===&lt;br /&gt;
Note that in the ''&amp;lt;script /&amp;gt;'' tag above, the .lua file is not under another directory. Therefore we'll create the file in the folder as meta.xml. Now you can copy and paste the following code into script.lua:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	local x,y,z&lt;br /&gt;
	x = 1959.55&lt;br /&gt;
	y = -1714.46&lt;br /&gt;
	z = 10&lt;br /&gt;
	spawnPlayer(source, x, y, z)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&amp;quot;, source)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler('onPlayerJoin', getRootElement(), joinHandler)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The script will spawn you at the coordinate(x,y,z) specified above, when you join the game. Note that the ''fadeCamera'' function must be used or the screen will be black. Source indicates who triggered the event. Since a player has joined when the code is triggered, you use source to look which has joined. So it'll spawn that player instead of everyone or a random person. If we have a closer look on [[addEventHandler]], you can see 3 things: 'onPlayerJoin', which indicates when it's triggered. getRootElement(), which shows by what/who it can be triggered. (getRootElement() is everything/everyone) And joinHandler, which indicates the function that has to be triggered after the event is triggered. Other details will be explained later in another example, now let's just run the server and try it out!&lt;br /&gt;
&lt;br /&gt;
===Running the script===&lt;br /&gt;
To get the server started, simply run the executable under the MTA DM directory. A list of server stats will be shown first; note the port number, which you'll need when joining the game. Then the server loads all the resources under the /resource/ directory, and then &amp;quot;ready to accept connections!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before you connect to the server, you must run the gamemode. Type &amp;quot;gamemode myserver&amp;quot; and press Enter. The server will start the gamemode you just created, and will also show any errors and warnings from this point on. Now you can start the MTA DM client, and &amp;quot;Quick Connect&amp;quot; using the IP address of your server and the port number you saw earlier. If all goes well, after a few seconds your character will be walking on the streets of Los Santos.&lt;br /&gt;
&lt;br /&gt;
Next we'll add a command to your script that players can use to spawn a vehicle beside their position. You may skip it and check out more advanced scripting with the [[Map manager|Map Manager]], which continues this tutorial. Another branch from this tutorial is [[Introduction to Scripting GUI]], you may follow it to see how Graphical User Interface in MTA:DM is drawn and scripted.&lt;br /&gt;
&lt;br /&gt;
==Creating a simple command==&lt;br /&gt;
Let's go back to the content of the ''script.lua'' file. As mentioned above, we want to provide a command to create a vehicle beside your current position in the game. Firstly we need to create a function we want to call and a command handler that creates the command the player will be able to enter in the console.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- create a vehicle and stuff&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- create a command handler&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names are clickable in code examples on the wiki and linked to the functions' documentation.''&lt;br /&gt;
&lt;br /&gt;
====About command handlers====&lt;br /&gt;
The first argument of [[addCommandHandler]] is the name of the command the player will be able to enter, the second argument is the function this will call, in this case ''createVehicleForPlayer''.&lt;br /&gt;
&lt;br /&gt;
If you have already experience in scripting, you will know that you call a function like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
functionName(argument1, argument2, argument3, ..)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
functionName(thePlayer, commandName, argument3, ..)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If we have a closer look on the lower example above, we can see argument1 is thePlayer and argument2 the commandName. thePlayer is simply the one who typed the command, so whatever you call it, the variable will contain the player who activated the command. commandName is simply the command they typed. So if they typed &amp;quot;/greet&amp;quot;, this argument will contain &amp;quot;greet&amp;quot;. Argument 3 is something extra the player typed, you'll learn it a little bit further in the tutorial. Never forget that the first 2 arguments are standard arguments, but you can name them to anything you want.&lt;br /&gt;
&lt;br /&gt;
We called the [[addCommandHandler]] function this way already and since ''createVehicleForPlayer'' is a function too, it can be called that way as well. But we are using a command handler for that, which calls it in a similiar manner, internally.&lt;br /&gt;
&lt;br /&gt;
For example: Someone types &amp;quot;createvehicle 468&amp;quot; ingame in the console to spawn a Sanchez, the command handler calls the createVehicleForPlayer function, as '''if''' we would have this line of code in the script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
createVehicleForPlayer(thePlayer,&amp;quot;createvehicle&amp;quot;,&amp;quot;468&amp;quot;) -- thePlayer is the player element of the player who entered the command&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
As we can see, it provides several parameters: the player who called the command, the command he entered and whatever text he had after that, in this case &amp;quot;468&amp;quot; as vehicle id for the Sanchez. The first two parameters are the same with all command handlers, which you can read on the [[addEventHandler]] page. For this fact, you always have to define at least those two parameters to use any after that (for example to process text that was entered after the command, like in our example the vehicle model id).&lt;br /&gt;
&lt;br /&gt;
''Note: You have to add the command handler AFTER you defined the handler function, else it can't find it. The order of execution matters.''&lt;br /&gt;
&lt;br /&gt;
====Writing the function====&lt;br /&gt;
In order to fill the function we created, we need to think about what we have to do:&lt;br /&gt;
* Get the players position, so we know where to spawn the vehicle (we want it to appear right beside the player)&lt;br /&gt;
* Calculate the position we want to spawn the vehicle at (we don't want it to appear in the player)&lt;br /&gt;
* Spawn the vehicle&lt;br /&gt;
* Check if it has been spawned successfully, or output a message&lt;br /&gt;
&lt;br /&gt;
In order to achieve our goals, we have to use several functions. To find function we need to use, we should visit the [[Scripting Functions|Server Functions List]]. First we need a function to get the players position. Since players are Elements, we first jump to the '''Element functions''' where we find the [[getElementPosition]] function. By clicking on the function name in the list, you get to the function description. There we can see the syntax, what it returns and usually an example. The syntax shows us what arguments we can or have to submit.&lt;br /&gt;
&lt;br /&gt;
For [[getElementPosition]], the syntax is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float, float, float getElementPosition ( element theElement )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three ''float'' in front of the function name are the return type. In this case it means the function returns three floating point numbers. (x, y and z) Within the parentheses, you can see what arguments you have to submit. In this case only the element whose position you want to get, which is the player in our example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	-- get the position and put it in the x,y,z variables&lt;br /&gt;
	-- (local means, the variables only exist in the current scope, in this case, the function)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next we want to ensure that the vehicle won't spawn directly in the player, so we add a few units to the ''x'' variable, which will make it spawn east from the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer) -- get the position of the player&lt;br /&gt;
	x = x + 5 -- add 5 units to the x position&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we need another function, one to spawn a vehicle. We once again search for it on the [[Scripting Functions|Server Functions List]], this time - since we are talking about vehicles - in the '''Vehicle functions''' section, where we will choose [[createVehicle]]. In this function's syntax, we only have one return type (which is more common), a vehicle element that points to the vehicle we just created. Also, we see that some arguments are enclosed within [ ] which means that those are optional.&lt;br /&gt;
&lt;br /&gt;
We already have all arguments we need for [[createVehicle]] in our function: The position we just calculated in the ''x,y,z'' variables and the model id that we provided through the command (&amp;quot;createvehicle 468&amp;quot;) and can access in the function as ''vehicleModel'' variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer) -- get the position of the player&lt;br /&gt;
	x = x + 5 -- add 5 units to the x position&lt;br /&gt;
	-- create the vehicle and store the returned vehicle element in the ''createdVehicle'' variable&lt;br /&gt;
	local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Of course this code can be improved in many ways, but at least we want to add a check whether the vehicle was created successfully or not. As we can read on the [[createVehicle]] page under '''Returns''', the function returns ''false'' when it was unable to create the vehicle. Thus, we check the value of the ''createVehicle'' variable.&lt;br /&gt;
&lt;br /&gt;
Now we have our complete script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer) -- get the position of the player&lt;br /&gt;
	x = x + 5 -- add 5 units to the x position&lt;br /&gt;
	local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z)&lt;br /&gt;
	-- check if the return value was ''false''&lt;br /&gt;
	if (createdVehicle == false) then&lt;br /&gt;
		-- if so, output a message to the chatbox, but only to this player.&lt;br /&gt;
		outputChatBox(&amp;quot;Failed to create vehicle.&amp;quot;,thePlayer)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, we introduced another function with [[outputChatBox]]. By now, you should be able to explore the function's documentation page yourself. For more advanced scripting, please check out the [[Map manager|Map Manager]].&lt;br /&gt;
&lt;br /&gt;
==What you need to know==&lt;br /&gt;
You already read some things about resources, command handlers and finding functions in the documentation in the first paragraph, but there is much more to learn. This section will give you a rather short overview over some of these things, while linking to related pages if possible.&lt;br /&gt;
===Clientside and Serverside scripts===&lt;br /&gt;
You may have already noticed these or similiar terms (Server/Client) somwhere on this wiki, mostly in conjunction with functions. MTA not only supports scripts that run on the server and provide commands (like the one we wrote above) or other features, but also scripts that run on the MTA client the players use to connect to the server. The reason for this is, that some features MTA provides have to be clientside (like a GUI - Graphical User Interface), others should be because they work better and still others are better off to be serverside or just don't work clientside.&lt;br /&gt;
&lt;br /&gt;
Most scripts you will make (gamemodes, maps) will probably be serverside, like the one we wrote in the first section. If you run into something that can't be solved serverside, you will probably have to make it clientside. For a clientside script for example, you would create a ordinary script file (for example called ''client.lua'') and specify it in the meta.xml, like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;client.lua&amp;quot; type=&amp;quot;client&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The ''type'' attribute defaults to 'server', so you only need to specify it for clientside scripts. When you do this, the clientside script will be downloaded to the player's computer once he connects to the server. Read more about [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===More complex resources===&lt;br /&gt;
The previous section showed briefly how to add clientside scripts to the resource, but there is also much more possible. As mentioned at the very top of this page, resources can be pretty much everything. Their purpose is defined by what they do. Let's have some theoretical resources, by looking at the files it contains, the ''meta.xml'' and what they might do:&lt;br /&gt;
&lt;br /&gt;
====First example - A utility script====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
/admin_commands&lt;br /&gt;
	/meta.xml&lt;br /&gt;
	/commands.lua&lt;br /&gt;
	/client.lua&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;Someguy&amp;quot; description=&amp;quot;admin commands&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;commands.lua&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;client.lua&amp;quot; type=&amp;quot;client&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''commands.lua'' provides some admin commands, like banning a player, muting or something else that can be used to admin the server&lt;br /&gt;
* The ''client.lua'' provides a GUI to be able to perform the mentioned actions easily&lt;br /&gt;
&lt;br /&gt;
This example might be running all the time (maybe even auto-started when the server starts) as it's useful during the whole gaming experience and also wont interfere with the gameplay, unless an admin decides to take some action of course.&lt;br /&gt;
&lt;br /&gt;
====Second example - A gamemode====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
/counterstrike&lt;br /&gt;
	/meta.xml&lt;br /&gt;
	/counterstrike.lua&lt;br /&gt;
	/buymenu.lua&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;Someguy&amp;quot; description=&amp;quot;Counterstrike remake&amp;quot; type=&amp;quot;gamemode&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;counterstrike.lua&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;buymenu.lua&amp;quot; type=&amp;quot;client&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''counterstrike.lua'' contains similiar to the following features:&lt;br /&gt;
** Let players choose their team and spawn them&lt;br /&gt;
** Provide them with weapons, targets and instructions (maybe read from a Map, see below)&lt;br /&gt;
** Define the game's rules, e.g. when does the round end, what happens when a player dies&lt;br /&gt;
** .. and maybe some more&lt;br /&gt;
* The ''buymenu.lua'' is a clientside script and creates a menu to buy weapons&lt;br /&gt;
&lt;br /&gt;
This example can be called a gamemode, since it not only intereferes with the gameplay, but actually defines the rules of it. The ''type'' attribute indicates that this example works with the [[Map manager]], yet another resource that was written by the QA Team to manage gamemodes and map loading. It is highly recommended that you base your gamemodes on the techniques it provides.&lt;br /&gt;
&lt;br /&gt;
This also means that the gamemode probably won't run without a map. Gamemodes should always be as generic as possible. An example for a map is stated in the next example.&lt;br /&gt;
&lt;br /&gt;
====Third example - A Map====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
/cs-airport&lt;br /&gt;
	/meta.xml&lt;br /&gt;
	/airport.map&lt;br /&gt;
	/airport.lua&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;Someguy&amp;quot; description=&amp;quot;Counterstrike airport map&amp;quot; type=&amp;quot;map&amp;quot; gamemodes=&amp;quot;counterstrike&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;map src=&amp;quot;airport.map&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;airport.lua&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''airport.map'' in a XML file that provides information about the map to the gamemode, these may include:&lt;br /&gt;
** Where the players should spawn, with what weapons, what teams there are&lt;br /&gt;
** What the targets are&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Provide vehicles&lt;br /&gt;
* The ''airport.lua'' might contain map-specific features, that may include:&lt;br /&gt;
** Opening some door/make something explode when something specific happens&lt;br /&gt;
** Create or move some custom objects, or manipulate objects that are created through the .map file&lt;br /&gt;
** .. anything else map-specific you can think of&lt;br /&gt;
&lt;br /&gt;
As you can see, the ''type'' attribute changed to 'map', telling the [[Map manager]] that this resource is a map, while the ''gamemodes'' attribute tells it for which gamemodes this map is valid, in this case the gamemode from the above example.&lt;br /&gt;
What may come as a surprise is that there is also a script in the Map resource. Of course this is not necessarily needed in a map, but opens a wide range of possibilities for map makers to create their own world within the rules of the gamemode they create it for.&lt;br /&gt;
&lt;br /&gt;
The ''airport.map'' file might look similiar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;map mode=&amp;quot;deathmatch&amp;quot; version=&amp;quot;1.0&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;terrorists&amp;gt;&lt;br /&gt;
		&amp;lt;spawnpoint posX=&amp;quot;2332.23&amp;quot; posY=&amp;quot;-12232.33&amp;quot; posZ=&amp;quot;4.42223&amp;quot; skins=&amp;quot;23-40&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/terrorists&amp;gt;&lt;br /&gt;
	&amp;lt;counterterrorists&amp;gt;&lt;br /&gt;
		&amp;lt;spawnpoint posX=&amp;quot;2334.23443&amp;quot; posY=&amp;quot;-12300.233&amp;quot; posZ=&amp;quot;10.2344&amp;quot; skins=&amp;quot;40-50&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/counterterrorists&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;bomb posX=&amp;quot;23342.23&amp;quot; posY=&amp;quot;&amp;quot; posZ=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;vehicle posX=&amp;quot;&amp;quot; posY=&amp;quot;&amp;quot; posZ=&amp;quot;&amp;quot; model=&amp;quot;602&amp;quot; /&amp;gt;	&lt;br /&gt;
	&amp;lt;vehicle posX=&amp;quot;&amp;quot; posY=&amp;quot;&amp;quot; posZ=&amp;quot;&amp;quot; model=&amp;quot;603&amp;quot; /&amp;gt;	&lt;br /&gt;
&amp;lt;/map&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When a gamemode is started with a map, the map resources is automatically started by the mapmanager and the information it contains can be read by the gamemode resource. When the map changes, the current map resource is stopped and the next map resource is started. For a more in-depth explanation and examples of how map resources are utilized in the main script, please visit the [[Writing Gamemodes]] page.&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
Events are the way MTA tells scripts about things that happen. For example when a player dies, the [[onPlayerWasted]] event is triggered. In order to perform any actions when a player dies, you have to prepare yourself similiar to adding a command handler, as shown in [[#Writing_the_script|the first chapter]].&lt;br /&gt;
&lt;br /&gt;
This example will output a message with the name of the player who died:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function playerDied(totalAmmo, killer, killerWeapon, bodypart)&lt;br /&gt;
	outputChatBox(getClientName(source)..&amp;quot; died!&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerWasted&amp;quot;,getRootElement(),playerDied)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of showing what arguments are needed, the documentation page for Events shows what parameters are passed to the handler function, similiar to the way a [[#About_command_handlers|command handler]] does, just that it is different from event to event. Another important point is the ''source'' variable, that exists in handler functions. It doesn't have to be added to the parameter list of the function, but it still exists. It has a different value from event to event, for player events (as in the example above) it is the player element. As another example, you can take a look at the basic spawning player script in the first section to get an idea how ''source'' is used.&lt;br /&gt;
&lt;br /&gt;
==Where to go from here==&lt;br /&gt;
You should now be familiar with the most basic aspects of MTA scripting and also a bit with the documentation. The [[Main Page]] provides you with links to more information, Tutorials and References that allow a deeper look into the topics you desire to learn about.&lt;br /&gt;
&lt;br /&gt;
From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts.&lt;br /&gt;
&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=XmlNodeGetValue&amp;diff=17615</id>
		<title>XmlNodeGetValue</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=XmlNodeGetValue&amp;diff=17615"/>
		<updated>2008-08-10T20:24:23Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Incomplete]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function is made to be able to read values in XML files. (for example &amp;lt;something&amp;gt;anything&amp;lt;/something&amp;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;
string xmlNodeGetValue ( xmlnode xmlnode )             &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''xmlnode:''' The node of which you need to know the value.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''none:'''&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the value of the node if successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
In this example is shown what xmlNodeSetValue does and how it works: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local xmlFile=xmlLoadFile(&amp;quot;xmlfile.xml&amp;quot;) --Open a file already created&lt;br /&gt;
if xmlFile then --If it's indeed opened:&lt;br /&gt;
        local node=xmlCreateSubNode(xmlFile,&amp;quot;somesubnode&amp;quot;) --Create a new subnode&lt;br /&gt;
        local success=xmlNodeSetValue(node,&amp;quot;somevalue&amp;quot;) --Set the value of it&lt;br /&gt;
                if success then --Check if it was successful&lt;br /&gt;
                        xmlSaveFile(xmlFile) --Save the file&lt;br /&gt;
                end --End what still needs to be ended&lt;br /&gt;
        end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The xml file wil look like: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;somenode&amp;gt;&lt;br /&gt;
        &amp;lt;somesubnode&amp;gt;somevalue&amp;lt;/somesubnode&amp;gt;&lt;br /&gt;
&amp;lt;/somenode&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{FunctionArea_Functions}}&lt;br /&gt;
{{XML_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=XmlNodeSetValue&amp;diff=17614</id>
		<title>XmlNodeSetValue</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=XmlNodeSetValue&amp;diff=17614"/>
		<updated>2008-08-10T20:20:21Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Incomplete]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function is made to be able to assign values in XML files. (for example &amp;lt;something&amp;gt;anything&amp;lt;/something&amp;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;
bool xmlNodeSetValue ( xmlnode xmlnode, string value )            &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''xmlnode:''' The node you want to set the value of.&lt;br /&gt;
*'''value:''' The value you want the node to have.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''none'''&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if successful, false otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
In this example is shown what xmlNodeSetValue does and how it works:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local xmlFile=xmlLoadFile(&amp;quot;xmlfile.xml&amp;quot;) --Open a file already created&lt;br /&gt;
if xmlFile then --If it's indeed opened:&lt;br /&gt;
	local node=xmlCreateSubNode(xmlFile,&amp;quot;somesubnode&amp;quot;) --Create a new subnode&lt;br /&gt;
	local success=xmlNodeSetValue(node,&amp;quot;somevalue&amp;quot;) --Set the value of it&lt;br /&gt;
		if success then --Check if it was successful&lt;br /&gt;
			xmlSaveFile(xmlFile) --Save the file&lt;br /&gt;
		end --End what still needs to be ended&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The xml file wil look like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;somenode&amp;gt;&lt;br /&gt;
	&amp;lt;somesubnode&amp;gt;somevalue&amp;lt;/somesubnode&amp;gt;&lt;br /&gt;
&amp;lt;/somenode&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{FunctionArea_Functions}}&lt;br /&gt;
{{XML_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=XmlNodeSetValue&amp;diff=17613</id>
		<title>XmlNodeSetValue</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=XmlNodeSetValue&amp;diff=17613"/>
		<updated>2008-08-10T20:19:17Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Incomplete]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This fake function is for use with blah &amp;amp; blah and does blahblahblabhalbhl&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 xmlNodeSetValue ( xmlnode xmlnode, string value )            &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''xmlnode:''' The node you want to set the value of.&lt;br /&gt;
*'''value:''' The value you want the node to have.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''none'''&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if successful, false otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
In this example is shown what xmlNodeSetValue does and how it works:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local xmlFile=xmlLoadFile(&amp;quot;xmlfile.xml&amp;quot;) --Open a file already created&lt;br /&gt;
if xmlFile then --If it's indeed opened:&lt;br /&gt;
	local node=xmlCreateSubNode(xmlFile,&amp;quot;somesubnode&amp;quot;) --Create a new subnode&lt;br /&gt;
	local success=xmlNodeSetValue(node,&amp;quot;somevalue&amp;quot;) --Set the value of it&lt;br /&gt;
		if success then --Check if it was successful&lt;br /&gt;
			xmlSaveFile(xmlFile) --Save the file&lt;br /&gt;
		end --End what still needs to be ended&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The xml file wil look like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;somenode&amp;gt;&lt;br /&gt;
	&amp;lt;somesubnode&amp;gt;somevalue&amp;lt;/somesubnode&amp;gt;&lt;br /&gt;
&amp;lt;/somenode&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{FunctionArea_Functions}}&lt;br /&gt;
{{XML_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=XmlNodeSetValue&amp;diff=17612</id>
		<title>XmlNodeSetValue</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=XmlNodeSetValue&amp;diff=17612"/>
		<updated>2008-08-10T20:12:38Z</updated>

		<summary type="html">&lt;p&gt;Paul Cortez: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Incomplete]]&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This fake function is for use with blah &amp;amp; blah and does blahblahblabhalbhl&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 xmlNodeSetValue ( xmlnode xmlnode, string value )            &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''xmlnode:''' The node you want to set the value of.&lt;br /&gt;
*'''value:''' The value you want the node to have.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''none'''&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if successful, false otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example does...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--This line does...&lt;br /&gt;
blabhalbalhb --abababa&lt;br /&gt;
--This line does this...&lt;br /&gt;
mooo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{FunctionArea_Functions}}&lt;br /&gt;
{{XML_functions}}&lt;/div&gt;</summary>
		<author><name>Paul Cortez</name></author>
	</entry>
</feed>