<?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=Dragon</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=Dragon"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Dragon"/>
	<updated>2026-04-15T06:40:15Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetJetpackWeaponEnabled&amp;diff=80560</id>
		<title>SetJetpackWeaponEnabled</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetJetpackWeaponEnabled&amp;diff=80560"/>
		<updated>2024-09-12T11:39:58Z</updated>

		<summary type="html">&lt;p&gt;Dragon: various edits to correct information and to put formatting more in line with similar pages&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function sets a weapon usable while using the Jetpack.&lt;br /&gt;
{{Note|colt 45, sawed-off, tec-9 and uzi are always enabled for the Jetpack and are not affected by this function.}}&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool setJetpackWeaponEnabled ( int weaponID/string weaponName, bool enabled )&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''weaponID/weaponName:''' The ID or weapon name that's being set usable on a Jetpack. Names can be: (Case is ignored)&lt;br /&gt;
{{All Weapon Types}}&lt;br /&gt;
*'''enabled:''' A [[boolean]] representing whether the weapon is enabled or disabled.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns true if successful, or false if invalid arguments are passed.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example enables the M4 to be fired while using a jetpack and announces it in the chat.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;addEventHandler(&amp;quot;onResourceStart&amp;quot;,resourceRoot,function()&lt;br /&gt;
     if setJetpackWeaponEnabled(&amp;quot;31&amp;quot;,true) then&lt;br /&gt;
          outputChatBox(getWeaponNameFromID(31)..&amp;quot; is now enabled for jetpacks!&amp;quot;)&lt;br /&gt;
     end&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example enables the M4, sniper rifle and country rifle to be fired while using a jetpack and announces it in the chat.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local weapons = {&lt;br /&gt;
    31,&lt;br /&gt;
    34,&lt;br /&gt;
    33,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;,resourceRoot,function()&lt;br /&gt;
    for i,v in ipairs(weapons) do&lt;br /&gt;
        if setJetpackWeaponEnabled(v,true) then&lt;br /&gt;
            outputChatBox(getWeaponNameFromID(v)..&amp;quot; is now enabled for jetpacks!&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.3.1|n/a|}}&lt;br /&gt;
==See Also==&lt;br /&gt;
{{World_functions|server}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Template:Shared_utility_functions&amp;diff=80113</id>
		<title>Template:Shared utility functions</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Template:Shared_utility_functions&amp;diff=80113"/>
		<updated>2024-09-05T06:55:25Z</updated>

		<summary type="html">&lt;p&gt;Dragon: added isTimerPaused and setTimerPaused&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[addDebugHook]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[base64Decode]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[base64Encode]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[debugSleep]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[decodeString]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[encodeString]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[fromJSON]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;!--{{New items|3.0159|1.6.0|--&amp;gt;&lt;br /&gt;
{{Added feature/item|1.6.0|1.5.9|21055|&lt;br /&gt;
&amp;lt;li&amp;gt;[[generateKeyPair]]&amp;lt;/li&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;li&amp;gt;[[getColorFromString]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getDevelopmentMode]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getDistanceBetweenPoints2D]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getDistanceBetweenPoints3D]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getEasingValue]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getNetworkStats]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getNetworkUsageData]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getPerformanceStats]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getRealTime]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getTickCount]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getTimerDetails]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getTimers]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getFPSLimit]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getUserdataType]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getVersion]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[gettok]]&amp;lt;/li&amp;gt;&lt;br /&gt;
{{Added feature/item|1.5.9|1.5.8|20788|&lt;br /&gt;
&amp;lt;li&amp;gt;[[isTransferBoxVisible]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[setTransferBoxVisible]]&amp;lt;/li&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;li&amp;gt;[[hash]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[inspect]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[interpolateBetween]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[iprint]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[isOOPEnabled]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[isTimer]]&amp;lt;/li&amp;gt;&lt;br /&gt;
{{New items|3.0161|1.6.0|&lt;br /&gt;
&amp;lt;li&amp;gt;[[isTimerPaused]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[setTimerPaused]]&amp;lt;/li&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;li&amp;gt;[[killTimer]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[md5]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[passwordHash]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[passwordVerify]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[pregFind]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[pregMatch]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[pregReplace]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[removeDebugHook]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[resetTimer]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[setDevelopmentMode]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[setFPSLimit]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[setTimer]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[ref]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[deref]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[sha256]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[split]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[teaDecode]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[teaEncode]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[toJSON]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[tocolor]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getProcessMemoryStats]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[utfChar]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[utfCode]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[utfLen]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[utfSeek]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[utfSub]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Bit_functions}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;[[Category:Functions templates]]&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetTimerPaused&amp;diff=80112</id>
		<title>SetTimerPaused</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetTimerPaused&amp;diff=80112"/>
		<updated>2024-09-05T06:53:56Z</updated>

		<summary type="html">&lt;p&gt;Dragon: Created page with &amp;quot;{{Server client function}} __NOTOC__ {{New feature/item|3.0161|1.6.0|22701|  This function allows you to pause existing running timers and resume existing paused ti...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{New feature/item|3.0161|1.6.0|22701| &lt;br /&gt;
This function allows you to pause existing running timers and resume existing paused timers.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setTimerPaused ( timer theTimer, bool paused )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
{{OOP||[[timer]]:paused||}}&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theTimer:''' The [[timer]] you wish to pause or resume.&lt;br /&gt;
*'''paused:''' Whether you want to pause (''true'') or resume (''false'') the [[timer]].&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the timer was successfully paused or resumed, ''false'' if no such timer existed.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&lt;br /&gt;
This example pauses all current timers from this resource.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Get a table of all current timers from this resource&lt;br /&gt;
local timers = getTimers ( )&lt;br /&gt;
-- Loop through the table of timers&lt;br /&gt;
for timerIndex, timerValue in ipairs( timers ) do&lt;br /&gt;
    -- pause each timer&lt;br /&gt;
    setTimerPaused ( timerValue, true )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Utility functions}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=IsTimerPaused&amp;diff=80111</id>
		<title>IsTimerPaused</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsTimerPaused&amp;diff=80111"/>
		<updated>2024-09-05T06:53:40Z</updated>

		<summary type="html">&lt;p&gt;Dragon: Created page with {{Server client function}} __NOTOC__ {{New feature/item|3.0161|1.6.0|22701| This function allows you to check whether a timer is paused. }} ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; bool isTimerPa...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{New feature/item|3.0161|1.6.0|22701| &lt;br /&gt;
This function allows you to check whether a timer is paused.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool isTimerPaused ( timer theTimer )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
{{OOP||[[timer]]:paused||}}&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theTimer:''' The [[timer]] you wish to check.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the timer is currently paused, ''false'' if not or if no such timer existed.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&lt;br /&gt;
This example pauses all currently running timers and resumes all currently paused timers from this resource.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Get a table of all current timers from this resource&lt;br /&gt;
local timers = getTimers ( )&lt;br /&gt;
-- Loop through the table of timers&lt;br /&gt;
for timerIndex, timerValue in ipairs( timers ) do&lt;br /&gt;
    -- check if each timer is currently paused&lt;br /&gt;
    local isPaused = isTimerPaused( timerValue )&lt;br /&gt;
    -- pause or resume each timer based on its current state&lt;br /&gt;
    setTimerPaused ( timerValue, not isPaused )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Utility functions}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Default_resources&amp;diff=79785</id>
		<title>Default resources</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Default_resources&amp;diff=79785"/>
		<updated>2024-07-08T05:50:26Z</updated>

		<summary type="html">&lt;p&gt;Dragon: added links to gamemode pages&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is related to the [https://github.com/multitheftauto/mtasa-resources mtasa-resources] project, the &amp;lt;strong&amp;gt;Default Lua resources that come with the Multi Theft Auto (MTA) multiplayer mod&amp;lt;/strong&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{Note|This article is currently '''Work In Progress'''}}&lt;br /&gt;
&lt;br /&gt;
== Download ==&lt;br /&gt;
These resources are available for '''download''' as a full ZIP archive on the '''Official Resources''' webpage at https://mirror-cdn.multitheftauto.com/mtasa/resources/. You may also obtain the files by downloading the GitHub Repository as a zip archive or by cloning it to your machine using Git.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
All resources described below can be found in the [https://github.com/multitheftauto/mtasa-resources mtasa-resources official GitHub repository]. To learn about a resource's history and recent changes, view the '''Git Commit History''' available online.&lt;br /&gt;
&lt;br /&gt;
=== [[File:Preferences-system.svg|48px]] Administration ===&lt;br /&gt;
&lt;br /&gt;
===== [[admin]] =====&lt;br /&gt;
MTA's default admin panel. Originally created by lil_Toady.&lt;br /&gt;
&lt;br /&gt;
===== admin2 =====&lt;br /&gt;
A general overhaul to MTA's default admin panel which is currently in development and meant to eventually replace the original admin resource.&lt;br /&gt;
&lt;br /&gt;
===== ip2c =====&lt;br /&gt;
Utility resource to find the country associated with a certain IP-address range.&lt;br /&gt;
&lt;br /&gt;
===== runcode =====&lt;br /&gt;
Runcode allows the user to quickly execute code via the use of an ingame command. Use /run [your code] for server-side or /crun [your code] for client-side code execution. Typically used for testing on development servers, not recommended for production level servers.&lt;br /&gt;
&lt;br /&gt;
=== [[File:Preferences-desktop-wallpaper.svg|48px]] Map Editor ===&lt;br /&gt;
&lt;br /&gt;
===== [[editor]] =====&lt;br /&gt;
MTA's default map editor system, allowing you to create maps for gamemodes.&lt;br /&gt;
&lt;br /&gt;
===== [[edf]] =====&lt;br /&gt;
EDF stands for Editor Definition File. This resource is the core functionality behind .edf files.&lt;br /&gt;
&lt;br /&gt;
=== [[File:Input-gaming.svg|48px]] Gamemodes ===&lt;br /&gt;
&lt;br /&gt;
===== [[resource:assault|assault]] =====&lt;br /&gt;
In assault one team has to fulfill certain tasks within a time limit while the other team has to prevent their opponents from completing them.&lt;br /&gt;
&lt;br /&gt;
===== briefcaserace =====&lt;br /&gt;
In briefcase race multiple teams compete to deliver briefcases to their destination.&lt;br /&gt;
&lt;br /&gt;
===== [[Resource:CTF|ctf]] =====&lt;br /&gt;
In capture the flag two or more teams compete to steal and capture the flags of the opposing teams.&lt;br /&gt;
&lt;br /&gt;
===== ctv =====&lt;br /&gt;
In capture the vehicle two or more teams compete to deliver vehicles to their home base before the opponents.&lt;br /&gt;
&lt;br /&gt;
===== deathmatch =====&lt;br /&gt;
Deathmatch is a free-for-all gamemode where the goal is to reach a certain frag limit before anyone else.&lt;br /&gt;
&lt;br /&gt;
===== fallout =====&lt;br /&gt;
In fallout players compete to stay on top of falling platforms for as long as possible.&lt;br /&gt;
&lt;br /&gt;
===== hay =====&lt;br /&gt;
In hay players attempt reach the top of a tall tower made from moving hay bales.&lt;br /&gt;
&lt;br /&gt;
===== play =====&lt;br /&gt;
MTA's default freeroam gamemode. It will spawn players around certain areas all over San Andreas and spawn in vehicles for them to explore the world with.&lt;br /&gt;
&lt;br /&gt;
===== [[resource:race|race]] =====&lt;br /&gt;
MTA's race gamemode features both checkpoint races and last-man-standing style destruction derbies. Originally created by arc_ with lots of improvements from ccw.&lt;br /&gt;
&lt;br /&gt;
===== [[Resource:Stealth|stealth]] =====&lt;br /&gt;
The stealth gamemode features noise and stealth mechanics as well as many gadgets players can choose from. Two teams compete to be the last one standing. Originally created by slothman and talidan.&lt;br /&gt;
&lt;br /&gt;
===== tdm =====&lt;br /&gt;
A basic team deathmatch mode where two teams compete to reach a given frag limit before the other.&lt;br /&gt;
&lt;br /&gt;
===== tdma =====&lt;br /&gt;
Team death match arena is another team death match gamemode. It functions similarly to 'tdm' but is usually played on smaller, more concealed maps with spawn points establishing a clear frontline separating the teams.&lt;br /&gt;
&lt;br /&gt;
=== [[File:Input-gaming.svg|48px]] Gameplay ===&lt;br /&gt;
&lt;br /&gt;
===== deathpickups =====&lt;br /&gt;
This resource will spawn weapon pickups near player corpses after they died.&lt;br /&gt;
&lt;br /&gt;
===== defaultstats =====&lt;br /&gt;
While running, this resource will make sure to give players maximum stats for stamina, weapon skills and more.&lt;br /&gt;
&lt;br /&gt;
===== freeroam =====&lt;br /&gt;
Freeroam provides players with a simple to use GUI window to do simple things like teleport, spawn vehicles or weapons, select a skin or play animations. It's used by the 'play'-gamemode.&lt;br /&gt;
&lt;br /&gt;
===== gps =====&lt;br /&gt;
GPS is able to calculate and display the quickest road path between two points on the map. Use /path2 [x] [y] [z] with your desired destination coordinates to receive directions on your mini-map.&lt;br /&gt;
&lt;br /&gt;
===== headshot =====&lt;br /&gt;
While this resource is running a single shot to a player's head will result in an instant kill.&lt;br /&gt;
&lt;br /&gt;
===== [[hedit]] =====&lt;br /&gt;
Powerful in-game handling editor to adjust various vehicle handling properties in real-time.&lt;br /&gt;
&lt;br /&gt;
===== [[Resource:Realdriveby|realdriveby]] =====&lt;br /&gt;
Enables advanced drive-bys with more weapons and configurable restrictions. Originally created by talidan.&lt;br /&gt;
&lt;br /&gt;
===== reload =====&lt;br /&gt;
Enables players to reload their current weapon with a configurable (default 'r') key.&lt;br /&gt;
&lt;br /&gt;
===== sfxbrowser =====&lt;br /&gt;
GUI browser to find and play sound effects from GTA:SA's sound banks. After starting the resource use /sfxbrowser to open.&lt;br /&gt;
&lt;br /&gt;
=== [[File:Preferences-system-windows.svg|48px]] Managers ===&lt;br /&gt;
&lt;br /&gt;
===== [[helpmanager]] =====&lt;br /&gt;
A GUI-interface meant to provide a central location for other resources to provide helpful insight on how to use them.&lt;br /&gt;
&lt;br /&gt;
===== [[Resource:mapcycler|mapcycler]] =====&lt;br /&gt;
Enables servers to cycle between select lists of maps and gamemodes automatically.&lt;br /&gt;
&lt;br /&gt;
===== [[votemanager]] =====&lt;br /&gt;
A resource to provide servers with the ability to start and process votes like mapvotes, kickvotes and more.&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
The [https://github.com/multitheftauto/mtasa-resources mtasa-resources] project is open source. Contributions can be done in various ways: not only with code, but also with documentation and bug reporting, for example.&lt;br /&gt;
&lt;br /&gt;
===== Contributing =====&lt;br /&gt;
Everyone is welcome to participate in improving the resource pack. Read more about the development process here: [[Default resources - Contributing]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Development]]&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Default_resources&amp;diff=79784</id>
		<title>Default resources</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Default_resources&amp;diff=79784"/>
		<updated>2024-07-07T17:24:35Z</updated>

		<summary type="html">&lt;p&gt;Dragon: added ip2c; added runcode; added gamemodes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is related to the [https://github.com/multitheftauto/mtasa-resources mtasa-resources] project, the &amp;lt;strong&amp;gt;Default Lua resources that come with the Multi Theft Auto (MTA) multiplayer mod&amp;lt;/strong&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{Note|This article is currently '''Work In Progress'''}}&lt;br /&gt;
&lt;br /&gt;
== Download ==&lt;br /&gt;
These resources are available for '''download''' as a full ZIP archive on the '''Official Resources''' webpage at https://mirror-cdn.multitheftauto.com/mtasa/resources/. You may also obtain the files by downloading the GitHub Repository as a zip archive or by cloning it to your machine using Git.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
All resources described below can be found in the [https://github.com/multitheftauto/mtasa-resources mtasa-resources official GitHub repository]. To learn about a resource's history and recent changes, view the '''Git Commit History''' available online.&lt;br /&gt;
&lt;br /&gt;
=== [[File:Preferences-system.svg|48px]] Administration ===&lt;br /&gt;
&lt;br /&gt;
===== [[admin]] =====&lt;br /&gt;
MTA's default admin panel. Originally created by lil_Toady.&lt;br /&gt;
&lt;br /&gt;
===== admin2 =====&lt;br /&gt;
A general overhaul to MTA's default admin panel which is currently in development and meant to eventually replace the original admin resource.&lt;br /&gt;
&lt;br /&gt;
===== ip2c =====&lt;br /&gt;
Utility resource to find the country associated with a certain IP-address range.&lt;br /&gt;
&lt;br /&gt;
===== runcode =====&lt;br /&gt;
Runcode allows the user to quickly execute code via the use of an ingame command. Use /run [your code] for server-side or /crun [your code] for client-side code execution. Typically used for testing on development servers, not recommended for production level servers.&lt;br /&gt;
&lt;br /&gt;
=== [[File:Preferences-desktop-wallpaper.svg|48px]] Map Editor ===&lt;br /&gt;
&lt;br /&gt;
===== [[editor]] =====&lt;br /&gt;
MTA's default map editor system, allowing you to create maps for gamemodes.&lt;br /&gt;
&lt;br /&gt;
===== [[edf]] =====&lt;br /&gt;
EDF stands for Editor Definition File. This resource is the core functionality behind .edf files.&lt;br /&gt;
&lt;br /&gt;
=== [[File:Input-gaming.svg|48px]] Gamemodes ===&lt;br /&gt;
&lt;br /&gt;
===== assault =====&lt;br /&gt;
In assault one team has to fulfill certain tasks within a time limit while the other team has to prevent their opponents from completing them.&lt;br /&gt;
&lt;br /&gt;
===== briefcaserace =====&lt;br /&gt;
In briefcase race multiple teams compete to deliver briefcases to their destination.&lt;br /&gt;
&lt;br /&gt;
===== ctf =====&lt;br /&gt;
In capture the flag two or more teams compete to steal and capture the flags of the opposing teams.&lt;br /&gt;
&lt;br /&gt;
===== ctv =====&lt;br /&gt;
In capture the vehicle two or more teams compete to deliver vehicles to their home base before the opponents.&lt;br /&gt;
&lt;br /&gt;
===== deathmatch =====&lt;br /&gt;
Deathmatch is a free-for-all gamemode where the goal is to reach a certain frag limit before anyone else.&lt;br /&gt;
&lt;br /&gt;
===== fallout =====&lt;br /&gt;
In fallout players compete to stay on top of falling platforms for as long as possible.&lt;br /&gt;
&lt;br /&gt;
===== hay =====&lt;br /&gt;
In hay players attempt reach the top of a tall tower made from moving hay bales.&lt;br /&gt;
&lt;br /&gt;
===== play =====&lt;br /&gt;
MTA's default freeroam gamemode. It will spawn players around certain areas all over San Andreas and spawn in vehicles for them to explore the world with.&lt;br /&gt;
&lt;br /&gt;
===== race =====&lt;br /&gt;
MTA's race gamemode features both checkpoint races and last-man-standing style destruction derbies. Originally created by arc_ with lots of improvements from ccw.&lt;br /&gt;
&lt;br /&gt;
===== stealth =====&lt;br /&gt;
The stealth gamemode features noise and stealth mechanics as well as many gadgets players can choose from. Two teams compete to be the last one standing. Originally created by slothman and talidan.&lt;br /&gt;
&lt;br /&gt;
===== tdm =====&lt;br /&gt;
A basic team deathmatch mode where two teams compete to reach a given frag limit before the other.&lt;br /&gt;
&lt;br /&gt;
===== tdma =====&lt;br /&gt;
Team death match arena is another team death match gamemode. It functions similarly to 'tdm' but is usually played on smaller, more concealed maps with spawn points establishing a clear frontline separating the teams.&lt;br /&gt;
&lt;br /&gt;
=== [[File:Input-gaming.svg|48px]] Gameplay ===&lt;br /&gt;
&lt;br /&gt;
===== deathpickups =====&lt;br /&gt;
This resource will spawn weapon pickups near player corpses after they died.&lt;br /&gt;
&lt;br /&gt;
===== defaultstats =====&lt;br /&gt;
While running, this resource will make sure to give players maximum stats for stamina, weapon skills and more.&lt;br /&gt;
&lt;br /&gt;
===== freeroam =====&lt;br /&gt;
Freeroam provides players with a simple to use GUI window to do simple things like teleport, spawn vehicles or weapons, select a skin or play animations. It's used by the 'play'-gamemode.&lt;br /&gt;
&lt;br /&gt;
===== gps =====&lt;br /&gt;
GPS is able to calculate and display the quickest road path between two points on the map. Use /path2 [x] [y] [z] with your desired destination coordinates to receive directions on your mini-map.&lt;br /&gt;
&lt;br /&gt;
===== headshot =====&lt;br /&gt;
While this resource is running a single shot to a player's head will result in an instant kill.&lt;br /&gt;
&lt;br /&gt;
===== [[hedit]] =====&lt;br /&gt;
Powerful in-game handling editor to adjust various vehicle handling properties in real-time.&lt;br /&gt;
&lt;br /&gt;
===== [[Resource:Realdriveby|realdriveby]] =====&lt;br /&gt;
Enables advanced drive-bys with more weapons and configurable restrictions. Originally created by talidan.&lt;br /&gt;
&lt;br /&gt;
===== reload =====&lt;br /&gt;
Enables players to reload their current weapon with a configurable (default 'r') key.&lt;br /&gt;
&lt;br /&gt;
===== sfxbrowser =====&lt;br /&gt;
GUI browser to find and play sound effects from GTA:SA's sound banks. After starting the resource use /sfxbrowser to open.&lt;br /&gt;
&lt;br /&gt;
=== [[File:Preferences-system-windows.svg|48px]] Managers ===&lt;br /&gt;
&lt;br /&gt;
===== [[helpmanager]] =====&lt;br /&gt;
A GUI-interface meant to provide a central location for other resources to provide helpful insight on how to use them.&lt;br /&gt;
&lt;br /&gt;
===== [[Resource:mapcycler|mapcycler]] =====&lt;br /&gt;
Enables servers to cycle between select lists of maps and gamemodes automatically.&lt;br /&gt;
&lt;br /&gt;
===== [[votemanager]] =====&lt;br /&gt;
A resource to provide servers with the ability to start and process votes like mapvotes, kickvotes and more.&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
The [https://github.com/multitheftauto/mtasa-resources mtasa-resources] project is open source. Contributions can be done in various ways: not only with code, but also with documentation and bug reporting, for example.&lt;br /&gt;
&lt;br /&gt;
===== Contributing =====&lt;br /&gt;
Everyone is welcome to participate in improving the resource pack. Read more about the development process here: [[Default resources - Contributing]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Development]]&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Default_resources&amp;diff=79750</id>
		<title>Default resources</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Default_resources&amp;diff=79750"/>
		<updated>2024-07-04T08:07:01Z</updated>

		<summary type="html">&lt;p&gt;Dragon: alphabetical order restored&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Work in Progress&amp;lt;/strong&amp;gt; - This page is related to the [https://github.com/multitheftauto/mtasa-resources mtasa-resources] project, the &amp;lt;strong&amp;gt;Default Lua resources that come with the Multi Theft Auto (MTA) multiplayer mod&amp;lt;/strong&amp;gt;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== [[admin]] =====&lt;br /&gt;
MTA's default admin panel. Originally created by lil_Toady.&lt;br /&gt;
&lt;br /&gt;
===== admin2 =====&lt;br /&gt;
A general overhaul to MTA's default admin panel which is currently in development and meant to eventually replace the original admin resource.&lt;br /&gt;
&lt;br /&gt;
===== deathpickups =====&lt;br /&gt;
This resource will spawn weapon pickups near player corpses after they died.&lt;br /&gt;
&lt;br /&gt;
===== defaultstats =====&lt;br /&gt;
While running, this resource will make sure to give players maximum stats for stamina, weapon skills and more.&lt;br /&gt;
&lt;br /&gt;
===== freeroam =====&lt;br /&gt;
MTA's default freeroam gamemode. Will spawn players around certain areas all over San Andreas and spawn in vehicles for them to explore the world with.&lt;br /&gt;
&lt;br /&gt;
===== gps =====&lt;br /&gt;
GPS is able to calculate and display the quickest road path between two points on the map. Use /path2 [x] [y] [z] with your desired destination coordinates to receive directions on your mini-map.&lt;br /&gt;
&lt;br /&gt;
===== headshot =====&lt;br /&gt;
While this resource is running a single shot to a player's head will result in an instant kill.&lt;br /&gt;
&lt;br /&gt;
===== [[hedit]] =====&lt;br /&gt;
Powerful in-game handling editor to adjust various vehicle handling properties in real-time.&lt;br /&gt;
&lt;br /&gt;
===== [[helpmanager]] =====&lt;br /&gt;
A GUI-interface meant to provide a central location for other resources to provide helpful insight on how to use them.&lt;br /&gt;
&lt;br /&gt;
===== [[Resource:mapcycler|mapcycler]] =====&lt;br /&gt;
Enables servers to cycle between select lists of maps and gamemodes automatically.&lt;br /&gt;
&lt;br /&gt;
===== [[Resource:Realdriveby|realdriveby]] =====&lt;br /&gt;
Enables advanced drive-bys with more weapons and configurable restrictions. Originally created by talidan.&lt;br /&gt;
&lt;br /&gt;
===== reload =====&lt;br /&gt;
Enables players to reload their current weapon with a configurable (default 'r') key.&lt;br /&gt;
&lt;br /&gt;
===== sfxbrowser =====&lt;br /&gt;
GUI browser to find and play sound effects from GTA:SA's sound banks. After starting the resource use /sfxbrowser to open.&lt;br /&gt;
&lt;br /&gt;
===== [[votemanager]] =====&lt;br /&gt;
A resource to provide servers with the ability to start and process votes like mapvotes, kickvotes and more.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt;Development&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Everyone is welcome to participate in improving the resource pack. Read more about the development process here: [[Default resources - Contributing]]&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Development]]&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Default_resources&amp;diff=79749</id>
		<title>Default resources</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Default_resources&amp;diff=79749"/>
		<updated>2024-07-04T03:33:29Z</updated>

		<summary type="html">&lt;p&gt;Dragon: added a couple initial entries to spark discussion on formatting, content and phrasing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Work in Progress&amp;lt;/strong&amp;gt; - This page is related to the [https://github.com/multitheftauto/mtasa-resources mtasa-resources] project, the &amp;lt;strong&amp;gt;Default Lua resources that come with the Multi Theft Auto (MTA) multiplayer mod&amp;lt;/strong&amp;gt;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== [[admin]] =====&lt;br /&gt;
MTA's default admin panel. Originally created by lil_Toady.&lt;br /&gt;
&lt;br /&gt;
===== admin2 =====&lt;br /&gt;
A general overhaul to MTA's default admin panel which is currently in development and meant to eventually replace the original admin resource.&lt;br /&gt;
&lt;br /&gt;
===== deathpickups =====&lt;br /&gt;
This resource will spawn weapon pickups near player corpses after they died.&lt;br /&gt;
&lt;br /&gt;
===== defaultstats =====&lt;br /&gt;
While running, this resource will make sure to give players maximum stats for stamina, weapon skills and more.&lt;br /&gt;
&lt;br /&gt;
===== freeroam =====&lt;br /&gt;
MTA's default freeroam gamemode. Will spawn players around certain areas all over San Andreas and spawn in vehicles for them to explore the world with.&lt;br /&gt;
&lt;br /&gt;
===== gps =====&lt;br /&gt;
GPS is able to calculate and display the quickest road path between two points on the map. Use /path2 [x] [y] [z] with your desired destination coordinates to receive directions on your mini-map.&lt;br /&gt;
&lt;br /&gt;
===== headshot =====&lt;br /&gt;
While this resource is running a single shot to a player's head will result in an instant kill.&lt;br /&gt;
&lt;br /&gt;
===== [[hedit]] =====&lt;br /&gt;
Powerful in-game handling editor to adjust various vehicle handling properties in real-time.&lt;br /&gt;
&lt;br /&gt;
===== [[helpmanager]] =====&lt;br /&gt;
A GUI-interface meant to provide a central location for other resources to provide helpful insight on how to use them.&lt;br /&gt;
&lt;br /&gt;
===== [[Resource:mapcycler|mapcycler]] =====&lt;br /&gt;
Enables servers to cycle between select lists of maps and gamemodes automatically.&lt;br /&gt;
&lt;br /&gt;
===== reload =====&lt;br /&gt;
Enables players to reload their current weapon with a configurable (default 'r') key.&lt;br /&gt;
&lt;br /&gt;
===== [[Resource:Realdriveby|realdriveby]] =====&lt;br /&gt;
Enables advanced drive-bys with more weapons and configurable restrictions. Originally created by talidan.&lt;br /&gt;
&lt;br /&gt;
===== sfxbrowser =====&lt;br /&gt;
GUI browser to find and play sound effects from GTA:SA's sound banks. After starting the resource use /sfxbrowser to open.&lt;br /&gt;
&lt;br /&gt;
===== [[votemanager]] =====&lt;br /&gt;
A resource to provide servers with the ability to start and process votes like mapvotes, kickvotes and more.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h1&amp;gt;Development&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Everyone is welcome to participate in improving the resource pack. Read more about the development process here: [[Default resources - Contributing]]&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Development]]&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Talk:OnClientPlayerWeaponFire&amp;diff=79111</id>
		<title>Talk:OnClientPlayerWeaponFire</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Talk:OnClientPlayerWeaponFire&amp;diff=79111"/>
		<updated>2024-04-25T03:45:10Z</updated>

		<summary type="html">&lt;p&gt;Dragon: Created page with &amp;quot;Pending testing whether remote player's projectile weapons (rocket launcher, grenades, etc.) or the camera trigger this event. Local player's definitely do --~~~~&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Pending testing whether remote player's projectile weapons (rocket launcher, grenades, etc.) or the camera trigger this event. Local player's definitely do --[[User:Dragon|Dragon]] ([[User talk:Dragon|talk]]) 03:44, 25 April 2024 (UTC)&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnClientPlayerWeaponFire&amp;diff=79110</id>
		<title>OnClientPlayerWeaponFire</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnClientPlayerWeaponFire&amp;diff=79110"/>
		<updated>2024-04-25T03:37:36Z</updated>

		<summary type="html">&lt;p&gt;Dragon: corrected info to reflect that the local player's projectile weapons or the camera will indeed correctly trigger the event&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client event}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This event is called when a player fires a weapon.  This event does not trigger for melee weapons. Projectile weapons or the camera will only trigger the event if fired by the local player.&lt;br /&gt;
{{Note|This event is only triggered for players that are streamed in}}&lt;br /&gt;
{{Note|This does not trigger for any player's melee weapons or for remote player's projectile weapons or cameras}}&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int weapon, int ammo, int ammoInClip, float hitX, float hitY, float hitZ, element hitElement, float startX, float startY, float startZ&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
*'''weapon''':  an [[int]] representing [[weapons|weapon]] used for firing a shot.&lt;br /&gt;
*'''ammo''': an [[int]] amount of ammo left for this weapon type.&lt;br /&gt;
*'''ammoInClip''': an [[int]] amount of ammo left for this weapon type in clip.&lt;br /&gt;
*'''hitX''', '''hitY''', '''hitZ''': [[float]] world coordinates representing a hit point.&lt;br /&gt;
*'''hitElement''': an [[element]] which was hit by a shot.&lt;br /&gt;
{{New feature/item|3.0131|1.3.1|4311|&lt;br /&gt;
*'''startX''', '''startY''', '''startZ''': [[float]] world coordinates representing the start of the bullet. Note: This is not the gun muzzle.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the streamed in [[player]] who fired the weapon.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example implements custom gunshot sounds.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function playGunfireSound(weaponID)&lt;br /&gt;
	local muzzleX, muzzleY, muzzleZ = getPedWeaponMuzzlePosition(source)&lt;br /&gt;
	local dim = getElementDimension(source)&lt;br /&gt;
	local int = getElementInterior(source)&lt;br /&gt;
	setAmbientSoundEnabled (&amp;quot;gunfire&amp;quot;, false)&lt;br /&gt;
&lt;br /&gt;
	local weaponSounds = {&lt;br /&gt;
		[22] = &amp;quot;sounds/weap/colt45.ogg&amp;quot;,&lt;br /&gt;
		[23] = &amp;quot;sounds/weap/silenced.ogg&amp;quot;,&lt;br /&gt;
		[24] = &amp;quot;sounds/weap/deagle.ogg&amp;quot;,&lt;br /&gt;
		[25] = &amp;quot;sounds/weap/shotgun.ogg&amp;quot;,&lt;br /&gt;
		[26] = &amp;quot;sounds/weap/sawed-off.ogg&amp;quot;,&lt;br /&gt;
		[27] = &amp;quot;sounds/weap/combat shotgun.ogg&amp;quot;,&lt;br /&gt;
		[28] = &amp;quot;sounds/weap/uzi.ogg&amp;quot;,&lt;br /&gt;
		[30] = &amp;quot;sounds/weap/ak-47.ogg&amp;quot;,&lt;br /&gt;
		[31] = &amp;quot;sounds/weap/m4.ogg&amp;quot;,&lt;br /&gt;
		[32] = &amp;quot;sounds/weap/tec9.ogg&amp;quot;,&lt;br /&gt;
		[34] = &amp;quot;sounds/weap/sniper.ogg&amp;quot;,&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if weaponSounds[weaponID] then&lt;br /&gt;
		sound = playSound3D(weaponSounds[weaponID], muzzleX, muzzleY, muzzleZ)&lt;br /&gt;
		setSoundMaxDistance(sound, 90)&lt;br /&gt;
		setElementDimension(sound, dim)&lt;br /&gt;
		setElementInterior(sound, int)&lt;br /&gt;
		setSoundVolume(sound, 0.6)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientPlayerWeaponFire&amp;quot;, root, playGunfireSound)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example sends a warning to the local player if they shoot another player with a minigun.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--First, we create a function for the event handler to use.&lt;br /&gt;
function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement )&lt;br /&gt;
    if weapon == 38 and getElementType(hitElement)==&amp;quot;player&amp;quot; then -- If the player shoots with a minigun, and hits another player...&lt;br /&gt;
         outputChatBox ( &amp;quot;Don't kill people with minigun, it's lame!&amp;quot;, 255, 0, 0 ) -- We output a warning to him.&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
-- Add this as a handler so that the function will be triggered every time the local player fires.&lt;br /&gt;
addEventHandler ( &amp;quot;onClientPlayerWeaponFire&amp;quot;, localPlayer, onClientPlayerWeaponFireFunc )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example makes the Shotgun fire explosive rounds.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement)&lt;br /&gt;
    if (weapon == 25) then -- If the player shoots with a shotgun&lt;br /&gt;
        createExplosion(hitX, hitY, hitZ, 12, true, 0, true) -- Creates a tiny explosion where the bullet hit.&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
-- Add this as a handler so that the function will be triggered every time a player fires.&lt;br /&gt;
addEventHandler(&amp;quot;onClientPlayerWeaponFire&amp;quot;, root, onClientPlayerWeaponFireFunc)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
===Client player events===&lt;br /&gt;
{{Client_player_events}}&lt;br /&gt;
===Client event functions===&lt;br /&gt;
{{Client_event_functions}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedAimTarget&amp;diff=77658</id>
		<title>SetPedAimTarget</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedAimTarget&amp;diff=77658"/>
		<updated>2023-09-21T14:26:58Z</updated>

		<summary type="html">&lt;p&gt;Dragon: /* Example */ fixed a typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function allows you to set a ped's aim target to a specific point. If a ped is within a certain range defined by [[getPedTargetStart]] and [[getPedTargetEnd]] he will be targeted and shot. &lt;br /&gt;
&lt;br /&gt;
''Note: If you wish to make a ped shoot you must use this in conjunction with an equipped weapon and [[setPedControlState]].''&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 setPedAimTarget ( ped thePed, float x, float y, float z )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePed:''' The ped whose target you want to set. Only peds and remote players will work; this function has no effect on the local player.&lt;br /&gt;
*'''x:''' The x coordinate of the aim target point.&lt;br /&gt;
*'''y:''' The y coordinate of the aim target point.&lt;br /&gt;
*'''z:''' The z coordinate of the aim target point.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the function was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
'''Example 1:''' This example creates a ped in the middle of the map and sets its aim target to point north-east.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createPedAndsetHisAimTarget ()&lt;br /&gt;
        local ped = createPed (0, 0, 0, 5 ) -- create a ped, who looks like cj, in the middle of the map&lt;br /&gt;
        setPedAimTarget ( ped, 10, 10, 5 ) -- set the ped's target to a point in North-East&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This example creates a ped at grove street that will shoot at anything that enters a certain marker.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local cj = createPed(0, 2498.5, -1684.0, 13.5, 20) -- create a ped at cjs house in grove street and give it an ak&lt;br /&gt;
givePedWeapon(cj, 30, 3000, true)&lt;br /&gt;
&lt;br /&gt;
local marker = createMarker(2493.0, -1669.0, 13.5, &amp;quot;checkpoint&amp;quot;, 3, 255, 0, 0, 128) -- create a marker and get its associated colshape for later use&lt;br /&gt;
local colshape = getElementColShape(marker)&lt;br /&gt;
&lt;br /&gt;
function renderHandler()&lt;br /&gt;
	local intruder = getElementsWithinColShape(colshape)[2] -- get the second element found within the colshape, because the first one will normally be the marker itself&lt;br /&gt;
	if intruder then&lt;br /&gt;
		local x,y,z = getElementPosition(intruder) -- if an intruder exists, get its position and have the cj ped fire at it&lt;br /&gt;
		setPedAimTarget(cj, x, y, z)&lt;br /&gt;
		setPedControlState(cj, &amp;quot;fire&amp;quot;, true)&lt;br /&gt;
	else&lt;br /&gt;
		setPedControlState(cj, &amp;quot;fire&amp;quot;, false) -- otherwise stop shooting&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, getRootElement(), renderHandler) -- add an event handler to go through the target acquisition procedure every frame&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client ped functions}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedAimTarget&amp;diff=77657</id>
		<title>SetPedAimTarget</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedAimTarget&amp;diff=77657"/>
		<updated>2023-09-21T14:24:27Z</updated>

		<summary type="html">&lt;p&gt;Dragon: /* Example */ Added an additional example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function allows you to set a ped's aim target to a specific point. If a ped is within a certain range defined by [[getPedTargetStart]] and [[getPedTargetEnd]] he will be targeted and shot. &lt;br /&gt;
&lt;br /&gt;
''Note: If you wish to make a ped shoot you must use this in conjunction with an equipped weapon and [[setPedControlState]].''&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 setPedAimTarget ( ped thePed, float x, float y, float z )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePed:''' The ped whose target you want to set. Only peds and remote players will work; this function has no effect on the local player.&lt;br /&gt;
*'''x:''' The x coordinate of the aim target point.&lt;br /&gt;
*'''y:''' The y coordinate of the aim target point.&lt;br /&gt;
*'''z:''' The z coordinate of the aim target point.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the function was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
'''Example 1:''' This example creates a ped in the middle of the map and sets its aim target to be point north-east.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createPedAndsetHisAimTarget ()&lt;br /&gt;
        local ped = createPed (0, 0, 0, 5 ) -- create a ped, who looks like cj, in the middle of the map&lt;br /&gt;
        setPedAimTarget ( ped, 10, 10, 5 ) -- set the ped's target to a point in North-East&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This example creates a ped at grove street that will shoot at anything that enters a certain marker.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local cj = createPed(0, 2498.5, -1684.0, 13.5, 20) -- create a ped at cjs house in grove street and give it an ak&lt;br /&gt;
givePedWeapon(cj, 30, 3000, true)&lt;br /&gt;
&lt;br /&gt;
local marker = createMarker(2493.0, -1669.0, 13.5, &amp;quot;checkpoint&amp;quot;, 3, 255, 0, 0, 128) -- create a marker and get its associated colshape for later use&lt;br /&gt;
local colshape = getElementColShape(marker)&lt;br /&gt;
&lt;br /&gt;
function renderHandler()&lt;br /&gt;
	local intruder = getElementsWithinColShape(colshape)[2] -- get the second element found within the colshape, because the first one will normally be the marker itself&lt;br /&gt;
	if intruder then&lt;br /&gt;
		local x,y,z = getElementPosition(intruder) -- if an intruder exists, get its position and have the cj ped fire at it&lt;br /&gt;
		setPedAimTarget(cj, x, y, z)&lt;br /&gt;
		setPedControlState(cj, &amp;quot;fire&amp;quot;, true)&lt;br /&gt;
	else&lt;br /&gt;
		setPedControlState(cj, &amp;quot;fire&amp;quot;, false) -- otherwise stop shooting&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, getRootElement(), renderHandler) -- add an event handler to go through the target acquisition prodecure every frame&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client ped functions}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User_talk:Quiret&amp;diff=77038</id>
		<title>User talk:Quiret</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User_talk:Quiret&amp;diff=77038"/>
		<updated>2023-06-15T19:02:15Z</updated>

		<summary type="html">&lt;p&gt;Dragon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi, thanks! The [https://wiki.multitheftauto.com/wiki/Where_to_buy_GTASA where to buy page] definitely needed some changes, as its primary purpose (telling people how they can legitimately obtain a compatible copy) got a little lost as time progressed and the game became harder to obtain. The whole Definitive Edition situation made things so much worse. After finally receiving confirmation recently that 'The Trilogy', as I assumed, contains a compatible version I had all the information I needed to reorganize everything and with the help of some feedback from the Developer Discord this is what I came up with. It should hopefully make it very clear to anyone interested in getting into MTA:SA what they can do if they want a legitimate compatible copy. No, I didn't consult any AI text generation for the content, the only AI involvement was me asking ChatGPT about certain keywords for styling, which in the end I used to have the extra little bit of separation between the different 'Products' on the table. Thanks again for your nice comment and your continued efforts on the wiki. --[[User:Dragon|Dragon]] ([[User talk:Dragon|talk]]) 19:01, 15 June 2023 (UTC)&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User_talk:Quiret&amp;diff=77037</id>
		<title>User talk:Quiret</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User_talk:Quiret&amp;diff=77037"/>
		<updated>2023-06-15T19:01:54Z</updated>

		<summary type="html">&lt;p&gt;Dragon: ty&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi, thanks! The [https://wiki.multitheftauto.com/wiki/Where_to_buy_GTASA there to buy page] definitely needed some changes, as its primary purpose (telling people how they can legitimately obtain a compatible copy) got a little lost as time progressed and the game became harder to obtain. The whole Definitive Edition situation made things so much worse. After finally receiving confirmation recently that 'The Trilogy', as I assumed, contains a compatible version I had all the information I needed to reorganize everything and with the help of some feedback from the Developer Discord this is what I came up with. It should hopefully make it very clear to anyone interested in getting into MTA:SA what they can do if they want a legitimate compatible copy. No, I didn't consult any AI text generation for the content, the only AI involvement was me asking ChatGPT about certain keywords for styling, which in the end I used to have the extra little bit of separation between the different 'Products' on the table. Thanks again for your nice comment and your continued efforts on the wiki. --[[User:Dragon|Dragon]] ([[User talk:Dragon|talk]]) 19:01, 15 June 2023 (UTC)&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Where_to_buy_GTASA&amp;diff=76991</id>
		<title>Where to buy GTASA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Where_to_buy_GTASA&amp;diff=76991"/>
		<updated>2023-06-13T17:41:43Z</updated>

		<summary type="html">&lt;p&gt;Dragon: Updated and re-ordered table; added purchase availability; added non-compatibility-warning about The Definitive Edition; added note about Steam or RGL keys from key-resellers; updated wording to be clear and consistent across the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page outlines general version compatibility for Grand Theft Auto: San Andreas with MTA:SA as well as where they can be purchased.&lt;br /&gt;
&lt;br /&gt;
=== Compatibility ===&lt;br /&gt;
&lt;br /&gt;
If a version of Grand Theft Auto: San Andreas marked below as compatible is not working, please try reinstalling MTA:SA. If that doesn't work, follow [https://forum.mtasa.com/topic/11757-patching-your-101-or-200-version-of-gta_saexe/ these instructions]. If that still doesn't work, then please contact us on [https://forum.mtasa.com/forum/83-client/ on the forums], or join the [https://mtasa.com/discord MTA Discord #help-support channel].&lt;br /&gt;
{{Important Note|Grand Theft Auto: San Andreas as part of '''Grand Theft Auto: The Trilogy – The Definitive Edition''' ''(2021)'' is an entirely new release of the game. This version is '''not compatible''' with MTA:SA.}}&lt;br /&gt;
&lt;br /&gt;
=== Obtaining compatible &amp;amp; used copies ===&lt;br /&gt;
&lt;br /&gt;
Officially, the only way to purchase a compatible copy of Grand Theft Auto: San Andreas from Rockstar Games and Take-Two is through the purchase of the classic collection [https://store.rockstargames.com/en/game/buy-grand-theft-auto-the-trilogy '''Grand Theft Auto: The Trilogy''' ''(2005)'' on the Rockstar Store]. The only other two options are either getting a used physical copy through flea-markets and private resellers or by buying a key for a compatible digital version from a key reseller. A prominent example in the EU for buying a used physical copy is [https://ebay.com ebay.com]. By typing in &amp;quot;gta san andreas pc&amp;quot; into the search field you can find plenty of people that still sell the compatible game. Be careful though as buying from untrustworthy resellers such as unknown non-business people does pose risks (for example fake or broken copies). To find a digital key-reseller, using a search engine to find &amp;quot;Grand Theft Auto: San Andreas key&amp;quot; or similar should yield plenty results. Evaluate which sources are trustworthy and check the key will work in your region before you consider a purchase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 900px; text-align: center; table-layout: fixed;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Product&lt;br /&gt;
!Retailer&lt;br /&gt;
!Works with MTA:SA?&lt;br /&gt;
!Available for purchase?&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; |Grand Theft Auto: The Trilogy ''(2005)''&lt;br /&gt;
|[https://store.rockstargames.com/en/game/buy-grand-theft-auto-the-trilogy Rockstar Store]&lt;br /&gt;
|{{Yes}}&lt;br /&gt;
|{{Yes|[https://store.rockstargames.com/en/game/buy-grand-theft-auto-the-trilogy Yes]}}&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; |This is the 2005 collection of the '''3 original classic GTA games'''. It's currently the only version which is both '''compatible''' and '''available for purchase'''.&lt;br /&gt;
|-&lt;br /&gt;
|Steam&lt;br /&gt;
|{{Yes}}&lt;br /&gt;
|{{NoAsterisk}}&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; style=&amp;quot;background: black; height: 1px; padding: 0px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; |Grand Theft Auto: San Andreas&lt;br /&gt;
(Digital copy)&lt;br /&gt;
|Rockstar Store&lt;br /&gt;
|{{Yes}}&lt;br /&gt;
|{{NoAsterisk}}&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; |MTA:SA installer will make this compatible for you (make sure to install the latest version of MTA:SA '''after''' installing the digital GTA version), but without modifying original game files.&lt;br /&gt;
|-&lt;br /&gt;
|[https://store.steampowered.com/app/12120/Grand_Theft_Auto_San_Andreas/ Steam]&lt;br /&gt;
|{{Yes}}&lt;br /&gt;
|{{NoAsterisk}}&lt;br /&gt;
|-&lt;br /&gt;
|[https://www.microsoft.com/en-us/p/grand-theft-auto-san-andreas/9wzdncrfj1zn Windows App Store]&lt;br /&gt;
|{{No}}&lt;br /&gt;
|{{No}}&lt;br /&gt;
|This is a mobile/Xbox &amp;quot;remastered&amp;quot; version of the game ported to PC. '''Will never work with MTA:SA.'''&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; style=&amp;quot;background: black; height: 1px; padding: 0px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
|Grand Theft Auto: San Andreas&lt;br /&gt;
(Used physical copy)&lt;br /&gt;
|Amazon / Ebay / etc. &lt;br /&gt;
[http://www.amazon.com/Grand-Theft-Auto-Andreas-Download/dp/B006YVXGJQ link 1] [https://www.amazon.de/Grand-Theft-Auto-Andreas-DVD-ROM/dp/B00076YSDM/ref=sr_1_1 link 2] [https://www.amazon.com/-/de/dp/B001DUG0NC/ref=sr_1_14 link 3]&lt;br /&gt;
|{{Partial|Unconfirmed (Standard)}}&lt;br /&gt;
|{{Partial|Depending}}&lt;br /&gt;
|For the '''Standard''' edition of the game, if MTA:SA is incompatible, visit [https://forum.mtasa.com/topic/11757-patching-your-101-or-200-version-of-gta_saexe/ this topic] and follow the instructions, or try obtaining a GTA:SA 1.00 No CD - any HOODLUM release will function correctly.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Still available through key resellers. Only consider purchasing from reputable sources and check for region restrictions.&lt;br /&gt;
&lt;br /&gt;
[[hu:Where to buy GTASA]]&lt;br /&gt;
[[es:Dónde comprar GTA: SA]]&lt;br /&gt;
[[pl:Where to buy GTASA]]&lt;br /&gt;
[[ru:Where to buy GTASA]]&lt;br /&gt;
[[uk:Where to buy GTASA]]&lt;br /&gt;
[[tr:GTA:SA Nerden Alınır]]&lt;br /&gt;
[[zh-cn:在那里可以购买GTASA]]&lt;br /&gt;
[[ro:Where to buy GTASA]]&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Template:NoAsterisk&amp;diff=76990</id>
		<title>Template:NoAsterisk</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Template:NoAsterisk&amp;diff=76990"/>
		<updated>2023-06-13T16:53:30Z</updated>

		<summary type="html">&lt;p&gt;Dragon: Created new wiki table template&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;/noinclude&amp;gt;style=&amp;quot;background: SandyBrown; color: black; vertical-align: middle; text-align: {{{align|center}}}; {{{style|}}}&amp;quot;|{{{1|No*}}}&amp;lt;noinclude&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DxDrawMaterialPrimitive3D&amp;diff=76384</id>
		<title>DxDrawMaterialPrimitive3D</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DxDrawMaterialPrimitive3D&amp;diff=76384"/>
		<updated>2023-04-02T19:25:13Z</updated>

		<summary type="html">&lt;p&gt;Dragon: /* Example */ Added an example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}} &lt;br /&gt;
This function draws a 3D primitive shape with material applied to it in the 3D world - rendered for one frame. This should be used in conjunction with [[onClientRender]] in order to display continuously.&lt;br /&gt;
If image file is used, it should ideally have dimensions that are a power of two, to prevent possible blurring.&lt;br /&gt;
Power of two: 2px, 4px, 8px, 16px, 32px, 64px, 128px, 256px, 512px, 1024px...&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 dxDrawMaterialPrimitive3D ( primitiveType pType, mixed material, bool postGUI, table vertice1 [, table vertice2, ...] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
* '''pType:''' Type of primitive to be drawn.&lt;br /&gt;
* '''image:''' Either a [[material]] element or a [[filepath]] of the image which is going to be drawn. (.dds images are also supported). Image files should ideally have dimensions that are a power of two, to prevent possible blurring. Use a texture created with [[dxCreateTexture]] to '''speed up drawing'''.&lt;br /&gt;
* '''postGUI:''' A bool representing whether the line should be drawn on top of or behind any ingame GUI (rendered by CEGUI).&lt;br /&gt;
* '''vertices:''' Tables representing each primitive vertice, required amount of them is determined by primitive type.&lt;br /&gt;
&lt;br /&gt;
==Allowed types==&lt;br /&gt;
[[Image:MTAsa_primitives.png|thumb|240px|Available primitive types.]]&lt;br /&gt;
More info on primitives may be found on [https://msdn.microsoft.com/en-us/library/windows/desktop/bb147291(v=vs.85).aspx this MSDN site] &lt;br /&gt;
* '''pointlist:''' Renders the vertices as a collection of isolated points.&lt;br /&gt;
* '''linelist:''' Renders the vertices as a list of isolated straight line segments.&lt;br /&gt;
* '''linestrip:''' Renders the vertices as a single polyline.&lt;br /&gt;
* '''trianglelist:''' Renders the specified vertices as a sequence of isolated triangles. Each group of three vertices defines a separate triangle.&lt;br /&gt;
* '''trianglestrip:''' Renders the vertices as a triangle strip.&lt;br /&gt;
* '''trianglefan:''' Renders the vertices as a triangle fan.&lt;br /&gt;
&lt;br /&gt;
==Vertices format==&lt;br /&gt;
* '''posX:''' An float representing the X position of the vertice in the GTA world.&lt;br /&gt;
* '''posY:''' An float representing the Y position of the vertice in the GTA world.&lt;br /&gt;
* '''posZ:''' An float representing the Z position of the vertice in the GTA world.&lt;br /&gt;
* '''color (optional):''' An integer of the hex color, produced using [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue). If it's not specified, white color is used.&lt;br /&gt;
* '''u:''' An float representing  the relative X coordinate of the top left corner of the material which should be drawn from image&lt;br /&gt;
* '''v:''' An float representing  the relative Y coordinate of the top left corner of the material which should be drawn from image&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a ''true'' if the operation was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Remarks==&lt;br /&gt;
When a 3D draw call is issued by any such material MTA function then the principle to [https://github.com/multitheftauto/mtasa-blue/blob/16769b8d1c94e2b9fe6323dcba46d1305f87a190/Client/core/Graphics/CMaterialPrimitive3DBatcher.cpp#L42 push it directly to the 3D adapter] does apply. To achieve this there is '''no software-side 3D clipping mathematics''' being performed. This way the vertex data is always being pushed to the vertex shader, leaving the entire freedom to the developer on how to interpret this vertex data in the shader. For example, even though this function does imply an use in 3D world space, the vertex coordinates could be translated directly into Direct3D 9 screen space instead, effectively discarding any multiplication with the camera projection matrix. The mathematical model for translation into valid Direct3D 9 screen-space coordinates is described [https://docs.microsoft.com/en-us/windows/win32/direct3d9/viewports-and-clipping here]. Let's assume that you are drawing the rectangle on a classic sheet of paper with a mathematical 2D X,Y coordinate system.&lt;br /&gt;
&lt;br /&gt;
[[File:D3d9_screen_space_transformation.png|frameless|center|Direct3D 9 screen-space transformation]]&lt;br /&gt;
&lt;br /&gt;
To transform the coordinates you first have to flip the Y coordinate using negation and then apply the Direct3D 9 screen-space rasterization cross-hair by using the screen dimensions (sw, sh). Since linear shapes are being preserved across linear translations, you can simplify each vertex-based figure into it's set of vertices for the purpose shown above. By using this function in such a way it can perform all the operations in the same quality such as the simpler [[dxDrawMaterialPrimitive]] function.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example draws the picture with the file name 'test.png' on the ground of Grove Street and adds a /flip command to flip it. The 'test.png' file needs to be included in the [[meta.xml]] in order for this example to work.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local picture = &amp;quot;test.png&amp;quot;&lt;br /&gt;
local worldRenderPositions = { -- create a table with all the world positions&lt;br /&gt;
    &lt;br /&gt;
    { 2483, -1663, 12.4, 0, 0 }, -- top left&lt;br /&gt;
    { 2493, -1663, 12.4, 1, 0 }, -- top right&lt;br /&gt;
    { 2483, -1673, 12.4, 0, 1 }, -- bottom left&lt;br /&gt;
    { 2493, -1673, 12.4, 1, 1 }, -- bottom right&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
function renderPicture()&lt;br /&gt;
    dxDrawMaterialPrimitive3D( &amp;quot;trianglestrip&amp;quot;, picture, false, unpack(worldRenderPositions) ) -- use unpack() to separate the points&lt;br /&gt;
end&lt;br /&gt;
addEventHandler( &amp;quot;onClientRender&amp;quot;, root, renderPicture )&lt;br /&gt;
&lt;br /&gt;
function flipPicture()&lt;br /&gt;
    for index, point in ipairs(worldRenderPositions) do&lt;br /&gt;
        if point[4] == 1 then&lt;br /&gt;
            point[4] = 0&lt;br /&gt;
        else&lt;br /&gt;
            point[4] = 1&lt;br /&gt;
        end&lt;br /&gt;
        if point[5] == 1 then&lt;br /&gt;
            point[5] = 0&lt;br /&gt;
        else&lt;br /&gt;
            point[5] = 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler( &amp;quot;flip&amp;quot;, flipPicture )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function can be used to draw billboards in the game world. You have to [https://forum.mtasa.com/topic/133065-naruto-jutsus-help-me/?do=findComment&amp;amp;comment=1003073 understand the mathematical models about the human vision] to calculate the proper vertices.&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|n/a|1.5.7-9.19626|}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Drawing_functions}}&lt;br /&gt;
&lt;br /&gt;
[[hu:dxDrawMaterialPrimitive3D]]&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=PlaySFX&amp;diff=76280</id>
		<title>PlaySFX</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=PlaySFX&amp;diff=76280"/>
		<updated>2023-03-11T06:05:47Z</updated>

		<summary type="html">&lt;p&gt;Dragon: /* Example */ Added another example, showcasing the &amp;quot;radio&amp;quot; syntax.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}}&lt;br /&gt;
{{New feature/item|3.0134|1.3.4|5731|&lt;br /&gt;
This function plays a sound from GTA's big sound containers.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Note|There is a tool available which allows you to find bank and sound IDs easily: [[https://community.mtasa.com/index.php?p=resources&amp;amp;s=details&amp;amp;id=7549 sfxBrowser:Download]].}}&lt;br /&gt;
{{Warning|Many players use versions of GTA:SA (especially pirated versions) that have audio files full of zeros so that they can compresses better in their ''AUDIO\SFX\'' folder. (They lack any data) &lt;br /&gt;
In case of these invalid audio files, this function returns ''false''.&lt;br /&gt;
&lt;br /&gt;
It also returns ''false'' when trying to play a track deleted in the recent GTA: SA Steam patches (and if the client is using a Steam GTA: SA copy).|true}}&lt;br /&gt;
{{Note|PlaySFX sounds are MTA driven sounds, so MTA volume affects the volume.}}&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 playSFX ( string containerName, int bankId, int soundId [, bool looped = false ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''containerName:''' The name of the audio container. Possible values are: &amp;quot;feet&amp;quot;, &amp;quot;genrl&amp;quot;, &amp;quot;pain_a&amp;quot;, &amp;quot;script&amp;quot;, &amp;quot;spc_ea&amp;quot;, &amp;quot;spc_fa&amp;quot;, &amp;quot;spc_ga&amp;quot;, spc_na&amp;quot;, &amp;quot;spc_pa&amp;quot;&lt;br /&gt;
*'''bankId:''' The audio bank id&lt;br /&gt;
*'''soundId:''' The sound id within the audio bank&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''looped:''' A [[boolean]] representing whether the sound will be looped&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns a [[sound]] element if the sound was successfully created, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
{{New feature/item|3.0140|1.4|6443|&lt;br /&gt;
==Syntax 2==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
element playSFX ( string &amp;quot;radio&amp;quot;, string radioStation, int trackId [, bool looped = false ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''radio:''' The string &amp;quot;radio&amp;quot; (used to differentiate to the first syntax) &lt;br /&gt;
*'''radioStation:''' The radio station. Possible values are &amp;quot;Adverts&amp;quot;, &amp;quot;Ambience&amp;quot;, &amp;quot;Police&amp;quot;, &amp;quot;Playback FM&amp;quot;, &amp;quot;K-Rose&amp;quot;, &amp;quot;K-DST&amp;quot;, &amp;quot;Cutscene&amp;quot;, &amp;quot;Beats&amp;quot;, &amp;quot;Bounce FM&amp;quot;, &amp;quot;SF-UR&amp;quot;, &amp;quot;Radio Los Santos&amp;quot;, &amp;quot;Radio X&amp;quot;, &amp;quot;CSR 103.9&amp;quot;, &amp;quot;K-Jah West&amp;quot;, &amp;quot;Master Sounds 98.3&amp;quot;, &amp;quot;WCTR&amp;quot;.&lt;br /&gt;
*'''trackId :''' The radio track id within the radio station audio file&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''looped:''' A [[boolean]] representing whether the sound will be looped&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns a [[sound]] element if the sound was successfully created, ''false'' otherwise.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The following example plays a firealarm sound (looped).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
if not playSFX(&amp;quot;script&amp;quot;, 7, 1, true) then&lt;br /&gt;
    outputChatBox(&amp;quot;You have to install some missing audio files to hear the sound&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example spawns Big Smoke in his Crack Palace and plays one of his screams followed by the mission accomplished sound when he's killed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local bigsmoke = createPed(311,2550.53, -1284.81, 1060.98, 270)&lt;br /&gt;
setElementInterior(bigsmoke, 2)&lt;br /&gt;
&lt;br /&gt;
function smokeDied()&lt;br /&gt;
    playSFX(&amp;quot;spc_na&amp;quot;, 32, 34)&lt;br /&gt;
    setTimer(playSFX, 1000, 1, &amp;quot;radio&amp;quot;, &amp;quot;Beats&amp;quot;, 9)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientPedWasted&amp;quot;, bigsmoke, smokeDied)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_audio_functions}}&lt;br /&gt;
&lt;br /&gt;
[[hu:playSFX]]&lt;br /&gt;
[[pt-br:playSFX]]&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DxDrawPrimitive&amp;diff=76066</id>
		<title>DxDrawPrimitive</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DxDrawPrimitive&amp;diff=76066"/>
		<updated>2023-01-28T20:28:26Z</updated>

		<summary type="html">&lt;p&gt;Dragon: /* Example */ added yet another example, hidden by default because it just expands on the previous one and is probably more suited towards advanced users. also fixed a comment in the previous example to be fully accurate&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}} &lt;br /&gt;
{{New feature/item|3.0157|1.5.6|14370|This function draws a 2D primitive shape across the screen - rendered for one frame. This should be used in conjunction with [[onClientRender]] in order to display continuously.}}&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 dxDrawPrimitive ( string pType, bool postGUI, table vertice1 [, table vertice2, ...] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
* '''pType:''' Type of primitive to be drawn.&lt;br /&gt;
* '''postGUI:''' A bool representing whether the line should be drawn on top of or behind any ingame GUI (rendered by CEGUI).&lt;br /&gt;
* '''vertices:''' Tables representing each primitive vertice, required amount of them is determined by primitive type.&lt;br /&gt;
&lt;br /&gt;
==Allowed types==&lt;br /&gt;
[[Image:MTAsa_primitives.png|thumb|240px|Available primitive types.]]&lt;br /&gt;
More info on primitives may be found on [https://msdn.microsoft.com/en-us/library/windows/desktop/bb147291(v=vs.85).aspx this MSDN site] &lt;br /&gt;
* '''pointlist:''' Renders the vertices as a collection of isolated points.&lt;br /&gt;
* '''linelist:''' Renders the vertices as a list of isolated straight line segments.&lt;br /&gt;
* '''linestrip:''' Renders the vertices as a single polyline.&lt;br /&gt;
* '''trianglelist:''' Renders the specified vertices as a sequence of isolated triangles. Each group of three vertices defines a separate triangle.&lt;br /&gt;
* '''trianglestrip:''' Renders the vertices as a triangle strip.&lt;br /&gt;
* '''trianglefan:''' Renders the vertices as a triangle fan.&lt;br /&gt;
&lt;br /&gt;
==Vertices format==&lt;br /&gt;
* '''posX:''' An float representing the absolute X position of the vertice, represented by pixels on the screen.&lt;br /&gt;
* '''posY:''' An float representing the absolute Y position of the vertice, represented by pixels on the screen.&lt;br /&gt;
* '''color (optional):''' An integer of the hex color, produced using [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue). If it's not specified, white color is used.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a ''true'' if the operation was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 1&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This is a small example that creates trianglefan primitive with vertices in places that user clicks. It assigns every vertice random color.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local vertices = {}&lt;br /&gt;
function onClick(btn, state, x, y)&lt;br /&gt;
	if btn ~= &amp;quot;left&amp;quot; then return end&lt;br /&gt;
	if state ~= &amp;quot;up&amp;quot; then return end&lt;br /&gt;
	local vertice = {x, y, tocolor(math.random(255), math.random(255), math.random(255))}&lt;br /&gt;
	table.insert(vertices, vertice)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientClick&amp;quot;, root, onClick)&lt;br /&gt;
&lt;br /&gt;
function draw()&lt;br /&gt;
	dxDrawPrimitive(&amp;quot;trianglefan&amp;quot;, true, unpack(vertices))&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientPreRender&amp;quot;, root, draw)&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;Example 2&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example draws one complete oscillation of a sine wave starting in the center of the players screen using a linestrip type primitive.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local screenSizeX,screenSizeY = guiGetScreenSize() -- save the current screen dimensions&lt;br /&gt;
local sinCoords = {}&lt;br /&gt;
&lt;br /&gt;
function resStart() -- do all this once during &amp;quot;onClientResourceStart&amp;quot;, rather than every frame&lt;br /&gt;
	local range = math.pi * 2 -- to get 1 complete oscillation of the sine wave we need the range from 0 to 2pi&lt;br /&gt;
	local resolution = 100 -- resolution in this example means in how many steps we draw the linestrip, higher resolution means smoother curve at the expense of longer computation time and higher memory usage&lt;br /&gt;
	local scale = 50&lt;br /&gt;
	for i=0,range,range/resolution do -- &amp;quot;loop through this [resolution] times, starting at 0 and ending at [range]&amp;quot;&lt;br /&gt;
		local x = screenSizeX * 0.5 + i * scale -- start at the center of the screen and go from there&lt;br /&gt;
		local y = screenSizeY * 0.5 - math.sin(i) * scale -- subtract rather than add because greater y value means lower on the screen, which is the opposite of what we're used to seeing in graphs&lt;br /&gt;
		table.insert(sinCoords,{x,y})&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientResourceStart&amp;quot;,getResourceRootElement(getThisResource()), resStart)&lt;br /&gt;
&lt;br /&gt;
function exampleRender()&lt;br /&gt;
	dxDrawPrimitive(&amp;quot;linestrip&amp;quot;,true,unpack(sinCoords)) -- render a linestrip type primitive with the coordinates we calculated earlier to draw our sine wave&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;,getRootElement(),exampleRender)&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;Example 3&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;
Modifying the previous example, we can also use it to draw a &amp;quot;loading circle&amp;quot;-symbol similar to what some modern games like using to indicate loading or cloud saving in progress.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local screenSizeX,screenSizeY = guiGetScreenSize() -- save the current screen dimensions&lt;br /&gt;
local circleCoords = {}&lt;br /&gt;
local resolution = 100 -- resolution in this example means in how many steps we draw the linestrip, higher resolution means smoother curve at the expense of longer computation time and higher memory usage&lt;br /&gt;
local scale = 20&lt;br /&gt;
local maxSegmentPercentage = 0.75 -- this means the largest our line will get is 3/4 of the full circle&lt;br /&gt;
local startPointRevolution = 2000 -- one full revolution around the circle for our starting point after this amount of milliseconds passed&lt;br /&gt;
local endPointOscillation = 3000 -- one full oscillation of our endpoint after this amount of milliseconds passed&lt;br /&gt;
&lt;br /&gt;
function resStart() -- do all this once during &amp;quot;onClientResourceStart&amp;quot;, rather than every frame&lt;br /&gt;
	local range = math.pi * 2 -- to complete a circle we need the range from 0 to 2pi&lt;br /&gt;
	for i=0,range,range/resolution do -- &amp;quot;loop through this [resolution] times, starting at 0 and ending at [range]&amp;quot;&lt;br /&gt;
		local x = screenSizeX * 0.5 + math.sin(i) * scale -- for a circle we get our x coordiante from sine and the y coordinate from cosine or vice versa&lt;br /&gt;
		local y = screenSizeY * 0.5 - math.cos(i) * scale -- subtract will later result in a clockwise spin, add in a counter clockwise one&lt;br /&gt;
		table.insert(circleCoords,{x,y})&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientResourceStart&amp;quot;,getResourceRootElement(getThisResource()), resStart)&lt;br /&gt;
&lt;br /&gt;
function exampleRender()&lt;br /&gt;
	local tick = getTickCount() -- get the current time in milliseconds, then use it in a few clever ways to animate our circle&lt;br /&gt;
	local firstPoint = math.ceil( ((tick/startPointRevolution) % 1)*resolution ) -- firstly dividing it and using %1 (modulo 1) to repeatedly get a slowly, linearly increasing value from 0 to 1. This is our starting point&lt;br /&gt;
	local secondPoint = math.ceil( firstPoint + (math.sin(tick/endPointOscillation)) * resolution*maxSegmentPercentage ) -- secondly figuring out where we want our end point to be, using sine to get a pleasant looking pulse for the line growth&lt;br /&gt;
	&lt;br /&gt;
	if firstPoint &amp;gt; secondPoint then -- because of how we calculate our end point, half the time it will be smaller than the start point. for unpack() to give us the range we want we need to provide the smaller value first&lt;br /&gt;
		firstPoint, secondPoint = secondPoint, firstPoint&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if secondPoint &amp;gt; resolution then -- sometimes we'll wrap around the origin point of our circle, those cases need to be taken care of, so we'll draw the linestrip in two parts for those.&lt;br /&gt;
		dxDrawPrimitive(&amp;quot;linestrip&amp;quot;,true,unpack(circleCoords,firstPoint,resolution)) -- [secondPoint] is overshooting, so first let's complete the circle from [firstPoint]&lt;br /&gt;
		dxDrawPrimitive(&amp;quot;linestrip&amp;quot;,true,circleCoords[resolution],unpack(circleCoords,1,secondPoint%resolution)) -- and then draw the remaining extra segments from the start of the circle to however many segments [secondPoint] went past [resolution]&lt;br /&gt;
	elseif firstPoint &amp;lt; 1 then -- lua tables start at an index of 1, so 0 and anything into the negatives needs to be handled&lt;br /&gt;
		dxDrawPrimitive(&amp;quot;linestrip&amp;quot;,true,unpack(circleCoords,resolution+firstPoint,resolution)) -- &amp;quot;how many segments before [resolution] do we have to start? Either way we complete it at [resolution]!&amp;quot;&lt;br /&gt;
		dxDrawPrimitive(&amp;quot;linestrip&amp;quot;,true,circleCoords[resolution],unpack(circleCoords,1,secondPoint)) -- draw the remaining segments from 1 all the way to [secondPoint]&lt;br /&gt;
	else&lt;br /&gt;
		dxDrawPrimitive(&amp;quot;linestrip&amp;quot;,true,unpack(circleCoords,firstPoint,secondPoint)) -- the line isn't currently crossing the origin point of the circle at the top, so drawing this one is straight forwards&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;,getRootElement(),exampleRender)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Drawing_functions}}&lt;br /&gt;
&lt;br /&gt;
[[hu:dxDrawPrimitive]]&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&amp;diff=76057</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=76057"/>
		<updated>2023-01-27T17:52:30Z</updated>

		<summary type="html">&lt;p&gt;Dragon: /* Player functions */ added isPlayerActuallyInVehicle&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
=== Table functions ===&lt;br /&gt;
*[[addTableChangeHandler]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function monitors the changes of a table.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getTableFromSql]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This functionality is used to obtain saved tables using the function ([https://wiki.multitheftauto.com/wiki/SetTableToSql SetTableToSql ]).&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isValueInTable]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns true if the value exists in the table, false if the value does not exist in the table.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[pairsByKeys]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function sort pairs table.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[rangeToTable]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function converts a string range to a table containing number values.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[setTableProtected]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function protects a table and makes it read-only.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[setTableToSql]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function is used to save the table in the database (sql).&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[Sort_Functions]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» These functions are able to sort your tables by a key.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[table.compare]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks whether two given tables are equal.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[table.copy]] &amp;lt;span style=&amp;quot;color:gray; 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;
*[[table.deepmerge]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function deep merges two tables. Every nested table will be correspondingly merged.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[table.element]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a new table with only userdata content.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[table.empty]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks whether a table is empty.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[table.fromString]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function converts string to a table.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[table.getRandomRows]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns random rows from table.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[table.map]] &amp;lt;span style=&amp;quot;color:gray; 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;
*[[table.merge]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function merges two or more tables together.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[table.random]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function retrieves a random value from a table.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[table.removeValue]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function removes a specified value from a table.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[table.size]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the absolute size of a table.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[table.toString]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function converts table to a string.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ACL functions ===&lt;br /&gt;
*[[aclGroupClone]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function clone a group to another group with/without ACLs and/or objects.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getAccountsRanks]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function is used to detect the account name groups and put them in the chat.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPlayerAcls]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of all ACL groups on a player.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPlayersInACLGroup]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns all players in an ACL group.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isPlayerInACL]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if a player element is in an ACL group.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[renameAclGroup]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function gives an existing ACL group a new name.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Account functions ===&lt;br /&gt;
*[[getPlayerFromAccountName]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function is used to obtain a player by the name of his account.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Camera functions ===&lt;br /&gt;
*[[smoothMoveCamera]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to create a cinematic camera flight.&lt;br /&gt;
&lt;br /&gt;
=== Cursor functions ===&lt;br /&gt;
*[[getCursorMovedOn]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks in which way the cursor is currently moving.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Drawing functions ===&lt;br /&gt;
*[[dxDrawAnimWindow]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function draws an animated 2D window on the screen.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawBorderedRectangle]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This is a function that will create a bordered rectangle.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawBorderedText]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This is a function that will create a bordered text.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawDashedLine]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function draws a line with dashes.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawGifImage]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function simulates the effect of a GIF image by using image sprites in 2D.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawImage3D]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function draws a 3D image in GTA world.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawImageOnElement]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function draws an image on any element.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawLinedRectangle]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This is a function that will create a rectangle outline with dx lines.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawLoading]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function draws a loading bar on the screen.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawOctagon3D]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function creates a 3D Octagon&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawPolygon]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function draws a custom polygon on the screen.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawProgressBar]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function simulates a progress bar drawed using DirectDraw.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawRectangle3D]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function draws a 3D rectangle in GTA world.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawRectangleOnPlayer]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function draws a 3D rectangle above the player.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawRing]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function draws a ring with dx lines.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawRombo]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function creates a Rhombus.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawSprite]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function draw a sprite in the 3D world.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawTextOnElement]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function draws a text on any element.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawTextOnRectangle]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» Esta funcion crea un rectangle con un texto dentro.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxDrawTriangle]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This is a function that will create a triangle with dx lines.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxGetFontSizeFromHeight]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function calculates the font size from given height.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[dxGetRealFontHeight]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function calculates the height of a font.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getScreenStartPositionFromBox]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function helps with getting the correct position for your dx-effects.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[wordWrap]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function breaks a long string into a table of separate lines limited to a specific length in pixels, for drawing separately.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[CreateRectangle3D]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This is a function that will create a 3d rectangle on the player screen.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[DxDrawBordered3DLine]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;»This function creates a bordered area with 3D dx lines.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Effects functions ===&lt;br /&gt;
*[[attachEffect]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you attach an effect to an element.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Element functions === &lt;br /&gt;
*[[autoAttach]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function attaches one element into another at the same position and rotation they are.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isElementPlayer]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks whether the element is a player or not.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[attachElementToBone]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to attach an element to ped bone accurately using new bone functions.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getElementsInDimension]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of elements that are in the specified dimension.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getElementSpeed]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the specified element's speed in m/s, km/h or mph.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getElementsWithinMarker]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of elements that are within a marker's collision shape.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getElementUsingData]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns table elements that contains the elements data with the given key and value.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getNearestElement]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the nearest element (of a specific type) to a player.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isElementInPhotograph]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if an element is in the player's camera picture area.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isElementInRange]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to check if an element's range to a main point is within the maximum range.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isElementMoving]]&amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if an element is moving.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isElementWithinAColShape]]&amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if an element is within a collision shape element.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isElementInAir]]&amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if an element is in air or not.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[multi_check]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks one element to many, handy and clean.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[setElementSpeed]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to set the speed of an element in kph or mph units.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getElementDirectionCardialPoint]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the direction of the element according to the ''wind rose''.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Events ===&lt;br /&gt;
*[[onVehicleWeaponFire]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This code implements an event that is triggered when a player in a vehicle fires a vehicle's weapon.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Input functions ===&lt;br /&gt;
*[[bindControlKeys]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to bind each key bound to a control individually. Doing this bypasses a little MTA restriction.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getBoundControls]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of control names that are bound to the specified key.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[unbindControlKeys]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to unbind each key bound to a control individually. Use this function with [[bindControlKeys]].&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Data functions === &lt;br /&gt;
*[[byte2human]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function converts an integer (number of bytes) into a human-readable unit.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[capitalize]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function capitalizes a given string.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[convertDate]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function converts date to another look.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[convertServerTickToTimeStamp]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function converts server ticks to a unix timestamp.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[convertTextToSpeech]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function converts the provided text to a speech in the provided language which players can hear.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[findRotation3D]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function takes two sets of XYZ coordinates. It returns the 3D direction from point A to point B.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[findRotation]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function takes two points and returns the direction from point A to point B.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[formatDate]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function formats a date on the basis of a format string and returns it.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[formatNumber]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function formats large numbers by adding commas.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[generateRandomASCIIString]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a random string which uses ASCII characters. &amp;lt;/span&amp;gt;&lt;br /&gt;
*[[generateString]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function generates a random string with any characters.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getAge]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function calculates the age of a given birthday.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getDistanceBetweenElements]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» Returns the distance between two elements.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getDistanceBetweenPointAndSegment2D]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function takes point coordinates and line (a segment) starting and ending coordinates. It returns the shortest distance between the point and the line.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getEasterDate]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns easter date monthday and month for a given year.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getFreeDimension]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function get free dimension.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getKeyFromValueInTable]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the key of the specified value in a table.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getOffsetFromXYZ]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPointFromDistanceRotation]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function finds a point based on a starting point, direction and distance.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getRealMonth]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the current month name&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getRGColorFromPercentage]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia', sans-serif; font-size:smaller;&amp;quot;&amp;gt;»This function returns two integers representing red and green colors according to the specified percentage.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getScreenRotationFromWorldPosition]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a screen relative rotation to a world position.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getTimestamp]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the UNIX timestamp of a specified date and time.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[gradientString]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function transforms a string in a new coloured gradient string.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[hex2rgb]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function convert hex to rgb.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[hexColorToRGB]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function convert hex string/number to RGBA values.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isLeapYear]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a boolean representing if a given year is a leap year.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isValidMail]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks whether a provided e-mail string is valid.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[removeHex]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function is used to remove hexadecimal numbers (colors, for example) from strings.&lt;br /&gt;
*[[RGBToHex]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a string representing the color in hexadecimal.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[RGBToHSV]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function convert RGB to HSV color space.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[RGBToDecimal]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function convert RGB to Decimal color.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[secondsToTimeDesc]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function converts a plain seconds-integer into a user-friendly time description.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[string.count]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function counts the amount of occurences of a string in a string.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[string.explode]] &amp;lt;span style=&amp;quot;color:gray; 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;
*[[string.insert]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function inserts a string within another string at a given position.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[switch]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows the value of a variable or expression to control the flow of program execution via a multiway branch.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[tocolor2rgba]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function convert tocolor to rgba.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[toHex]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function converts a decimal number to a hexadecimal number, as a fix to be used client-side.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[var dump]] &amp;lt;span style=&amp;quot;color:gray; 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;
*[[wavelengthToRGBA]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function converts a physical wavelength of light to a RGBA color.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== GUI functions === &lt;br /&gt;
*[[centerWindow]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function centers a CEGUI window element responsively in any resolution.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[guiMoveElement]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function moves guiElement by/like using moveObject.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[guiSetStaticImageMovable]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to move a static image like a gui window.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isMouseOnGUICloseButton]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to check whether the mouse cursor/pointer is within a gui-window's native close button.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isMouseOnGuiElement]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to check whether or not your mouse is over a specific gui element, this is especially useful if the gui element has a parent. &amp;lt;/span&amp;gt;&lt;br /&gt;
=====Comboboxes=====&lt;br /&gt;
*[[guiComboBoxAdjustHeight]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function adjusts a CEGUI combobox element to have the correct height.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Gridlists=====&lt;br /&gt;
*[[convertGridListToText]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function converts grid list contents to text.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getGridListRowIndexFromText]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the GridList row index from the specified text.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[guiGridListAddPlayers]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function add all online players to a grid list.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[guiGridListGetColumnIDFromTitle]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function gets a gridlist's column ID from the column title.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[guiGridListGetSelectedText]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a string containing the inner text of a selected gridlist item.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[guiGridListSetColumnNonSortable]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function makes a gridlist column become non-sortable.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isTextInGridList]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if some text exist or not in the GridList.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Labels=====&lt;br /&gt;
*[[guiLabelAddEffect]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function add an effects to the gui-label like (shadow, outline).&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Marker functions ===&lt;br /&gt;
*[[createMarkerAttachedTo]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function creates a marker that is attached to an element.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Math functions ===&lt;br /&gt;
*[[math.clamp]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the number between range of numbers or it's minimum or maximum.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[math.getBezierPoint]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» Get N-th order bezier point.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[math.hypot]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the Hypotenuse of the triangle given by sides x and y.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[math.isPointInPolygon]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» Check if point is inside polygon or not.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[math.lerp]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» Get val between two integer.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[math.percent]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a percentage from two number values.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[math.polygonArea]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» Compute area of any polygon.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[math.randomDiff]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» Generates a pseudo-random integer that's always different from the last random number generated.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[math.rotVecToEulerAngle]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» Rotation Vector To Euler Angle&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[math.round]] &amp;lt;span style=&amp;quot;color:gray; 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;
*[[mathNumber]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function is a workaround for the client-side floating-point precision of 24-bits.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[reMap]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» Re-maps a number from one range to another.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[Math.percentProgress|math.percentProgress]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» Returns a percentage progress from two specific values.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[math.average]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the simple arithmetic mean of multiple numbers.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Map functions ===&lt;br /&gt;
*[[assignLod]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function lets you conveniently generate and apply a LOD model to a mapping object.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getWorldPositionFromMapPosition]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function converts an F11 map position to world position.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ped functions ===&lt;br /&gt;
*[[getAlivePlayers (Client)|getAlivePlayers]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of the alive players client-side.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getAlivePlayersInTeam]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of the alive players in a team.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getGuestPlayers]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function gets a players not login or players Guest .&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getOnlineAdmins]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of all logged-in administrators.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPedEyesPosition]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to get peds eyes position.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPedGender]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to get peds their gender.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPedMaxHealth]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a pedestrians's maximum health by converting it from their maximum health stat.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPedMaxOxygenLevel]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a ped's maximum oxygen level by converting it from their maximum underwater stamina stat.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPedWeaponSkill]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a ped's corresponding weapon skill level name.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPedHitBone]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function gets the approximate number of the bone where the ped is hit.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPlayerFromNamePart]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a player from partial name.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPlayerFromSerial]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a player from their serial.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPlayersByData]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of players that have the specified data name.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPlayersInPhotograph]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of all players in photograph.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPlayersInVehicles]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of the players insides vehicles from a specified dimension.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isPedAiming]]&amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if a pedestrian is aiming their weapon.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isPedAimingNearPed]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This is similar to isPedAiming but uses a colshape to be more precise.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isPedDiving]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This feature checks that pedestrian is diving in the water.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isPedDrivingVehicle]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if a specified pedestrian is driving a vehicle.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isPlayerInTeam]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if a player is in a specified team.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[setPedAttack]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function will make a ped attack a specified target.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[setPedFollow]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function will make a ped follow a specified target.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPlayerNameFromID]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function will get the player name from the ID element data.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Player functions ===&lt;br /&gt;
*[[countPlayersInRange]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the number of players that are within a certain range of the specified coordinates.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPlayerPreviousAndNextWeapon]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the player previous and next weapon.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getPlayersInRange]]&amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function make a table of players within certain range.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isPlayerActuallyInVehicle]]&amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if a player is actually in a vehicle instead of just in the process of entering.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isPlayerHitByVehicle]]&amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function cancels event when a element is hit by a vehicle.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[warpToPlayer]]&amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function make player warp to another player.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Resource functions ===&lt;br /&gt;
*[[getFilesInResourceFolder]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function gets a list of files that are inside a folder of a resource.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getResourceScripts]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of the resource scripts.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getResourceSettings]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of the resource settings.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getResourceSize]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the size of a specified resource in kB(kilobyte)&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[refreshResource]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function refreshes your resource if you changed any of the files&lt;br /&gt;
*[[setResourcePriority]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function set resource download priority group.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound functions ===&lt;br /&gt;
*[[isSoundFinished]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if a sound element has finished.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isSoundPlaying]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if a sound element is playing or not.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[stopSoundSlowly]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function stop your sound element slowly.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Browser functions ===&lt;br /&gt;
*[[playVideo]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function plays a video on the screen.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Team functions ===&lt;br /&gt;
*[[getTeamFromColor]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a team element by the specified color.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getTeamWithFewestPlayers]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a team element with least players of all the specified teams.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vehicle functions ===&lt;br /&gt;
*[[findEmptyCarSeat]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function finds you the first empty seat in a vehicle.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getNearestVehicle]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function gets the nearest vehicle to the specified player in a specified distance.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getRandomVehicle]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function gets a random vehicle.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getValidVehicleModels]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of all valid vehicle models.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getVehiclesCountByType]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the amount of vehicles by the given type as an integer value.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getVehicleTurnVelocityCenterOfMass]]&amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function gets a vehicle's turn velocity relative to the vehicle's center or mass.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isVehicleDoubleExhaust]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks is exhaust vehicle double.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isVehicleEmpty]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks whether a vehicle is empty.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isVehicleOccupied]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if a specified vehicle is occupied.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isVehicleOnRoof]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks whether vehicle is on roof.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isVehicleOnFire]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if the vehicle is on fire or not.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isVehicleReversing]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if a specified vehicle is moving backwards.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isVehicleUpgraded]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks is vehicle upgraded by upgrade ID.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[setVehicleGravityPoint]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[setVehicleTurnVelocityCenterOfMass]]&amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function sets a vehicle's turn velocity relative to the vehicle's center or mass.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[setVehicleHandlingFromText]]&amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function sets a vehicle's handling from text.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Weapon functions === &lt;br /&gt;
*[[getJetpackWeaponsEnabled]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of enabled weapons usable on a jetpack.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Object functions ===&lt;br /&gt;
*[[getDynamicDoorObjectOpenRatio]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function tells you how open a dynamic door is in a range from 0 to 1.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isElementObject]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function tells you if an element is an object or no.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== XML functions ===&lt;br /&gt;
*[[getXMLNodes]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns all children of a XML node.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Engine functions ===&lt;br /&gt;
*[[engineGetCOLsFromLibrary]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function gets the collision data from the col library.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[engineLoadIMGContainer]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function loads the IMG container.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Utility ===&lt;br /&gt;
*[[animate]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to use interpolateBetween without render event and easily used.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[callClientFunction]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to call any client-side function from the server's side.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[callServerFunction]] &amp;lt;span style=&amp;quot;color:gray; 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;
*[[check]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if its arguments are of the right type and calls the error-function if one is not.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[checkPassiveTimer]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to use passive timers in your conditions. For example you want to prevent players repeatedly using a command.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[coroutine.resume]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function applies a fix for hidden coroutine error messages.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[compact]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function create table containing variables and their values.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getBanFromName]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This functions returns the ban of the given playername.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getCurrentFPS]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the frames per second at which GTA: SA is running.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[getSkinNameFromID]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns the name of the skin from the given id.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[IfElse]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns one of two values based on a boolean expression.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isCharInString]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This shared function allows you to check if a char specified is in a string value.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isMouseInCircle]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function checks if a cursor position is in circular area or not.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[isMouseInPosition]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to check whether the mouse cursor/pointer is within a rectangular position.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[iterElements]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function returns ''a time-saving'' iterator for your for-loops.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[PlotTrajectoryAtTime]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» Calculate projectile/water trajectory.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[preprocessor]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function allow you to use gcc macros.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[vector3:compare]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This method checks whether two vectors match, with optional precision.&amp;lt;/span&amp;gt;&lt;br /&gt;
*[[svgCreateRoundedRectangle]] &amp;lt;span style=&amp;quot;color:gray; font-size:smaller;&amp;quot;&amp;gt;» This function creates a rectangle with rounded edges.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;[[Category:Useful Functions]]&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=IsPlayerActuallyInVehicle&amp;diff=76056</id>
		<title>IsPlayerActuallyInVehicle</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsPlayerActuallyInVehicle&amp;diff=76056"/>
		<updated>2023-01-27T17:37:37Z</updated>

		<summary type="html">&lt;p&gt;Dragon: Created page with &amp;quot;{{Useful Function}} __NOTOC__ This function provides a hacky way to recreate the client-side behavior of isPedInVehicle server-sided for player elements ONLY. It checks if a specified player is actually in a vehicle and not just in the process of entering.  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool isPlayerActuallyInVehicle ( player thePlayer )&amp;lt;/syntaxhighlight&amp;gt;  ===Required Arguments=== * '''thePlayer''': a player to check if they are inside a ve...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function provides a hacky way to recreate the client-side behavior of [[isPedInVehicle]] server-sided for [[player]] elements ONLY. It checks if a specified [[player]] is actually in a [[vehicle]] and not just in the process of entering.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool isPlayerActuallyInVehicle ( player thePlayer )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''thePlayer''': a [[player]] to check if they are inside a [[vehicle]] or not.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the specified [[player]] has fully completed entering a [[vehicle]] and hasn't fully completed exiting it yet, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Function source&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function isPlayerActuallyInVehicle(player)&lt;br /&gt;
	assert(isElement(player) and (getElementType(player) == &amp;quot;player&amp;quot;), &amp;quot;Bad argument @ isPlayerActuallyInVehicle [player expected, got &amp;quot; .. type(player) .. &amp;quot; '&amp;quot; .. tostring(player) .. &amp;quot;']&amp;quot;)&lt;br /&gt;
	local vehicle = getPedOccupiedVehicle(player)&lt;br /&gt;
	if vehicle then&lt;br /&gt;
		local x,y = getElementPosition(player)&lt;br /&gt;
		local vx,vy = getElementPosition(vehicle)&lt;br /&gt;
		if x == vx and y == vy then&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example will output a chat message anywhere within 50ms of a player changing their in-vehicle-state according to [[isPlayerActuallyInVehicle]].&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local allPlayers = {}&lt;br /&gt;
function resStart()&lt;br /&gt;
	for i,v in ipairs(getElementsByType(&amp;quot;player&amp;quot;)) do&lt;br /&gt;
		allPlayers[v] = isPlayerActuallyInVehicle(v)&lt;br /&gt;
	end&lt;br /&gt;
	setTimer(checkInterval,50,0)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;,getResourceRootElement(getThisResource()),resStart)&lt;br /&gt;
&lt;br /&gt;
function addPlayer()&lt;br /&gt;
	allPlayers[source] = isPlayerActuallyInVehicle(source)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;,getRootElement(),addPlayer)&lt;br /&gt;
&lt;br /&gt;
function checkInterval()&lt;br /&gt;
	for k,v in pairs(allPlayers) do&lt;br /&gt;
		local result = isPlayerActuallyInVehicle(k)&lt;br /&gt;
		if not v == result then&lt;br /&gt;
			outputChatBox(getPlayerName(k)..&amp;quot; changed their in vehicle state to &amp;quot;..tostring(result))&lt;br /&gt;
			allPlayers[k] = result&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: [[User:Dragon]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=TakePlayerScreenShot&amp;diff=76051</id>
		<title>TakePlayerScreenShot</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=TakePlayerScreenShot&amp;diff=76051"/>
		<updated>2023-01-24T03:33:23Z</updated>

		<summary type="html">&lt;p&gt;Dragon: /* Example */ replaced current lackluster example with one that is a little more elaborate and practical&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function forces a client to capture the current screen output and send it back to the server. The image will contain the GTA HUD and the output of any dxDraw functions that are not flagged as 'post GUI'. The image specifically excludes the chat box and all GUI (including the client console). The result is received with the event [[onPlayerScreenShot]].&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 takePlayerScreenShot ( player thePlayer, int width, int height [, string tag = &amp;quot;&amp;quot;, int quality = 30, int maxBandwith = 5000, int maxPacketSize = 500 ] )         &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
{{OOP||[[player]]:takeScreenShot||}}&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePlayer:''' the player to get the screen capture from.&lt;br /&gt;
*'''width:''' the width of the capture image.&lt;br /&gt;
*'''height:''' the height of the capture image.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''tag:''' A string to help identify the screen capture. The string is passed to the matching [[onPlayerScreenShot]] event for your personal convenience.&lt;br /&gt;
*'''quality:''' Quality of the final JPEG image from 0 to 100. A lower value can reduce the memory used by the image considerably which will result in faster and less intrusive uploads.&lt;br /&gt;
*'''maxBandwith:''' The amount of client upload bandwidth to use (in bytes per second) when sending the image.&lt;br /&gt;
*'''maxPacketSize: ''' The maximum size of one packet.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the function was successfully, ''false'' if invalid arguments are specified.&lt;br /&gt;
&lt;br /&gt;
==Example==  &lt;br /&gt;
===Example 1===&lt;br /&gt;
This example will take a player screenshot whenever a player takes a picture with the camera weapon and then send the picture to all clients, which will render the latest screenshot in the bottom right corner of their screen.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local screenSizeX,screenSizeY = guiGetScreenSize() -- save the current screen dimensions&lt;br /&gt;
local imgtexture&lt;br /&gt;
local takenBy&lt;br /&gt;
&lt;br /&gt;
function wepFire(weapon)&lt;br /&gt;
	if weapon == 43 then -- if the weapon the player just fired is the camera&lt;br /&gt;
		triggerServerEvent(&amp;quot;onPlayerTakesPhoto&amp;quot;,getLocalPlayer())&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientPlayerWeaponFire&amp;quot;,getLocalPlayer(),wepFire)&lt;br /&gt;
&lt;br /&gt;
function updateLatestPhoto(img)&lt;br /&gt;
	if imgtexture then -- clean up the old dxTextrue if there is one&lt;br /&gt;
		destroyElement(imgtexture)&lt;br /&gt;
	end&lt;br /&gt;
	imgtexture = dxCreateTexture(img) -- create a new dxTexture from the image data so that we can render it using dxDrawImage&lt;br /&gt;
	takenBy = &amp;quot;taken by &amp;quot;..getPlayerName(source) -- let's also credit the photographer&lt;br /&gt;
end&lt;br /&gt;
addEvent(&amp;quot;updatePhoto&amp;quot;,true)&lt;br /&gt;
addEventHandler(&amp;quot;updatePhoto&amp;quot;,getRootElement(),updateLatestPhoto)&lt;br /&gt;
&lt;br /&gt;
function renderPhoto()&lt;br /&gt;
	if imgtexture then&lt;br /&gt;
		local sizeX, sizeY = 320, 240&lt;br /&gt;
		dxDrawImage(screenSizeX-sizeX,screenSizeY-sizeY,sizeX,sizeY,imgtexture) -- render the picture as well as the name of the photographer in the bottom right corner of the screen&lt;br /&gt;
		dxDrawText(takenBy,screenSizeX-sizeX,screenSizeY-sizeY,screenSizeX,screenSizeY,tocolor(0,0,0))&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;,getRootElement(),renderPhoto)&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;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function requestScreenshot()&lt;br /&gt;
	takePlayerScreenShot(source,320,240,&amp;quot;cameraphoto&amp;quot;,50) -- the player just took a picture with the camera, let's request a screenshot to see what they took a photo of&lt;br /&gt;
end&lt;br /&gt;
addEvent(&amp;quot;onPlayerTakesPhoto&amp;quot;,true)&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerTakesPhoto&amp;quot;,getRootElement(),requestScreenshot)&lt;br /&gt;
&lt;br /&gt;
function incomingPlayerScreenshot(res,status,img,timestamp,tag)&lt;br /&gt;
	if status == &amp;quot;ok&amp;quot; and tag == &amp;quot;cameraphoto&amp;quot; then -- make sure a picture was taken successfully and that we're the ones who requested this screenshot&lt;br /&gt;
		triggerClientEvent(&amp;quot;updatePhoto&amp;quot;,source,img)  -- trigger a client event to share the image with everyone on the server&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerScreenShot&amp;quot;,getRootElement(),incomingPlayerScreenshot)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.3|n/a|}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Player functions}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DxDrawPrimitive&amp;diff=76047</id>
		<title>DxDrawPrimitive</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DxDrawPrimitive&amp;diff=76047"/>
		<updated>2023-01-23T17:15:34Z</updated>

		<summary type="html">&lt;p&gt;Dragon: added another example using the linestrip type primitive&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}} &lt;br /&gt;
{{New feature/item|3.0157|1.5.6|14370|This function draws a 2D primitive shape across the screen - rendered for one frame. This should be used in conjunction with [[onClientRender]] in order to display continuously.}}&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 dxDrawPrimitive ( string pType, bool postGUI, table vertice1 [, table vertice2, ...] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
* '''pType:''' Type of primitive to be drawn.&lt;br /&gt;
* '''postGUI:''' A bool representing whether the line should be drawn on top of or behind any ingame GUI (rendered by CEGUI).&lt;br /&gt;
* '''vertices:''' Tables representing each primitive vertice, required amount of them is determined by primitive type.&lt;br /&gt;
&lt;br /&gt;
==Allowed types==&lt;br /&gt;
[[Image:MTAsa_primitives.png|thumb|240px|Available primitive types.]]&lt;br /&gt;
More info on primitives may be found on [https://msdn.microsoft.com/en-us/library/windows/desktop/bb147291(v=vs.85).aspx this MSDN site] &lt;br /&gt;
* '''pointlist:''' Renders the vertices as a collection of isolated points.&lt;br /&gt;
* '''linelist:''' Renders the vertices as a list of isolated straight line segments.&lt;br /&gt;
* '''linestrip:''' Renders the vertices as a single polyline.&lt;br /&gt;
* '''trianglelist:''' Renders the specified vertices as a sequence of isolated triangles. Each group of three vertices defines a separate triangle.&lt;br /&gt;
* '''trianglestrip:''' Renders the vertices as a triangle strip.&lt;br /&gt;
* '''trianglefan:''' Renders the vertices as a triangle fan.&lt;br /&gt;
&lt;br /&gt;
==Vertices format==&lt;br /&gt;
* '''posX:''' An float representing the absolute X position of the vertice, represented by pixels on the screen.&lt;br /&gt;
* '''posY:''' An float representing the absolute Y position of the vertice, represented by pixels on the screen.&lt;br /&gt;
* '''color (optional):''' An integer of the hex color, produced using [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue). If it's not specified, white color is used.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a ''true'' if the operation was successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 1&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This is a small example that creates trianglefan primitive with vertices in places that user clicks. It assigns every vertice random color.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local vertices = {}&lt;br /&gt;
function onClick(btn, state, x, y)&lt;br /&gt;
	if btn ~= &amp;quot;left&amp;quot; then return end&lt;br /&gt;
	if state ~= &amp;quot;up&amp;quot; then return end&lt;br /&gt;
	local vertice = {x, y, tocolor(math.random(255), math.random(255), math.random(255))}&lt;br /&gt;
	table.insert(vertices, vertice)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientClick&amp;quot;, root, onClick)&lt;br /&gt;
&lt;br /&gt;
function draw()&lt;br /&gt;
	dxDrawPrimitive(&amp;quot;trianglefan&amp;quot;, true, unpack(vertices))&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientPreRender&amp;quot;, root, draw)&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;Example 2&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example draws one complete oscillation of a sine wave starting in the center of the players screen using a linestrip type primitive.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local screenSizeX,screenSizeY = guiGetScreenSize() -- save the current screen dimensions&lt;br /&gt;
local sinCoords = {}&lt;br /&gt;
&lt;br /&gt;
function resStart() -- do all this once during &amp;quot;onClientResourceStart&amp;quot;, rather than every frame&lt;br /&gt;
	local range = math.pi * 2 -- to get 1 complete oscillation of the sine wave we need the range from 0 to 2pi&lt;br /&gt;
	local resolution = 100 -- resolution in this example means in how many steps we draw the linestrip, higher resolution means smoother curve at the expense of longer computation time&lt;br /&gt;
	local scale = 50&lt;br /&gt;
	for i=0,range,range/resolution do -- &amp;quot;loop through this [resolution] times, starting at 0 and ending at [range]&amp;quot;&lt;br /&gt;
		local x = screenSizeX * 0.5 + i * scale -- start at the center of the screen and go from there&lt;br /&gt;
		local y = screenSizeY * 0.5 - math.sin(i) * scale -- subtract rather than add because greater y value means lower on the screen, which is the opposite of what we're used to seeing in graphs&lt;br /&gt;
		table.insert(sinCoords,{x,y})&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientResourceStart&amp;quot;,getResourceRootElement(getThisResource()), resStart)&lt;br /&gt;
&lt;br /&gt;
function exampleRender()&lt;br /&gt;
	dxDrawPrimitive(&amp;quot;linestrip&amp;quot;,true,unpack(sinCoords)) -- render a linestrip type primitive with the coordinates we calculated earlier to draw our sine wave&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;,getRootElement(),exampleRender)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Drawing_functions}}&lt;br /&gt;
&lt;br /&gt;
[[hu:dxDrawPrimitive]]&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=FireWeapon&amp;diff=76046</id>
		<title>FireWeapon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=FireWeapon&amp;diff=76046"/>
		<updated>2023-01-23T15:43:39Z</updated>

		<summary type="html">&lt;p&gt;Dragon: added another example that does more than fire a single shot&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
Fires one shot from a [[Element/Weapon|custom weapon]].&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool fireWeapon ( weapon theWeapon )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[Element/Weapon|weapon]]:fire}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theWeapon:''' The weapon to be fired.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the shot weapon is valid and therefore the shot was fired, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 1&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This function creates and fires a weapon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createAndFire()&lt;br /&gt;
    local weapon = createWeapon(&amp;quot;mp5&amp;quot;, 0, 0, 3) -- Create a MP5 at the coordinates 0, 0, 3&lt;br /&gt;
    fireWeapon(weapon) -- Fire the weapon we spawned&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientResourceStart&amp;quot;, resourceRoot, createAndFire)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 2&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example will create an M4, attach it to the local player and fire it every frame. Be aware that neither the weapon nor the shots are synced between players and that normally weapons don't fire every frame.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local wep&lt;br /&gt;
function resStart()&lt;br /&gt;
	wep = createWeapon(&amp;quot;m4&amp;quot;,0,0,0) -- when the resource starts, create the M4 and attach it to the local player with an offset to place it above their head facing forwards&lt;br /&gt;
	attachElements(wep,getLocalPlayer(),0,0,1,0,0,90)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientResourceStart&amp;quot;,getResourceRootElement(getThisResource()), resStart)&lt;br /&gt;
&lt;br /&gt;
function wepFire() -- fire the M4 every frame using the &amp;quot;onClientRender&amp;quot; event&lt;br /&gt;
	fireWeapon(wep)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;,getRootElement(),wepFire)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|n/a|1.3.0-9.04555|}}&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Client weapon creation functions}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Talk:FireWeapon&amp;diff=66556</id>
		<title>Talk:FireWeapon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Talk:FireWeapon&amp;diff=66556"/>
		<updated>2020-05-16T02:45:34Z</updated>

		<summary type="html">&lt;p&gt;Dragon: Created page with &amp;quot;&amp;quot;Returns true if the shot weapon is valid and therefore the shot was fired, false otherwise.&amp;quot; Is this as conflicting as I think it is? If we only check if the weapon is valid,...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;quot;Returns true if the shot weapon is valid and therefore the shot was fired, false otherwise.&amp;quot; Is this as conflicting as I think it is? If we only check if the weapon is valid, then a weapon without ammo would still return true despite not firing, which I think isn't really helpful for working with created weapons. If that's the case and we can't improve that, then I feel like documentation should make '''very clear''' that neither total ammo nor ammo in clip will be taken into consideration. --[[User:Dragon|Dragon]] ([[User talk:Dragon|talk]]) 02:45, 16 May 2020 (UTC)&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnPlayerWasted&amp;diff=65801</id>
		<title>OnPlayerWasted</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnPlayerWasted&amp;diff=65801"/>
		<updated>2020-04-09T22:11:09Z</updated>

		<summary type="html">&lt;p&gt;Dragon: Added documentation for 'killer' parameter for fall damage scenarios. Added documentation about objects being possible killers&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 is killed or dies.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
{{New feature/item|3|1.0||&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int totalAmmo, element killer, int killerWeapon, int bodypart, bool stealth&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Deprecated_feature|3|1.0|&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int totalAmmo, element killer, int killerWeapon, int bodypart&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
*'''totalAmmo''': an [[int]] representing the total ammo the victim had when they died.&lt;br /&gt;
*'''killer''': an [[element]] representing the [[player]], [[vehicle]] or [[object]] who was the killer. Deaths resulting from fall damage provide the [[vehicle]] or [[object]] landed on as the killer. If there was no killer this is ''false''.&lt;br /&gt;
*'''killerWeapon''': an [[int]] representing the [[Weapons|killer weapon]] or the [[Damage Types|damage type]].&lt;br /&gt;
*'''bodypart''': an [[int]] representing the bodypart ID the victim was hit on when they died.&lt;br /&gt;
{{BodyParts}}&lt;br /&gt;
*'''stealth''': a [[boolean]] value representing whether or not this was a stealth kill.&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[player]] that died or got killed.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example prints the killer and bodypart to the chat when a player dies.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- register player_Wasted as a handler for onPlayerWasted&lt;br /&gt;
function player_Wasted ( ammo, attacker, weapon, bodypart )&lt;br /&gt;
	-- if there was an attacker&lt;br /&gt;
	if ( attacker ) then&lt;br /&gt;
		-- we declare our variable outside the following checks&lt;br /&gt;
		local tempString&lt;br /&gt;
		-- if the element that killed him was a player,&lt;br /&gt;
		if ( getElementType ( attacker ) == &amp;quot;player&amp;quot; ) then&lt;br /&gt;
			-- put the attacker, victim and weapon info in the string&lt;br /&gt;
			tempString = getPlayerName ( attacker )..&amp;quot; killed &amp;quot;..getPlayerName ( source )..&amp;quot; (&amp;quot;..getWeaponNameFromID ( weapon )..&amp;quot;)&amp;quot;&lt;br /&gt;
		-- else, if it was a vehicle,&lt;br /&gt;
		elseif ( getElementType ( attacker ) == &amp;quot;vehicle&amp;quot; ) then&lt;br /&gt;
			-- we'll get the name from the attacker vehicle's driver&lt;br /&gt;
			tempString = getPlayerName ( getVehicleController ( attacker ) )..&amp;quot; killed &amp;quot;..getPlayerName ( source )..&amp;quot; (&amp;quot;..getWeaponNameFromID ( weapon )..&amp;quot;)&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
		-- if the victim was shot in the head, append a special message&lt;br /&gt;
		if ( bodypart == 9 ) then&lt;br /&gt;
			tempString = tempString..&amp;quot; (HEADSHOT!)&amp;quot;&lt;br /&gt;
		-- else, just append the bodypart name&lt;br /&gt;
		else&lt;br /&gt;
			tempString = tempString..&amp;quot; (&amp;quot;..getBodyPartName ( bodypart )..&amp;quot;)&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
		-- display the message&lt;br /&gt;
		outputChatBox ( tempString )&lt;br /&gt;
	-- if there was no attacker,&lt;br /&gt;
	else&lt;br /&gt;
		-- output a death message without attacker info&lt;br /&gt;
		outputChatBox ( getPlayerName ( source )..&amp;quot; died. (&amp;quot;..getWeaponNameFromID ( weapon )..&amp;quot;) (&amp;quot;..getBodyPartName ( bodypart )..&amp;quot;)&amp;quot; )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerWasted&amp;quot;, getRootElement(), player_Wasted )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And another example, this will spawn you in the middle of GTA SA world (x=0, y=0, z=3) after 2 seconds of your death&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler( &amp;quot;onPlayerWasted&amp;quot;, getRootElement( ),&lt;br /&gt;
	function()&lt;br /&gt;
		setTimer( spawnPlayer, 2000, 1, source, 0, 0, 3 )&lt;br /&gt;
	end&lt;br /&gt;
)&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>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnClientPlayerChangeNick&amp;diff=24109</id>
		<title>OnClientPlayerChangeNick</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnClientPlayerChangeNick&amp;diff=24109"/>
		<updated>2010-07-27T15:34:54Z</updated>

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

		<summary type="html">&lt;p&gt;Dragon: /* Example */ made the example a bit more clear&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Incomplete Event]]&lt;br /&gt;
{{Client event}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This event is triggered when a player changes his nickname.&lt;br /&gt;
&lt;br /&gt;
==Parameters== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string oldNick, string newNick&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*'''oldNick:''' the nickname the player had before.&lt;br /&gt;
*'''newNick:''' the new nickname of the player.&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The source of this event is the player that changed his nick&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example snippet sends a lame message every time a player changes his nick.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler ( &amp;quot;onClientPlayerChangeNick&amp;quot;, getRootElement(),&lt;br /&gt;
    function ( oldNick, newNick )&lt;br /&gt;
        outputChatBox ( &amp;quot;Hi &amp;quot; .. oldNick .. &amp;quot;! Oh... You're not &amp;quot; .. oldNick .. &amp;quot; anymore, are you?&amp;quot;, 0, 255, 0 )&lt;br /&gt;
        outputChatBox ( &amp;quot;I like your new name &amp;quot; .. newNick .. &amp;quot;!&amp;quot;, 0, 255, 0 )&lt;br /&gt;
    end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
===Client player events===&lt;br /&gt;
{{Client_player_events}}&lt;br /&gt;
===Client event functions===&lt;br /&gt;
{{Client_event_functions}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnElementDataChange&amp;diff=22869</id>
		<title>OnElementDataChange</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnElementDataChange&amp;diff=22869"/>
		<updated>2010-04-12T17:28:41Z</updated>

		<summary type="html">&lt;p&gt;Dragon: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server event}}&lt;br /&gt;
This event is triggered when an elementdata entry for an element changes. A client can perform this change on the element or it can be done using [[setElementData]].&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 theName, var theOldValue&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''theName''': The name of the element data entry that changed&lt;br /&gt;
*'''theOldValue''': The old value of this entry before it changed. The new value can be accessed using [[getElementData]] ( source, theName ).&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[element]] whose elementdata changed.&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;
&amp;lt;!-- Explain what the example is in a single sentance --&amp;gt;&lt;br /&gt;
This example outputs a message to players when any of their element data values is changed.&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 outputChange(dataName,oldValue)&lt;br /&gt;
	if getElementType(source) == &amp;quot;player&amp;quot; then -- check if the element is a player&lt;br /&gt;
		local newValue = getElementData(source,dataName) -- find the new value&lt;br /&gt;
		outputChatBox(&amp;quot;Your element data '&amp;quot;..tostring(dataName)..&amp;quot;' has changed from '&amp;quot;..tostring(oldValue)..&amp;quot;' to '&amp;quot;..tostring(newValue)..&amp;quot;'&amp;quot;,source) -- output the change for the affected player&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onElementDataChange&amp;quot;,getRootElement(),outputChange)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Needs Example]]&lt;br /&gt;
&lt;br /&gt;
{{See also/Server event|Element events}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnElementDataChange&amp;diff=22866</id>
		<title>OnElementDataChange</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnElementDataChange&amp;diff=22866"/>
		<updated>2010-04-09T14:27:01Z</updated>

		<summary type="html">&lt;p&gt;Dragon: Added an example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server event}}&lt;br /&gt;
This event is triggered when an elementdata entry for an element changes. A client can perform this change on the element or it can be done using [[setElementData]].&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 theName, var theOldValue&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''theName''': The name of the element data entry that changed&lt;br /&gt;
*'''theOldValue''': The old value of this entry before it changed. The new value can be accessed using [[getElementData]] ( source, theName ).&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[element]] whose elementdata changed.&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 outputs a message to players when any of their element data values is changed.&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 outputChange(dataName,oldValue)&lt;br /&gt;
	if getElementType(source) == &amp;quot;player&amp;quot; then -- check if the element is a player&lt;br /&gt;
		local newValue = getElementData(source,dataName) -- find the new value&lt;br /&gt;
		outputChatBox(&amp;quot;Your element data '&amp;quot;..tostring(dataName)..&amp;quot;' has changed from '&amp;quot;..tostring(oldValue)..&amp;quot;' to '&amp;quot;..tostring(newValue)..&amp;quot;'&amp;quot;,source) -- output the change for the affected player&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onElementDataChange&amp;quot;,getRootElement(),outputChange)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Needs Example]]&lt;br /&gt;
&lt;br /&gt;
{{See also/Server event|Element events}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=21179</id>
		<title>User talk:Dragon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=21179"/>
		<updated>2009-08-20T23:04:40Z</updated>

		<summary type="html">&lt;p&gt;Dragon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;section name=&amp;quot;Todo&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;
&amp;gt;extend magnetwheels functionality&lt;br /&gt;
|    -different modes, detect near ground and walls&lt;br /&gt;
-----&amp;gt;camera fixes ... ?&lt;br /&gt;
|    |    -remove quick changing, flickering&lt;br /&gt;
|    |    -possibility to deactivate, maybe request it&lt;br /&gt;
|    -remove ability to use it as a way of flying&lt;br /&gt;
&amp;gt;extend xxxs functionality if playing animations backwards becomes possible&lt;br /&gt;
|    -user controls, mime hot coffee... if i get permission to do so lols&lt;br /&gt;
|    -maybe add female part too, multiplayer like&lt;br /&gt;
|    -camera&lt;br /&gt;
&amp;gt;add new features to scoreboard&lt;br /&gt;
-----&amp;gt;click players and get options what to do, PM, votekick, etc.&lt;br /&gt;
|    |    export a function to include new fields, for admin kick, band, spectate and such&lt;br /&gt;
|    -clientside settings&lt;br /&gt;
|    -request name column to become smaller or shrink, or code and submit patch for it&lt;br /&gt;
&amp;gt;spacecowboys gamemode&lt;br /&gt;
|    -to much to do to list it here&lt;br /&gt;
&amp;gt;dark resource&lt;br /&gt;
|    -let this become a stealth map or something with included lua to make it &amp;quot;dark&amp;quot; ;P&lt;br /&gt;
|    -set the timer correctly so the darkness rectangle doesnt stack and activate, deactivate correctly for goggles&lt;br /&gt;
|    -somehow add a hint that goggles are really useful on this map so more people take it on stealth start&lt;br /&gt;
&amp;gt;utsounds&lt;br /&gt;
|    -get the original facts when which sound is played&lt;br /&gt;
|    -clean up code... -argh&lt;br /&gt;
|    -better quality for some sounds&lt;br /&gt;
|    -remove headshot code and include it instead, offer setting for sniper 1 hit kill or put it in an own resource&lt;br /&gt;
|    -a help file..??&lt;br /&gt;
&amp;gt;admin&lt;br /&gt;
|    -possibility to dis include resource types in resource list so servers with many maps have a better survey of their resources&lt;br /&gt;
|    -fix autologin option somehow&lt;br /&gt;
|    -maybe help getting rid of warnings, errors and bring back its old functionality&lt;br /&gt;
&amp;gt;lag compensation&lt;br /&gt;
|    -maybe ask talidan for a fix and an included testing session&lt;br /&gt;
|    -search for the revision its uselessness is caused by&lt;br /&gt;
|    -testing between dp2.3 and current&lt;br /&gt;
&amp;gt;find cause for currently emerging BAD DESYNC&lt;br /&gt;
&amp;gt;bullet holes and scratches for cars script&lt;br /&gt;
&amp;gt;chatbubbles&lt;br /&gt;
-----&amp;gt;fix overlapping (for a later release)&lt;br /&gt;
|    |    -make it work&lt;br /&gt;
|    |    -make it look smooth&lt;br /&gt;
|    |    -find a good way to implement this, test CAREFULLY&lt;br /&gt;
|    -release it&lt;br /&gt;
|    -ask for it to become part of optional resources&lt;br /&gt;
&amp;gt;dragonsmusic&lt;br /&gt;
|    -cycling between own stand alone resources which play the music, so you dont need to download all of them at once&lt;br /&gt;
|    -MOAR SONGS&lt;br /&gt;
&amp;gt;external http download issue?!&lt;br /&gt;
&amp;gt;flashbang&lt;br /&gt;
|    -sound volume depending on distance&lt;br /&gt;
|    -when closer longer blind, when far away only for short time&lt;br /&gt;
|    -depending where on screen it is&lt;br /&gt;
|    -bug with rocketlauncher and sniper aim&lt;br /&gt;
|    -dxrectangle instead, find a way to combine it with sound blending&lt;br /&gt;
&amp;gt;notifications&lt;br /&gt;
|    -optimize the size for all resolutions&lt;br /&gt;
|    -create a how to use guide&lt;br /&gt;
|    -add some examples&lt;br /&gt;
|    -release&lt;br /&gt;
&amp;gt;maps&lt;br /&gt;
|    -check for doors to replace (because of new dynamic objects)&lt;br /&gt;
|    -release them&lt;br /&gt;
|    -finish hallway and add security cams&lt;br /&gt;
&amp;gt;stealth&lt;br /&gt;
|    -add some celebration sounds in the end&lt;br /&gt;
&amp;gt;beg for community login, 3d scene and credits scene to come back&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=21178</id>
		<title>User talk:Dragon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=21178"/>
		<updated>2009-08-20T23:03:37Z</updated>

		<summary type="html">&lt;p&gt;Dragon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;section name=&amp;quot;Todo&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;
&amp;gt;extend magnetwheels functionality&lt;br /&gt;
|    -different modes, detect near ground and walls&lt;br /&gt;
-----&amp;gt;camera fixes ... ?&lt;br /&gt;
|    |    -remove quick changing, flickering&lt;br /&gt;
|    |    -possibility to deactivate, maybe request it&lt;br /&gt;
|    -remove ability to use it as a way of flying&lt;br /&gt;
&amp;gt;extend xxxs functionality if playing animations backwards becomes possible&lt;br /&gt;
|    -user controls, mime hot coffee... if i get permission to do so lols&lt;br /&gt;
|    -maybe add female part too, multiplayer like&lt;br /&gt;
|    -camera&lt;br /&gt;
&amp;gt;add new features to scoreboard&lt;br /&gt;
-----&amp;gt;click players and get options what to do, PM, votekick, etc.&lt;br /&gt;
|    |    export a function to include new fields, for admin kick, band, spectate and such&lt;br /&gt;
|    -clientside settings&lt;br /&gt;
|    -request name column to become smaller or shrink, or code and submit patch for it&lt;br /&gt;
&amp;gt;spacecowboys gamemode&lt;br /&gt;
|    -to much to do to list it here&lt;br /&gt;
&amp;gt;dark resource&lt;br /&gt;
|    -let this become a stealth map or something with included lua to make it &amp;quot;dark&amp;quot; ;P&lt;br /&gt;
|    -set the timer correctly so the darkness rectangle doesnt stack and activate, deactivate correctly for goggles&lt;br /&gt;
|    -somehow add a hint that goggles are really useful on this map so more people take it on stealth start&lt;br /&gt;
&amp;gt;utsounds&lt;br /&gt;
|    -get the original facts when which sound is played&lt;br /&gt;
|    -clean up code... -argh&lt;br /&gt;
|    -better quality for some sounds&lt;br /&gt;
|    -remove headshot code and include it instead, offer setting for sniper 1 hit kill or put it in an own resource&lt;br /&gt;
|    -a help file..??&lt;br /&gt;
&amp;gt;admin&lt;br /&gt;
|    -possibility to dis include resource types in resource list so servers with many maps have a better survey of their resources&lt;br /&gt;
|    -fix autologin option somehow&lt;br /&gt;
|    -maybe help getting rid of warnings, errors and bring back its old functionality&lt;br /&gt;
&amp;gt;lag compensation&lt;br /&gt;
|    -maybe ask talidan for a fix and an included testing session&lt;br /&gt;
|    -search for the revision its uselessness is caused by&lt;br /&gt;
|    -testing between dp2.3 and current&lt;br /&gt;
&amp;gt;find cause for currently emerging BAD DESYNC&lt;br /&gt;
&amp;gt;bullet holes and scratches for cars script&lt;br /&gt;
&amp;gt;chatbubbles&lt;br /&gt;
-----&amp;gt;fix overlapping (for a later release)&lt;br /&gt;
|    |    -make it work&lt;br /&gt;
|    |    -make it look smooth&lt;br /&gt;
|    |    -find a good way to implement this, test CAREFULLY&lt;br /&gt;
|    -release it&lt;br /&gt;
|    -ask for it to become part of optional resources&lt;br /&gt;
&amp;gt;dragonsmusic&lt;br /&gt;
|    -cycling between own stand alone resources which play the music, so you dont need to download all of them at once&lt;br /&gt;
|    -MOAR SONGS&lt;br /&gt;
&amp;gt;external http download issue?!&lt;br /&gt;
&amp;gt;flashbang&lt;br /&gt;
|    -sound volume depending on distance&lt;br /&gt;
|    -when closer longer blind, when far away only for short time&lt;br /&gt;
|    -depending where on screen it is&lt;br /&gt;
|    -bug with rocketlauncher and sniper aim&lt;br /&gt;
|    -dxrectangle instead, find a way to combine it with sound blending&lt;br /&gt;
&amp;gt;notifications&lt;br /&gt;
|    -optimize the size for all resolutions&lt;br /&gt;
|    -create a how to use guide&lt;br /&gt;
|    -add some examples&lt;br /&gt;
|    -release&lt;br /&gt;
&amp;gt;maps&lt;br /&gt;
|    -check for doors to replace (because of new dynamic objects)&lt;br /&gt;
|    -release them&lt;br /&gt;
|    -finish hallway and add security cams&lt;br /&gt;
&amp;gt;stealth&lt;br /&gt;
|    -add some celebration sounds in the end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=21177</id>
		<title>User talk:Dragon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=21177"/>
		<updated>2009-08-20T23:02:46Z</updated>

		<summary type="html">&lt;p&gt;Dragon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;section name=&amp;quot;Todo&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;
&amp;gt;extend magnetwheels functionality&lt;br /&gt;
|    -different modes, detect near ground and walls&lt;br /&gt;
-----&amp;gt;camera fixes ... ?&lt;br /&gt;
|    |    -remove quick changing, flickering&lt;br /&gt;
|    |    -possibility to deactivate, maybe request it&lt;br /&gt;
|    -remove ability to use it as a way of flying&lt;br /&gt;
&amp;gt;extend xxxs functionality if playing animations backwards becomes possible&lt;br /&gt;
|    -user controls, mime hot coffee... if i get permission to do so lols&lt;br /&gt;
|    -maybe add female part too, multiplayer like&lt;br /&gt;
|    -camera&lt;br /&gt;
&amp;gt;add new features to scoreboard&lt;br /&gt;
-----&amp;gt;click players and get options what to do, PM, votekick, etc.&lt;br /&gt;
|    |    export a function to include new fields, for admin kick, band, spectate and such&lt;br /&gt;
|    -clientside settings&lt;br /&gt;
|    -request name column to become smaller or shrink, or code and submit patch for it&lt;br /&gt;
&amp;gt;spacecowboys gamemode&lt;br /&gt;
|    -to much to do to list it here&lt;br /&gt;
&amp;gt;dark resource&lt;br /&gt;
|    -let this become a stealth map or something with included lua to make it &amp;quot;dark&amp;quot; ;P&lt;br /&gt;
|    -set the timer correctly so the darkness rectangle doesn't stack and activate, deactivate correctly for goggles&lt;br /&gt;
|    -somehow add a hint that goggles are really useful on this map so more people take it on stealth start&lt;br /&gt;
&amp;gt;utsounds&lt;br /&gt;
|    -get the original facts when which sound is played&lt;br /&gt;
|    -clean up code... -argh&lt;br /&gt;
|    -better quality for some sounds&lt;br /&gt;
|    -remove headshot code and include it instead, offer setting for sniper 1 hit kill or put it in an own resource&lt;br /&gt;
|    -a help file..??&lt;br /&gt;
&amp;gt;admin&lt;br /&gt;
|    -possibility to dis include resource types in resource list so servers with many maps have a better survey of their resources&lt;br /&gt;
|    -fix autologin option somehow&lt;br /&gt;
|    -maybe help getting rid of warnings, errors and bring back its old functionality&lt;br /&gt;
&amp;gt;lag compensation&lt;br /&gt;
|    -maybe ask talidan for a fix and an included testing session&lt;br /&gt;
|    -search for the revision its uselessness is caused by&lt;br /&gt;
|    -testing between dp2.3 and current&lt;br /&gt;
&amp;gt;find cause for currently emerging BAD DESYNC&lt;br /&gt;
&amp;gt;bullet holes and scratches for cars script&lt;br /&gt;
&amp;gt;chatbubbles&lt;br /&gt;
-----&amp;gt;fix overlapping (for a later release)&lt;br /&gt;
|    |    -make it work&lt;br /&gt;
|    |    -make it look smooth&lt;br /&gt;
|    |    -find a good way to implement this, test CAREFULLY&lt;br /&gt;
|    -release it&lt;br /&gt;
|    -ask for it to become part of optional resources&lt;br /&gt;
&amp;gt;dragonsmusic&lt;br /&gt;
|    -cycling between own stand alone resources which play the music, so you don't need to download all of them at once&lt;br /&gt;
|    -MOAR SONGS&lt;br /&gt;
&amp;gt;external http download issue?!&lt;br /&gt;
&amp;gt;flashbang&lt;br /&gt;
|    -sound volume depending on distance&lt;br /&gt;
|    -when closer longer blind, when far away only for short time&lt;br /&gt;
|    -depending where on screen it is&lt;br /&gt;
|    -bug with rocketlauncher and sniper aim&lt;br /&gt;
|    -dxrectangle instead, find a way to combine it with sound blending&lt;br /&gt;
&amp;gt;notifications&lt;br /&gt;
|    -optimize the size for all resolutions&lt;br /&gt;
|    -create a how to use guide&lt;br /&gt;
|    -add some examples&lt;br /&gt;
|    -release&lt;br /&gt;
&amp;gt;maps&lt;br /&gt;
|    -check for doors to replace (because of new dynamic objects)&lt;br /&gt;
|    -release them&lt;br /&gt;
|    -finish hallway and add security cams&lt;br /&gt;
&amp;gt;stealth&lt;br /&gt;
|    -add some celebration sounds in the end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetCameraMatrix&amp;diff=20966</id>
		<title>SetCameraMatrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetCameraMatrix&amp;diff=20966"/>
		<updated>2009-08-04T23:20:13Z</updated>

		<summary type="html">&lt;p&gt;Dragon: removed thePlayer from required arguments client side&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function sets the camera's position and direction. The first three arguments are the point at which the camera lies, the last three are the point the camera faces (or the point it &amp;quot;looks at&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Calling this function takes the camera's focus away from the player and sets the camera in a fixed position and rotation. The camera's focus can be brought back to the player using the [[setCameraTarget]] function.&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setCameraMatrix ( player thePlayer, float positionX, float positionY, float positionZ [, float lookAtX, float lookAtY, float lookAtZ, float roll = 0, float fov = 70 ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePlayer:''' The player whose camera is to be changed.&lt;br /&gt;
*'''positionX:''' The x coordinate of the camera's position.&lt;br /&gt;
*'''positionY:''' The y coordinate of the camera's position.&lt;br /&gt;
*'''positionZ:''' The z coordinate of the camera's position.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''lookAtX:''' The x coordinate of the point the camera faces.&lt;br /&gt;
*'''lookAtY:''' The y coordinate of the point the camera faces.&lt;br /&gt;
*'''lookAtZ:''' The z coordinate of the point the camera faces.&lt;br /&gt;
*'''roll:''' The camera roll angle, -180 to 180. A value of 0 means the camera sits straight, positive values will turn it counter-clockwise and negative values will turn it clockwise. -180 or 180 means the camera is upside down.&lt;br /&gt;
*'''fov:''' the field of view angle, 0 to 180. The higher this value is, the more you will be able to see what is to your sides.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setCameraMatrix ( float positionX, float positionY, float positionZ [, float lookAtX, float lookAtY, float lookAtZ, float roll, float fov ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''positionX:''' The x coordinate of the camera's position.&lt;br /&gt;
*'''positionY:''' The y coordinate of the camera's position.&lt;br /&gt;
*'''positionZ:''' The z coordinate of the camera's position.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''lookAtX:''' The x coordinate of the point the camera faces.&lt;br /&gt;
*'''lookAtY:''' The y coordinate of the point the camera faces.&lt;br /&gt;
*'''lookAtZ:''' The z coordinate of the point the camera faces.&lt;br /&gt;
*'''roll:''' The camera roll angle, -180 to 180. A value of 0 means the camera sits straight, positive values will turn it counter-clockwise and negative values will turn it clockwise. -180 or 180 means the camera is upside down.&lt;br /&gt;
*'''fov:''' the field of view angle, 0 to 180. The higher this value is, the more you will be able to see what is to your sides.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the arguments are valid, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This code fixates the camera onto the Vinewood sign in Las Venturas for any player that joins the server:&lt;br /&gt;
&amp;lt;section class=&amp;quot;server&amp;quot; name=&amp;quot;Server script&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function setCameraOnPlayerJoin()&lt;br /&gt;
     -- slowly fade the camera in to make the screen visible&lt;br /&gt;
     fadeCamera(source, true, 5)&lt;br /&gt;
     -- set the player's camera to a fixed position, looking at a fixed point&lt;br /&gt;
     setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, getRootElement(), setCameraOnPlayerJoin)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Camera functions}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DE/Lua_Tutorial&amp;diff=20531</id>
		<title>DE/Lua Tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DE/Lua_Tutorial&amp;diff=20531"/>
		<updated>2009-07-10T15:16:12Z</updated>

		<summary type="html">&lt;p&gt;Dragon: /* Rückgabewerte */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
==Vorwort==&lt;br /&gt;
Da es bis auf einige knappe und teils unprofessionelle Tutorials kein deutsches Lua Tutorial gibt, habe ich beschlossen, nun ein eigenes zu schreiben, welches alle für MTA notwendigen Grundlagen einfach und übersichtlich erklärt.&lt;br /&gt;
Weiterführende Möglichkeiten und Funktionen können der [http://www.lua.org/manual/5.1/ Offiziellen Lua Dokumentation] entnommen werden, die es jedoch nicht auf Deutsch gibt.&lt;br /&gt;
&lt;br /&gt;
Ein weiterer Grund ist, dass ich schon von einigen gehört habe und auch so schon den Verdacht hatte, dass MTA einfach so wenige deutsche Spieler und vor allem Server hat (gibt es überhaupt '''einen''' deutschen?), weil die meisten Probleme mit den englischen Dokumentationen haben oder der Meinung sind, dass für MTA ja sowieso kein deutscher Support vorhanden ist.&lt;br /&gt;
&lt;br /&gt;
Soviel nun dazu, wie es zu der Idee des deutschen Lua Tutorials kam.&lt;br /&gt;
Fangen wir an mit dem Erlernen einer neuen Sprache!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Grundlagen==&lt;br /&gt;
===Lua, eine Skriptsprache===&lt;br /&gt;
Lua (portugiesisch für Mond) ist eine Skriptsprache zum Einbinden in Programme, um diese leichter weiterentwickeln und warten zu können. Insbesondere die geringe Größe des Interpreters von 120 KB und die hohe Geschwindigkeit verglichen mit anderen Skriptsprachen überzeugen viele Entwickler davon, Lua einzusetzen.&lt;br /&gt;
&lt;br /&gt;
Die Syntax lehnt sich an die von Pascal an, was besonders Anfängern den Einstieg in Lua erleichtert. Im Gegensatz zu von Pascal abgeleiteten Sprachen nutzt Lua jedoch „==“ und nicht „=“ als Vergleichsoperator.&lt;br /&gt;
&lt;br /&gt;
(Quelle: [http://de.wikipedia.org/wiki/Lua Wikipedia])&lt;br /&gt;
&lt;br /&gt;
Einige werden sich bei dieser Einführung vielleicht gefragt haben, was der Unterschied zwischen Skript- und Programmiersprache ist und was ein Interpreter sein soll. Im folgenden will ich diese beiden Fragen so kurz und einfach wie möglich klären.&lt;br /&gt;
&lt;br /&gt;
Eine '''Programmiersprache''' (z.B. C, C++, Pascal, Delphi) wird - wie der Name schon sagt - verwendet, um Programme zu schreiben. Ein Programm liegt bekannterweise in Form einer Executable (*.exe) vor. Diese kann weitgehend unabhängig von irgendwelchen Betriebssystemen oder der Umgebung selbstständig ausgeführt werden (z.B. durch Doppelklick). Weitgehend deswegen, da einige Programme aufgrund von Speicherersparnissen sogenannte Programmbibliotheken (original Dynamic Link Library, kurz dll) benötigen, um zu funktionieren. Erklärungen dazu findet ihr [http://de.wikipedia.org/wiki/Dynamic_Link_Library hier].&amp;lt;br&amp;gt;&lt;br /&gt;
Um einen Programmquellcode, d.h. einen Text, der in einer Programmiersprache geschrieben wurde, aus dem Textdokumentformat in eine Anwendung (original Executable, kurz exe) umzuwandeln, benötigt man nun einen Compiler (zu Deutsch Kompilierer oder Übersetzer), der die Programmiersprache aus der menschenlesbaren Form in die maschinenlesbare Form umwandelt. Neben dieser Hauptaufgabe übernimmt der Compiler natürlich noch weitere Aufgaben, auf die ich jetzt aber nicht genauer eingehen werde. Infos dazu findet ihr [http://de.wikipedia.org/wiki/Compiler hier].&amp;lt;br&amp;gt;&lt;br /&gt;
Die maschinenlesbare Form ist für Menschen unlesbar.&lt;br /&gt;
&lt;br /&gt;
Eine '''Skriptsprache''' (z.B. JavaScript, DOS-Batch(Win) bzw. Shell-Scripts(UNIX)) hingegen liegt standardmäßig in der menschenlesbaren Form vor. Skriptsprachen werden - wie im ersten Satz bereits erwähnt - vor allem von Programmen benutzt, um benutzerdefinierte Abläufe verwenden zu können. Zur Ausführung von Scripts wird ein sogenannter Interpreter benötigt, der das Skript liest und es Schritt für Schritt in die Maschinensprache umwandelt und ausführt. Manche Skriptsprachen kann man mit einem Precompiler (zu Deutsch Vorkompilierer oder Vorübersetzer) vorkompilieren. Diesen könnte man auch den Vorkauer vom Interpreter nennen, da er das Script schon zum Teil in die Maschinensprache umwandelt, jedoch nicht so extrem wie der Compiler der Programmiersprachen. Das Ergebnis davon ist logischerweise die schnellere Ausführung des Skripts.&lt;br /&gt;
&lt;br /&gt;
Genug der langweiligen Definitionen. Klären wir lieber, was man denn alles braucht, um ein Lua Script zu schreiben.&lt;br /&gt;
&lt;br /&gt;
===Materialien===&lt;br /&gt;
Lua Skripte werden üblicherweise als Textdateien mit der Endung .lua gespeichert. Die Endung ist jedoch nicht von belang. Es kann jede beliebige Endung gewählt werden.&lt;br /&gt;
&lt;br /&gt;
Wie jede normale Textdatei kann man also auch Lua Skripte mit dem standard Texteditor des vorhandenen Betriebssystems schreiben, editieren und lesen. Ich persönlich empfehle jedoch das Programm Notepad++, welches [http://notepad-plus.sourceforge.net/de/site.htm hier] heruntergeladen werden kann. Das Programm ist Freeware und wird regelmäßig aktualisiert und erweitert. Der Vorteil daran ist, dass es ein professionelles Syntax-Highlighting eingebaut hat, welches Schlagwörter und Standardfunktionen farblich oder anderweitig hervorhebt und somit die Übersichtlichkeit erheblich verbessert.&amp;lt;br&amp;gt;&lt;br /&gt;
Standardmäßig wird die Sprache Lua automatisch an der Dateiendung .lua erkannt, solltest Du eine andere Endung verwenden und trotzdem das Lua Syntax-Highlighting verwenden wollen, kannst Du es oben im Menü „Sprachen“ einstellen.&lt;br /&gt;
&lt;br /&gt;
Wer ohne MTA seine kleinen Lua Skripte testen oder ausführen möchte, kann sich [http://luabinaries.luaforge.net/download.html hier] einen kostenlosen standalone Interpreter herunterladen. Wenn Du Dir nicht sicher bist, welche Windows Edition Du hast, dann hast Du wahrscheinlich eine 32 Bit Version, welche auf dieser Seite der „Windows x86 Executables“ entspricht. Die aktuelle Version (Win 32 Bit) dafür gibt es bei einem Klick auf [http://luaforge.net/frs/download.php/3134/lua5_1_3_Win32_bin.zip lua5_1_3_Win32_bin.zip].&amp;lt;br&amp;gt;&lt;br /&gt;
Nach dem Download kann der Standalone Interpreter mit einem Doppelklick auf die „lua5.1.exe“ gestartet werden. Dort kann man dann direkt Lua Befehle eingeben oder ein Script laden. Dies geht wie folgt:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;dofile(&amp;quot;dateiname.lua&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Kommentare==&lt;br /&gt;
Um sein Skript übersichtlicher zu gestalten, kann man mit Kommentaren bestimmte Zeilen eräutern, Bereiche abgrenzen, alten Code deaktivieren, ohne ihn zu entfernen und generell das Skript übersichtlicher gestalten.&amp;lt;br&amp;gt;&lt;br /&gt;
Kommentare werden vom Interpreter vollkommen ignoriert und sind nur für den Menschen lesbar und von Belang.&lt;br /&gt;
&lt;br /&gt;
===Einzeilig===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;-- Dies ist ein einzeiliger Kommentar. Er gilt von -- bis zum Ende dieser Zeile. Automatische Zeilenumbrüche, die eingefügt werden, wenn die Zeilenlänge überschritten wurde, zählen nicht.&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mehrzeilig===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;--[[ Dieser Kommentar&lt;br /&gt;
     geht über beliebig viele Zeilen&lt;br /&gt;
     und endet mit ]]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Variablen==&lt;br /&gt;
===Einführung===&lt;br /&gt;
Eine Variable kann man sich wie eine kleine Kiste vorstellen, auf der außen ein Bezeichner (oder Name) steht und die einen Wert enthält. Während der Bezeichner immer gleich ist, kann der Inhalt variieren.&lt;br /&gt;
Jede Variable hat einen Variablentypen, der bei Programmiersprachen normalerweise zu Beginn des Programmes fest definiert wird und sich nicht ändern kann. Da Lua aber ja keine Programmiersprache ist, muss der Variablentyp zu Beginn und auch sonst nie festgelegt werden und kann sich beliebig oft verändern. Der Interpreter erkennt Variablentypen automatisch und nimmt dem Skripter somit eine Menge Arbeit (vor allem bzgl. der Planung) ab.&lt;br /&gt;
&lt;br /&gt;
===Typen===&lt;br /&gt;
Im Folgenden will ich die wichtigsten Variablentypen auflisten und kurz beschreiben.&lt;br /&gt;
;Integer (ganze Zahlen)&lt;br /&gt;
:Umfasst alle Ganzzahlen, sowohl negative als auch positive.&lt;br /&gt;
:Beispiele: -8, 0, 12, 2&lt;br /&gt;
;Float (Komma- bzw. gebrochene Zahlen)&lt;br /&gt;
:Umfasst alle Fließkommazahlen, sowohl negative als auch positive. Wichtig dabei ist, dass anstelle des Kommas (,) ein Dezimalpunkt (.) zum Trennen des ganzen vom gebrochenen Teil verwendet werden muss.&lt;br /&gt;
:Beispiele: -77.2, 0.0, 3.14159, 9.81&lt;br /&gt;
;String (Zeichenkette)&lt;br /&gt;
:Kann jedes beliebige Zeichen enthalten. Eine maximale Länge ist mir nicht bekannt. Strings müssen immer in Anführungszeichen(&amp;quot; oder ') eingschlossen werden.&lt;br /&gt;
:Beispiele: &amp;quot;hallo&amp;quot;, 'Lua ist toll!', &amp;quot;&amp;quot;, &amp;quot; :D &amp;quot;&lt;br /&gt;
;Boolean (Schalter)&lt;br /&gt;
:Kann zwei verschiedene Werte enthalten: ''true'' (dt. wahr bzw. an) oder ''false'' (dt. falsch bzw. aus). ''true'' entspricht dabei nicht dem Wert 1 und ''false'' nicht dem Wert 0.&lt;br /&gt;
:Beispiele: ''true'', ''false''&lt;br /&gt;
;Nil (Leer oder Nichts)&lt;br /&gt;
:''nil'' ist sowohl ein Wert als auch ein Typ. Eine Variable vom Typ ''nil'' enthält automatisch den Wert ''nil''. ''nil'' bedeutet ganz einfach nichts. Wenn eine Variable ''nil'' ist, existiert sie nicht. ''nil'' entspricht weder dem Wert 0 noch dem Wert ''false'' noch dem Wert &amp;quot;&amp;quot;!&lt;br /&gt;
:Beispiele: ''nil''&lt;br /&gt;
Ich werde auf jeden Variablentypen noch detaillierter eingehen. Außerdem wurden hier die Variablentypen '''function''', '''table''' und '''userdata''' nicht aufgeführt, da diese jeweils ein eigenes Kapitel bekommen.&lt;br /&gt;
&lt;br /&gt;
===Definition===&lt;br /&gt;
Eine Variable definieren bedeutet im Grunde genommen eine Variable anlegen. In Lua muss einer Variable bei der Definition ein Wert zugewiesen werden. ''nil'' ist dabei als Wert auch möglich, macht jedoch wenig Sinn, da jede beliebige Variablenbezeichnung automatisch den Wert ''nil'' enthält.&lt;br /&gt;
&lt;br /&gt;
Man unterscheidet zwischen '''lokalen''' und '''globalen''' Variablen. Um eine Variable als lokal zu definieren muss das Schlüsselwort ''local'' davor geschrieben werden. Lokal bedeutet für uns im Moment noch ganz einfach, dass die Variable nur im aktuellen Script verfügbar ist. Sollten also z.B. von einem Programm zwei verschiedene Lua Skripte geladen sein und benutzt werden, können diese untereinander auf die globalen Variablen des jeweils anderen Skripts zugreifen, auf die lokalen jedoch nicht. Generell empfiehlt es sich, immer lokale Variablen zu nehmen, falls man nicht explizit eine globale benötigt, da so vermieden wird, dass mehrere parallel laufende Skripte aufgrund von gleichen Variablenbezeichnern durcheinander kommen.&lt;br /&gt;
&lt;br /&gt;
====Einzeln====&lt;br /&gt;
Definieren wir uns also nun unsere erste lokale Variable und geben ihr einen ganzzahligen Inhalt:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local zahl = 7 -- weist der lokalen Variable zahl den Wert 7 zu&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Eine globale Variable erhält man, indem man einfach das ''local'' weglässt:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;gZahl = 13 -- weist der globalen Variable gZahl den Wert 13 zu&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Das selbe geht natürlich nun auch mit allen anderen Variablentypen:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local ganzzahl = -5&lt;br /&gt;
local kommazahl = 0.008&lt;br /&gt;
local zeichenkette = &amp;quot;Hello World&amp;quot;&lt;br /&gt;
local schalter = true&lt;br /&gt;
local nichts = nil -- diese Zeile kann man sich im Grunde genommen sparen, da jede nicht definierte Variable automatisch den Wert nil hat&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Längere Strings mit mehreren Zeilenumbrüchen können in einer vereinfachten Weise zugewiesen werden. Dies funktioniert so ähnlich wie bei Kommentaren. Anstelle von Anführungszeichen verwendet man [[ als Anfangs- und ]] als Endmarkierung des Strings.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local text = [[Willkommen auf unserem Server.&lt;br /&gt;
Bitte halte Dich an die Regeln.&lt;br /&gt;
MfG die Administration]]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Alternativ kann in einem String, der in doppelten Anführungszeichen (&amp;quot;) eingeschlossen ist, folgende Steuerzeichen enthalten:&lt;br /&gt;
;\n&lt;br /&gt;
:Entspricht einem Zeilenumbruch.&lt;br /&gt;
;\t&lt;br /&gt;
:Entspricht einem Tabulator.&lt;br /&gt;
;\&amp;quot;&lt;br /&gt;
:Wird verwendet, um doppelte Anführungszeichen in einem String, der von doppelten Anführungszeichen eingeschlossen ist, darzustellen, ohne dass der Interpreter diese fälschlicherweise als Stringende auffasst.&lt;br /&gt;
;\'&lt;br /&gt;
:Wie \&amp;quot;, nur gilt dies in Strings, die von einfachen Anführungszeichen eingeschlossen sind.&lt;br /&gt;
;\\&lt;br /&gt;
:Entspricht einem Backslash (\)&lt;br /&gt;
&lt;br /&gt;
====Mehrere====&lt;br /&gt;
Man kann in einer Zeile mehrere Variablen definieren, indem man sie mit Kommas voneinander trennt. Die Variablentypen können dabei alle unterschiedlich sein. Hier mal ein Beispiel:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local frucht, anzahl, reif = &amp;quot;apfel&amp;quot;, 4, true&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''local'' darf dabei nur einmal am Zeilenanfang stehen und bewirkt, dass alle dahinter aufgelisteten Variablen lokal werden.&amp;lt;br&amp;gt;&lt;br /&gt;
Sollten links neben dem Gleichheitszeichen mehr Variablenbezeichner stehen als rechts Werte, so bleiben die überschüssigen Variablen ''nil''. Im umgekehrten Fall werden überschüssige Werte rechts einfach ignoriert.&lt;br /&gt;
&lt;br /&gt;
==Operatoren==&lt;br /&gt;
===Arithmetische===&lt;br /&gt;
Arithmetische Operatoren werden verwendet, um Berechnungen durchzuführen. Somit kann man entweder mit Variablen, festen Zahlen oder einer Mischung neue Werte berechnen oder verändern.&amp;lt;br&amp;gt;&lt;br /&gt;
Bei Berechnungen gilt stets: '''Punkt- vor Strichrechnung'''.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
;Plus (+)&lt;br /&gt;
:Addiert zwei Werte miteinander.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a, b = 3, 8&lt;br /&gt;
local c = a + b -- a + b entspricht hier der Rechnung 3 + 8, c erhält nun also den Wert 11&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Minus (-)&lt;br /&gt;
:Subtrahiert den zweiten vom ersten Wert.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a, b = 3, 8&lt;br /&gt;
local c = a - b -- a - b entspricht hier der Rechnung 3 - 8, c erhält nun also den Wert -5&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Mal (*)&lt;br /&gt;
:Multipliziert zwei Werte miteinander.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a, b = 3, 8&lt;br /&gt;
local c = a * b -- a * b entspricht hier der Rechnung 3 * 8, c erhält nun also den Wert 24&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Geteilt (/)&lt;br /&gt;
:Dividiert den ersten durch den zweiten Wert. Hierbei entsteht in den meisten Fällen eine Kommazahl!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a, b = 3, 8&lt;br /&gt;
local c = a / b -- a / b entspricht hier der Rechnung 3 / 8, c erhält nun also den Wert 0.375&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Modulo (%)&lt;br /&gt;
:Ermittelt den Rest, der übrig bleibt, wenn man die erste Zahl durch die zweite teilt.&lt;br /&gt;
:Der Modulo-Operator gehört zur Punktrechnung.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a, b = 14, 3&lt;br /&gt;
local c = a % b -- a % b entspricht hier der Rechnung 14 % 3, c erhält nun also den Wert 2, da 14 / 3 = 4 REST 2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Minus (-) (als Vorzeichen)&lt;br /&gt;
:Dient zur Darstellung einer negativen Zahl, also einer Zahl unter 0.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = -3 -- entspricht der Rechnung a = 0 - 3&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Hoch (^)&lt;br /&gt;
:Potenziert die erste Zahl mit der zweiten.&lt;br /&gt;
:Potenzen werden noch '''vor''' der Punktrechnung ausgerechnet.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a, b = 3, 8&lt;br /&gt;
local c = a ^ b -- a ^ b entspricht hier der Rechnung 3 ^ 8 (3&amp;lt;sup&amp;gt;8&amp;lt;/sup&amp;gt;), c erhält nun also den Wert 6561&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logische===&lt;br /&gt;
Logische Operatoren werden Benutzt, um Werte miteinander zu vergleichen und mehrere Bedingungen zu verknüpfen. Wir werden genauer auf sie zurückkommen, wenn es um Bedingungen geht. Bis dahin reicht es, wenn man sich merkt, dass ein logischer Vergleich entweder ''true'' (wenn die Aussage wahr ist) oder ''false'' (wenn die Aussage falsch ist) ergibt.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
;Gleich (==)&lt;br /&gt;
:Prüft, ob zwei Werte gleich sind.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (5 == 5) -- a ist true, da die Aussage wahr ist&lt;br /&gt;
local b = (5 == 8) -- b ist false, da die Aussage falsch ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Ungleich (~=)&lt;br /&gt;
:Prüft, ob zwei Werte ungleich sind.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (5 ~= 5) -- a ist false, da die Aussage falsch ist&lt;br /&gt;
local b = (5 ~= 8) -- b ist true, da die Aussage wahr ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Größer als (&amp;gt;)&lt;br /&gt;
:Prüft, ob der erste Wert größer als der zweite ist.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (5 &amp;gt; 5) -- a ist false, da die Aussage falsch ist&lt;br /&gt;
local b = (5 &amp;gt; 8) -- b ist false, da die Aussage falsch ist&lt;br /&gt;
local c = (8 &amp;gt; 5) -- c ist true, da die Aussage wahr ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Größer als oder gleich (&amp;gt;=)&lt;br /&gt;
:Prüft, ob der erste Wert größer als der zweite ist oder dem zweiten gleicht.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (5 &amp;gt;= 5) -- a ist true, da die Aussage wahr ist&lt;br /&gt;
local b = (5 &amp;gt;= 8) -- b ist false, da die Aussage falsch ist&lt;br /&gt;
local c = (8 &amp;gt;= 5) -- c ist true, da die Aussage wahr ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Kleiner als (&amp;lt;)&lt;br /&gt;
:Prüft, ob der erste Wert kleiner als der zweite ist.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (5 &amp;lt; 5) -- a ist false, da die Aussage falsch ist&lt;br /&gt;
local b = (5 &amp;lt; 8) -- b ist true, da die Aussage wahr ist&lt;br /&gt;
local c = (8 &amp;lt; 5) -- c ist false, da die Aussage falsch ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Kleiner als oder gleich (&amp;lt;=)&lt;br /&gt;
:Prüft, ob der erste Wert kleiner als der zweite ist oder dem zweiten gleicht.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (5 &amp;lt;= 5) -- a ist true, da die Aussage wahr ist&lt;br /&gt;
local b = (5 &amp;lt;= 8) -- b ist true, da die Aussage wahr ist&lt;br /&gt;
local c = (8 &amp;lt;= 5) -- c ist false, da die Aussage falsch ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Und (and)&lt;br /&gt;
:Verknüpft zwei Bedingungen miteinander.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (true and false) -- a ist false, da nicht beide Aussagen wahr sind&lt;br /&gt;
local b = (5 &amp;lt; 8) and (7 == 7) -- b ist true, da beide Aussagen wahr sind&lt;br /&gt;
local c = (8 &amp;gt; 5) and (1 ~= 2) and (0 &amp;lt;= -7) -- c ist false, da die dritte Aussage falsch ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Oder (or)&lt;br /&gt;
:Verknüpft zwei Bedingungen miteinander.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (true or false) -- a ist true, da die erste Aussage wahr ist&lt;br /&gt;
local b = (5 &amp;lt; 8) or (7 == 7) -- b ist true, da mindestens eine der Aussagen wahr ist&lt;br /&gt;
local c = (8 &amp;gt; 5) or (1 ~= 2) or (0 &amp;lt;= -7) -- c ist true, da mindestens eine der Aussagen wahr ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Nicht (not)&lt;br /&gt;
:Kehrt einen Booleanwert um.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = not true -- a ist false&lt;br /&gt;
local b = not false -- b ist true&lt;br /&gt;
local c = not (0 == 8) -- c ist true, da die Aussage falsch ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sonstige===&lt;br /&gt;
Lua hat noch zwei weitere Operatoren, die sich jedoch nicht in die oberen Gruppen eingliedern lassen.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Länge (#)&lt;br /&gt;
:Steht für die Länge eines Strings oder einer Table.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local sprache = &amp;quot;deutsch&amp;quot;&lt;br /&gt;
local laenge = #sprache -- laenge wird hier auf 7 gesetzt, da das Wort &amp;quot;deutsch&amp;quot; 7 Buchstaben hat&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Verknüpfung (..)&lt;br /&gt;
:Verknüpft zwei Strings miteinander.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local geschlecht, alter = &amp;quot;männlich&amp;quot;, &amp;quot;18&amp;quot;&lt;br /&gt;
local satz = &amp;quot;Ich bin &amp;quot;..geschlecht..&amp;quot; und &amp;quot;..alter..&amp;quot; Jahre alt.&amp;quot; -- weist satz den Wert &amp;quot;Ich bin männlich und 18 Jahre alt.&amp;quot; zu&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Natürlich können auch alle anderen Variablentypen mit- und untereinander verglichen werden.&amp;lt;br&amp;gt;&lt;br /&gt;
Der Längenoperator (#) sowie der Verknüpfungsoperator (..) sind nur für Strings gedacht, wobei der erste später noch bei Tables eine Rolle spielen wird und der zweite es nicht so genau nimmt mit den Variablentypen. Bei Booleans und ''nil'' jedoch führt er in jedem Fall zu einem Fehler. Wir kommen später noch darauf zu sprechen, wie man soetwas umgeht.&amp;lt;br&amp;gt;&lt;br /&gt;
Für Integer und Floats sind alle Vergleichsoperatoren und die arithmetischen verfügbar. Strings unterstützen nur die Vergleichsoperatoren, wobei man mit den größer/kleiner Operatoren zwei Strings nach dem Alphabet ordnen kann.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&amp;quot;a&amp;quot; &amp;lt; &amp;quot;b&amp;quot; -- ergibt true, da a vor b im Alphabet kommt&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Strings, Booleans und ''nil'' kann man nur untereinander vergleichen, nicht miteinander. Miteinander führt in jedem Fall zu ''false''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Bedingungen==&lt;br /&gt;
===Einführung===&lt;br /&gt;
Bedingungen sind dazu da, um bestimmte Anweisungen nur auszuführen, wenn ein bestimmter Sachverhalt gegeben ist.&lt;br /&gt;
Ein Beispiel wäre, wenn ein Spieler einem anderen Spieler eine private Nachricht senden möchte. Dann kann er das natürlich nur tun, wenn der adressierte Spieler auch online ist.&lt;br /&gt;
Also soll die Nachricht in einem solchen Fall gesendet werden, andernfalls dem Sender jedoch eine Fehlermeldung ausgegeben werden.&lt;br /&gt;
&lt;br /&gt;
===Syntax===&lt;br /&gt;
Die Syntax einer Bedingung, die man übrigens auch „if-Statement“ (if = engl. für wenn) oder im Englischen „condition“ nennt, ist recht simpel.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;if &amp;lt;bedingung&amp;gt; then&lt;br /&gt;
    -- Anweisung(en), die ausgeführt werden soll(en), wenn die Bedingung wahr (=true) ist&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Für &amp;lt;bedingung&amp;gt; darf hier jeder Audruck eingesetzt werden, der letztendlich irgendeinen Wert ergibt.&lt;br /&gt;
Sollte &amp;lt;bedingung&amp;gt; ''nil'' oder ''false'' sein, so wird die Anweisung zwischen then und end nicht ausgeführt, andernfalls wird sie ausgeführt.&lt;br /&gt;
&lt;br /&gt;
===Else-Statement===&lt;br /&gt;
Auf jedes if-Statement darf ein else-Statement (else = engl. für sonst) folgen. Dieses benötigt kein then und auch keine Bedingung, sondern wird ausgeführt, wenn die Bedingung des if-Statements ''nil'' oder ''false'' ist. Das else-Statement ist optional!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;if &amp;lt;bedingung&amp;gt; then&lt;br /&gt;
    -- Anweisung(en), die ausgeführt werden soll(en), wenn die Bedingung erfüllt wird&lt;br /&gt;
else&lt;br /&gt;
    -- Anweisung(en), die ausgeführt werden soll(en), wenn die Bedingung nicht erfüllt wird&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Elseif-Statement===&lt;br /&gt;
Das elseif-Statement ist ein spezielles Statement, was es erlaubt, einer unübersichtlichen Verschachtelung zu entgehen, indem es die Möglichkeit bietet, einem else-Statement auch eine Bedingung zu geben. Ein if-Statement darf beliebig viele elseif-Statements enthalten. Diese müssen jedoch zwischen dem if- und dem else-Statement (falls vorhanden) stehen. Für die Bedingung gilt hier das selbe, wie für das if-Statement. Wichtig ist, dass demnach auch hier ein then erforderlich ist. Genauso wie das else-Statement ist jedoch auch das elseif-Statement optional!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;if &amp;lt;bedingung1&amp;gt; then&lt;br /&gt;
    -- Anweisung(en), die ausgeführt werden soll(en), wenn die Bedingung 1 erfüllt wird&lt;br /&gt;
elseif &amp;lt;bedingung2&amp;gt; then&lt;br /&gt;
    -- Anweisung(en), die ausgeführt werden soll(en), wenn die Bedingung 2 erfüllt wird&lt;br /&gt;
else&lt;br /&gt;
    -- Anweisung(en), die ausgeführt werden soll(en), wenn weder Bedingung 1 noch Bedingung 2 erfüllt werden&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Bedingungen formulieren===&lt;br /&gt;
Bei der Bedingung eines if-Statements muss nicht zwangsläufig ein Boolean herauskommen. Wie bereits erwähnt, ist die Bedingung immer dann wahr, wenn sie weder ''nil'' noch ''false'' ist.&lt;br /&gt;
D.h., dass auch Werte wie 0, &amp;quot;Hallo&amp;quot; und 3.14159 als „wahr“ gelten. Natürlich ist das auch bei ''true'' der Fall.&lt;br /&gt;
&lt;br /&gt;
Um komplexere Bedingungen zu formulieren, werden auf jeden Fall die bereits aufgelisteten logischen Operatoren benötigt.&lt;br /&gt;
Mit diesen kann man für jeden nur erdenklichen Fall eine Bedingung formulieren.&lt;br /&gt;
&lt;br /&gt;
Wenn logische (Vergleichs-)Operatoren (==, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=) angewandt werden, kommt dabei immer ein Boolean raus, wie man auch schon an den gegebenen Beispielen erkennen kann.&lt;br /&gt;
Verknüfungen (and, or) sind dazu gedacht, um z.B. zu überprüfen, ob mehrere oder wenigstens eine Bedingung von vielen erfüllt werden oder nicht. Der not-Operator ermöglicht es, zu überprüfen, ob eine Bedingung nicht erfüllt wird.&lt;br /&gt;
&lt;br /&gt;
Zu dem and- und dem or-Operator möchte ich an dieser Stelle noch etwas ergänzen. Der and-Operator wird zunächst einmal dazu verwendet, um herauszufinden, ob zwei Bedingungen gleichzeitig erfüllt sind. Der or-Operator wird dazu benutzt, um herauszufinden, ob eine von zweien oder beide Bedingungen erfüllt sind.&lt;br /&gt;
&lt;br /&gt;
Weder der and- noch der or-Operator geben aber zwangsläufig einen Boolean zurück.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local foo = wert1 and wert2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Sollte wert1 ''nil'' oder ''false'' sein, so entspricht dieser Ausdruck dem folgenden:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local foo = wert1&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Ist wert1 weder ''nil'' noch ''false'', so entspricht der Ausdruck dem hier:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local foo = wert2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Bei or ist es ähnlich, nur umgekehrt.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local foo = wert1 or wert2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Sollte wert1 ''nil'' oder ''false'' sein, so entspricht dieser Ausdruck dem folgenden:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local foo = wert2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Ist wert1 weder ''nil'' noch ''false'', so entspricht der Ausdruck dem hier:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local foo = wert1&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Beispiele===&lt;br /&gt;
====50-50-Chance====&lt;br /&gt;
Dieses Beispiel simuliert einen Münzwurf. math.random() und print() sind standard Lua-Funktionen. Zum Thema Funktionen komme ich später. Für dieses Beispiel reicht es, wenn ihr wisst, dass math.random() eine Zufallszahl (float) zwischen 0 und 1 zurückgibt und print(&amp;quot;text&amp;quot;) den in den Klammern eingeschlossenen String in die Konsole ausgibt.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local zufall = math.random()&lt;br /&gt;
if (zufall &amp;lt; 0.5) then&lt;br /&gt;
    print(&amp;quot;Kopf&amp;quot;)&lt;br /&gt;
else&lt;br /&gt;
    print(&amp;quot;Zahl&amp;quot;)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
====Der Nutzen von elseif====&lt;br /&gt;
Im Folgenden wollen wir herausfinden, ob eine Zahl positiv, negativ oder 0 ist. Dazu möchte ich zuerst ein Beispiel ohne und danach eines mit elseif zeigen, um meine Aussage, dass elseif Verschachtelungen spart, zu verifizieren.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local zahl = 14&lt;br /&gt;
&lt;br /&gt;
--ohne elseif&lt;br /&gt;
if (zahl &amp;lt; 0) then&lt;br /&gt;
    print(&amp;quot;Die Zahl ist negativ.&amp;quot;)&lt;br /&gt;
else&lt;br /&gt;
    if (zahl == 0) then&lt;br /&gt;
        print(&amp;quot;Die Zahl entspricht 0.&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
        print(&amp;quot;Die Zahl ist positiv.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--mit elseif&lt;br /&gt;
if (zahl &amp;lt; 0) then&lt;br /&gt;
    print(&amp;quot;Die Zahl ist negativ.&amp;quot;)&lt;br /&gt;
elseif (zahl == 0) then&lt;br /&gt;
    print(&amp;quot;Die Zahl entspricht 0.&amp;quot;)&lt;br /&gt;
else&lt;br /&gt;
    print(&amp;quot;Die Zahl ist positiv.&amp;quot;)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Je komplexer das ganze if-Statement, desto nützlicher wird elseif sein.&lt;br /&gt;
====Eingebettetes Pseudo-if-Statement====&lt;br /&gt;
In vielen Script- und Programmiersprachen gibt es ein gekürztes if-Statement. In Javascript z.B. geht das wie folgt:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;var nachricht = &amp;quot;Du benutzt zurzeit &amp;quot; + (ie ? &amp;quot;den Internet Explorer&amp;quot; : &amp;quot;einen guten Browser&amp;quot;) + &amp;quot;.&amp;quot;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Wir gehen dabei davon aus, dass in der Variable ie ein Boolean gespeichert ist, der ''true'' ist, wenn der Benutzer den Internet Explorer benutzt, ansonsten ''false''.&lt;br /&gt;
Diese Art von eingebetteten if-Statements gibt es noch in vielen anderen Sprachen, unter anderen in PHP, Java und C(++). In meinem Beispiel kann man sich das ? als then und den : als else vorstellen. Dann sollte es eigentlich nicht allzu schwer sein, diese Art von if-Statement zu verstehen.&lt;br /&gt;
&lt;br /&gt;
So direkt gibt es das bei Lua nicht, aber mit and und or kann man sich ein Konstrukt bauen, welches auf die gleiche Weise funktioniert. Dazu werde ich einfach mal das obere Beispiel in Lua umwandeln, auch, wenn Lua eigentlich nicht viel mit Browsern am Hut hat.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local nachricht = &amp;quot;Du benutzt zurzeit &amp;quot;..(ie and &amp;quot;den Internet Explorer&amp;quot; or &amp;quot;einen guten Browser&amp;quot;)..&amp;quot;.&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Zuerst ist das and an der Reihe. Es schmeißt den String &amp;quot;den Internet Explorer&amp;quot; raus, wenn ie ''false'' (oder ''nil'') ist und zurück bleibt auf jeden Fall ''false'' (oder ''nil''). Das wird dann vom or rausgeschmissen und zurück bleibt &amp;quot;einen guten Browser&amp;quot;.&lt;br /&gt;
Wenn ie weder ''false'' noch ''nil'' ist, schmeißt and die Vairable ie raus und zurück bleibt &amp;quot;den Internet Explorer&amp;quot;. Da dieser String weder ''false'' noch ''nil'' ist, wird er vom or beibelassen und &amp;quot;einen guten Browser&amp;quot; rausgeschmissen.&lt;br /&gt;
Entschuldigt meine Ausdrucksweise mit dem rausschmeißen, aber das schien mir die beste Möglichkeit, diese Methode verständlich zu erklären.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Tabellen==&lt;br /&gt;
===Einführung===&lt;br /&gt;
Tabellen sind spezielle Variablen, die mehrere Werte enthalten können.&lt;br /&gt;
Damit wir Tabellen verwenden können, führe ich nun erst einmal den Variablentyp „table“ ein. Mit einer table-Variable kann man ersteinmal kaum Operationen durchführen. Dazu benötigt man Funktionen, zu denen wir aber erst später kommen.&lt;br /&gt;
&lt;br /&gt;
===Definition===&lt;br /&gt;
Um eine Variable als (leere) table zu definieren, benutzt man diesen Ausdruck:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle = {}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ohne Funktionen macht das noch recht wenig Sinn. Um einer Tabelle direkt mehrere Werte zuzuweisen, schreibt man diese einfach durch Kommata getrennt zwischen die geschweiften Klammern.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle1 = { &amp;quot;Apfel&amp;quot;, 14, 3.14159, true }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Eine table kann alle möglichen Typen von Variablen enthalten. So zum Beispiel auch andere Tabellen.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle2 = { 1, { 1.25, 1.5, 1.75 }, 2, { 2.25, 2.5, 2.75 } }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Um nun auf die Elemente einer table zugreifen zu können, benutzt man Indizes (Indizes ist der Plural von Index). Jedes Element in einer table hat einen Index. Wenn man die Tabellen so definiert, wie ich es gemacht habe, so wird jedem Element ein integer als Index zugewiesen, wobei das erste Element die 1 als Index bekommt, das zweite die 2 usw.&lt;br /&gt;
Der ungefähre Wert von Pi (3.14159) in der oberen Tabelle hat den Index 3. Um anhand eines Indizes ein Element einer Tabelle abzufragen, schreibt man den Index einfach in eckigen Klammern hinter den Tabellennamen.&lt;br /&gt;
tabelle1[3] entspricht also dem Wert 3.14159.&lt;br /&gt;
Wenn das Element der Tabelle selbst noch eine Tabelle ist, wie z.B. das Element mit dem index 2 aus tabelle2, dann setzt man die Indizes einfach hintereinander. Der Wert 2.25 ist demnach in tabelle2[4][1] gespeichert.&lt;br /&gt;
&lt;br /&gt;
===Ganzzahlige Indizes===&lt;br /&gt;
Um gezielt bestimmten Indizes einen Wert zuzuweisen, kann man folgende Schreibweise verwenden:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local auskunft = { [11] = &amp;quot;elf&amp;quot;, [88] = &amp;quot;achtundachtzig&amp;quot;, [0] = &amp;quot;null&amp;quot; }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Dabei spielt es keine Rolle, in welcher Reihenfolge die Indizes einen Wert zugewiesen bekommen und es spiel auch keine Rolle, ob die Indizes positiv oder negativ sind.&lt;br /&gt;
Es muss jedoch beachtet werden, dass etwas wie { [1] = &amp;quot;eins&amp;quot;, &amp;quot;zwei&amp;quot; } dem Index 1 den Wert &amp;quot;zwei&amp;quot; zuweisen würde, da Lua immer bei 1 anfängt zu zählen, egal, ob der Scripter den Index 1 bereits definiert hat.&lt;br /&gt;
&lt;br /&gt;
===Zeichenketten als Indizes===&lt;br /&gt;
Ein Index kann auch ein String sein. Dazu verwendet man folgende Schreibweise:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;lua konstanten = { [&amp;quot;pi&amp;quot;] = 3.14159, [&amp;quot;e&amp;quot;] = 2.71828 }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Ansprechen kann man diese Werte genauso wie bei integer-Indizes. konstanten[&amp;quot;pi&amp;quot;] ist also 3.14159.&lt;br /&gt;
&lt;br /&gt;
Eine Besonderheit bei Zeichenketten als Index ist, dass es eine vereinfachte Schreibweise gibt. Sowohl bei der Definition als auch bei der Abfrage der Elemente. Das obige Beispiel kann auch so realisiert werden:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;lua konstanten = { pi = 3.14159, e = 2.71828 }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Zum Abfragen der Elemente kann man die Schreibweise konstanten.pi bzw. konstanten.e verwenden.&lt;br /&gt;
Man sollte aber bedenken, dass Schlüsselwörter wie z.B. if oder local als Indizes besser mit [&amp;quot;if&amp;quot;] und [&amp;quot;local&amp;quot;] definiert werden.&lt;br /&gt;
&lt;br /&gt;
===Beliebige Indizes===&lt;br /&gt;
Ein Index muss nicht unbedingt ein integer oder ein string sein. Genauer gesagt kann ein Index ein beliebiger Wert (außer ''nil'') sein.&lt;br /&gt;
Somit wäre z.B. auch das möglich:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle = { [true] = &amp;quot;wahr&amp;quot;, [3.14159] = &amp;quot;pi&amp;quot;, [0] = 1, 123 }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Die Zahl 123 hätte hier übrigens den Index 1.&lt;br /&gt;
&lt;br /&gt;
===Einzelzuweisungen===&lt;br /&gt;
Man muss nicht immer alle Werte einer table auf einmal definieren. Jedes Tabellenelement lässt sich wie eine normale Variable behandeln.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle = {}&lt;br /&gt;
tabelle[true] = &amp;quot;wahr&amp;quot;&lt;br /&gt;
tabelle.pi = 3.14159&lt;br /&gt;
tabelle[2] = { 1, 2, 3 }&lt;br /&gt;
tabelle[2][0] = 0&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jedes undefinierte Element hat - genauso wie jede undefinierte Variable - den Wert ''nil''.&lt;br /&gt;
&lt;br /&gt;
===Verlinkungen===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle1 = { 1, 2, 3 }&lt;br /&gt;
local tabelle2 = tabelle1&lt;br /&gt;
tabelle1[1] = 4&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In der zweiten Zeile dieses Beispiels wird die tabelle1 nicht in die Variable tabelle2 kopiert, sondern tabelle2 verweist ab sofort auf tabelle1. Am Ende des Codes wäre also tabelle2[1] auch 4, obwohl es nicht explizit zugewiesen wurde.&lt;br /&gt;
&lt;br /&gt;
Um eine Tabelle zu kopieren, könnt ihr euch die Useful Function [[table.copy]] aus der Wiki kopieren und diese dazu verwenden.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Schleifen==&lt;br /&gt;
===Einführung===&lt;br /&gt;
Schleifen verwendet man immer dann, wenn man eine oder mehrere Anweisungen mehr als einmal direkt hintereinander ausführen möchte oder wenn man eine oder mehrere Anweisungen für jedes Element einer table ausführen möchte.&lt;br /&gt;
Es gibt drei verschiedene Arten von Schleifen. Diese werde ich jetzt hier einzeln vorstellen.&lt;br /&gt;
&lt;br /&gt;
===While-Schleife===&lt;br /&gt;
Die while-Schleife wiederholt eine oder mehrere Anweisungen solange, bis eine bestimmte Bedingung nicht mehr erfüllt wird.&lt;br /&gt;
Die Syntax ist die folgende:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;while [bedingung] do&lt;br /&gt;
    -- Anweisung(en)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Beispiel:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local zahl = 10&lt;br /&gt;
while (zahl &amp;gt;= 0) do&lt;br /&gt;
    print(zahl)&lt;br /&gt;
    zahl = zahl - 1&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Das Beispiel gibt nacheinander alle Zahlen von 10 bis 0 aus. Nach der Schleife hat zahl dann den Wert -1.&lt;br /&gt;
&lt;br /&gt;
===Repeat-Until-Schleife===&lt;br /&gt;
Die repeat-until-Schleife wiederholt eine oder mehrere Anweisungen solange, bis eine bestimmte Bedingung erfüllt ist. Sie führt diese Anweisung(en) aber in jedem Fall einmal aus.&lt;br /&gt;
Die Syntax lautet:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;repeat&lt;br /&gt;
    -- Anweisung(en)&lt;br /&gt;
until [bedingung]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Das obere Beispiel lässt sich hiermit wie folgt realisieren:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local zahl = 10&lt;br /&gt;
repeat&lt;br /&gt;
    print(zahl)&lt;br /&gt;
    zahl = zahl - 1&lt;br /&gt;
until (zahl &amp;lt; 0)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===For-Schleife===&lt;br /&gt;
Es gibt zwei verschiedene for-Schleifen. Einmal die einfache numerische for-Schleife und zum Anderen die generische for-Schleife, mit der man u.a. alle Elemente einer tabelle durchlaufen kann. Mit der generischen for-Schleife kann man noch ganz andere wesentlich komplexere Operationen durchführen, die ich hier aber nicht erklären werde, da sie auch - zumindest beim Scripten für MTA - nicht wirklich benötigt werden.&lt;br /&gt;
====Numerisch====&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;for [laufvariable], [maximum], [schrittweite] do&lt;br /&gt;
    -- Anweisung(en)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Die Laufvariable wird nach jedem Durchlauf der Schleife um die Schrittweite erhöht, bis sie größer oder gleich dem Maximum ist. Alle drei Werte müssen numerisch sein, d.h. ein integer oder ein float. Die Schrittweite kann auch weggelassen werden. Sie ist dann automatisch 1.&lt;br /&gt;
Unser Beispiel von oben sähe mit einer for-Schleife so aus:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;for i=10, 0, -1 do&lt;br /&gt;
    print(i)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Die Variable i ist nur innerhalb der Schleife verfügbar. Damit sie auch nach der Schleife noch verfügbar ist, muss man sie schon vor der Schleife deklarieren.&lt;br /&gt;
====Generisch====&lt;br /&gt;
Die generische for-Schleife wird hauptsächlich dazu verwendet, um tables zu durchlaufen. Ich werde sie daher auch nur in diesem Zusammenhang erläutern.&lt;br /&gt;
Die Syntax für den Fall, dass man eine table durchlaufen will, ist:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;for [index], [wert] in pairs([tabelle]) do&lt;br /&gt;
    -- Anweisung(en)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Diese Schleife geht durch alle Elemente der Tabelle und führt die Anweisungen somit für alle Elemente der Tabelle aus, wobei Index jedes Mal dem aktuellen Index des Tabellenelements und Wert jedes Mal dem aktuellen Wert des Tabellenelements entspricht.&lt;br /&gt;
Anstelle von pairs() kann man auch ipairs() nehmen, wenn man nur alle ganzzahligen Indizes durchlaufen möchte.&lt;br /&gt;
Hier mal ein Beispiel:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle = { eins = 1, &amp;quot;hallo&amp;quot;, pi = 3.14159 }&lt;br /&gt;
&lt;br /&gt;
-- mit pairs&lt;br /&gt;
for index, wert in pairs(tabelle) do&lt;br /&gt;
  print(tostring(index)..&amp;quot;=&amp;quot;..tostring(wert)..&amp;quot;, &amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
-- Ausgabe: &amp;quot;eins=1, 1=hallo, pi=3.14159, &amp;quot;&lt;br /&gt;
&lt;br /&gt;
-- mit ipairs&lt;br /&gt;
for index, wert in ipairs(tabelle) do&lt;br /&gt;
  print(tostring(index)..&amp;quot;=&amp;quot;..tostring(wert)..&amp;quot;, &amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
-- Ausgabe: &amp;quot;1=hallo, &amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
tostring() ist übrigens eine Funktion, die eine beliebige Variable in einen string umwandelt. Wenn man Variablen mit einem string verknüpfen will und sich nicht sicher ist, ob diese Variablen string sind oder nicht, sollte man auf jeden Fall diese Funktion verwenden, da ansonsten Fehler auftreten können. (Lua gibt einen Error aus, wenn man z.B. soetwas versucht: &amp;quot;Hallo &amp;quot;..nil..&amp;quot;.&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
===Schleifenabbruch===&lt;br /&gt;
Mit dem Schlüsselwort break kann man eine Schleife sofort abbrechen.&lt;br /&gt;
Hier ein kurzes Beispiel dazu:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local zahl = 10&lt;br /&gt;
while (true) do&lt;br /&gt;
    print(zahl)&lt;br /&gt;
    zahl = zahl - 1&lt;br /&gt;
    if (zahl &amp;lt; 0) then&lt;br /&gt;
        break&lt;br /&gt;
    end&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Diese Schleife würde auch alle Zahlen von 10 bis 0 nacheinander ausgeben, nur dass der Abbruch manuell erfolgt, wenn zahl negativ wird. Ohne diese Bedingung würde die Schleife endlos laufen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Funktionen==&lt;br /&gt;
===Einführung===&lt;br /&gt;
Funktionen sind im Grunde genommen Anweisungsblöcke, die - meist in Abhängigkeit von übergebenen Werten - mehrmals an unterschiedlichen Orten im Script bzw. zu unterschiedlichen Zeiten ausgeführt werden sollen.&lt;br /&gt;
Da eine Funktion - sofern sie mehr als einmal ausgeführt werden soll bzw. mehr als einmal benötigt wird - auch in einer Variable gespeichert werden kann, kann man den Variablentyp function einführen, der in Lua auch tatsächlich existiert.&lt;br /&gt;
Funktionen können Werte übergeben bekommen und auch Werte zurückgeben.&lt;br /&gt;
&lt;br /&gt;
===Definition===&lt;br /&gt;
Die allgemeine Syntax für das Definieren einer Funktion ist die folgende:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function [funktionsname]([parameterliste])&lt;br /&gt;
    -- Anweisung(en)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ein Beispiel für eine Funktion, die das Quadrat einer Zahl zurückgibt, wäre:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function quadrat(zahl)&lt;br /&gt;
    return zahl * zahl&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternativ kann eine Funktion übrigens auch so einer Variable zugewiesen werden:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;quadrat = function (zahl) return zahl * zahl end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Rückgabewerte===&lt;br /&gt;
return wird verwendet, um die Funktion einen Wert zurückgeben zu lassen. Nach einem return-Befehl bricht die Funktion alle Tätigkeiten ab und ist beendet.&lt;br /&gt;
Um einen Rückgabewert verwenden zu können, müssen wir aber ersteinmal wissen, wie man eine Funktion dazu bringt, die Anweisungen, die sie enthält, auszuführen.&lt;br /&gt;
Das geht allgemein mit funktionsname(parameterliste).&lt;br /&gt;
Als Beispiel für unsere quadrat-Funktion:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local vier = quadrat(2)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wenn wir quadrat(2) ausführen, dann wird der obrige Code ausgeführt, wobei die Variable zahl den Wert 2 zugewiesen bekommt. zahl ist dabei jedoch nur innerhalb der Funktion definiert.&lt;br /&gt;
Die Variable vier bekommt nun den Wert 2 * 2, also 4 zugewiesen.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local vier = quadrat&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
würde die Funktion quadrat in die Variable vier kopieren. Man könnte nun also auch vier(2) aufrufen, um 4 zu bekommen.&lt;br /&gt;
&lt;br /&gt;
Eine Funktion kann auch mehrere Funktionswerte zurückgeben. Das ist vor allem dann sinnvoll, wenn es sich um Positionen handelt, was bei MTA ja nicht selten vorkommt.&lt;br /&gt;
Beispiel:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function berechnungen(zahl1, zahl2)&lt;br /&gt;
    return zahl1 + zahl2, zahl1 - zahl2, zahl1 * zahl2, zahl1 / zahl2&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local summe, differenz, produkt, quotient = berechnungen(5, 10)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Damit wird summe = 15, differenz = -5, produkt = 50 und quotient = 0.5.&lt;br /&gt;
&lt;br /&gt;
===Lua Standardfunktionen===&lt;br /&gt;
Funktionen wie tostring, print und math.random sind Standardfunktionen von Lua. Eine komplette Liste aller Lua Standardfunktionen bekommt ihr auf der [http://www.lua.org/manual/5.1/#index offiziellen Lua Webseite] (Englisch).&lt;br /&gt;
&lt;br /&gt;
Die Standard-string-Funktionen erlauben eine besondere Syntax, die ich hier kurz erläutern möchte, da sie von vielen erfahrenen Scriptern genutzt wird und es hilfreich ist, wenn man etwas damit anfangen kann.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local name = &amp;quot;Firzen Polas&amp;quot;&lt;br /&gt;
local laenge = string.len(name)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Dieser Code weist der Variable laenge die Länge des strings &amp;quot;Firzen Polas&amp;quot;, also 12, zu.&lt;br /&gt;
Alternativ kann man auch den folgenden Code verwenden:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local name = &amp;quot;Firzen Polas&amp;quot;&lt;br /&gt;
local laenge = name:len()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Vorraussetzung ist, dass die Variable vor dem Doppelpunkt ein string ist. Bei den math- und table-Funktionen funktioniert dies nicht.&lt;br /&gt;
&lt;br /&gt;
===Rekursive Funktionen===&lt;br /&gt;
Rekursive Funktionen sind eine effektive Alternative zu Schleifen - zumindest in manchen seltenen Fällen. Das berühmteste Beispiel ist das Berechnen einer Fakultät.&lt;br /&gt;
Zur Information: n! (sprich: n Fakultät) bezeichnet das Produkt aller Ganzzahlen von n bis 1, also quasi 1*2*3*4*...*n.&lt;br /&gt;
Beispiel: 3! = 1 * 2 * 3 = 6&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function fakultaet(zahl)&lt;br /&gt;
    if (zahl &amp;gt; 0) then&lt;br /&gt;
        return zahl * fakultaet(zahl - 1)&lt;br /&gt;
    else&lt;br /&gt;
        return 1&lt;br /&gt;
    end&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Mit Schleife sähe das so aus:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function fakultaet(zahl)&lt;br /&gt;
    if (zahl == 0) then&lt;br /&gt;
        return 1&lt;br /&gt;
    end&lt;br /&gt;
    for i=zahl-1, 1, -1 do&lt;br /&gt;
        zahl = zahl * i&lt;br /&gt;
    end&lt;br /&gt;
    return zahl&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Variable Parameterzahl===&lt;br /&gt;
Manchmal benötigt eine Funktion nicht zwingend eine bestimmte Anzahl von Parametern oder soll eine variable Anzahl an Parametern akzeptieren.&lt;br /&gt;
Dies lässt sich realisieren mit drei Punkten am Ende der Parameterliste.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function aufsummieren(...)&lt;br /&gt;
    local parameter = {...}&lt;br /&gt;
    local summe = 0&lt;br /&gt;
    for _, zahl in pairs(parameter)&lt;br /&gt;
        summe = summe + tonumber(zahl)&lt;br /&gt;
    end&lt;br /&gt;
    return summe&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
... entspricht dabei innerhalb der Funktion der Parameterliste als normale Liste.&lt;br /&gt;
D.h., wenn man aufsummieren(1, 2, 3, 4) aufruft, dann wird parameter = {1, 2, 3, 4}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Fragen, Anregungen, Kritik==&lt;br /&gt;
Sollten noch irgendwelche Fragen offen sein, so könnt ihr jederzeit in unserem [irc://irc.gtanet.com/#mta.german IRC Channel] oder in unserem [http://mtasa.ath.cx/wbblite/ Forum] vorbeischauen und eure Fragen dort loswerden.&lt;br /&gt;
Außerdem haben wir in unserem IRC Channel einen Lua Bot, an dem ihr Funktionen, die auf den standard Lua Funktionen basieren, ausprobieren könnt.&lt;br /&gt;
&lt;br /&gt;
Anregungen und Kritik nehme ich dort auch entgegen. Alternativ könnt ihr diese hier in die Diskussion schreiben.&lt;br /&gt;
Falls ihr Fehler findet, behebt diese bitte oder gebt mir bescheid.&lt;br /&gt;
&lt;br /&gt;
Ich hoffe, das Tutorial konnte euch weiterhelfen. Demnächst wird es noch ein weiteres Tutorial geben, was auf MTA spezialisiert ist und grundlegende Techniken und Möglichkeiten erklärt.&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DE/Lua_Tutorial&amp;diff=20530</id>
		<title>DE/Lua Tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DE/Lua_Tutorial&amp;diff=20530"/>
		<updated>2009-07-10T14:41:20Z</updated>

		<summary type="html">&lt;p&gt;Dragon: /* For-Schleife */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
==Vorwort==&lt;br /&gt;
Da es bis auf einige knappe und teils unprofessionelle Tutorials kein deutsches Lua Tutorial gibt, habe ich beschlossen, nun ein eigenes zu schreiben, welches alle für MTA notwendigen Grundlagen einfach und übersichtlich erklärt.&lt;br /&gt;
Weiterführende Möglichkeiten und Funktionen können der [http://www.lua.org/manual/5.1/ Offiziellen Lua Dokumentation] entnommen werden, die es jedoch nicht auf Deutsch gibt.&lt;br /&gt;
&lt;br /&gt;
Ein weiterer Grund ist, dass ich schon von einigen gehört habe und auch so schon den Verdacht hatte, dass MTA einfach so wenige deutsche Spieler und vor allem Server hat (gibt es überhaupt '''einen''' deutschen?), weil die meisten Probleme mit den englischen Dokumentationen haben oder der Meinung sind, dass für MTA ja sowieso kein deutscher Support vorhanden ist.&lt;br /&gt;
&lt;br /&gt;
Soviel nun dazu, wie es zu der Idee des deutschen Lua Tutorials kam.&lt;br /&gt;
Fangen wir an mit dem Erlernen einer neuen Sprache!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Grundlagen==&lt;br /&gt;
===Lua, eine Skriptsprache===&lt;br /&gt;
Lua (portugiesisch für Mond) ist eine Skriptsprache zum Einbinden in Programme, um diese leichter weiterentwickeln und warten zu können. Insbesondere die geringe Größe des Interpreters von 120 KB und die hohe Geschwindigkeit verglichen mit anderen Skriptsprachen überzeugen viele Entwickler davon, Lua einzusetzen.&lt;br /&gt;
&lt;br /&gt;
Die Syntax lehnt sich an die von Pascal an, was besonders Anfängern den Einstieg in Lua erleichtert. Im Gegensatz zu von Pascal abgeleiteten Sprachen nutzt Lua jedoch „==“ und nicht „=“ als Vergleichsoperator.&lt;br /&gt;
&lt;br /&gt;
(Quelle: [http://de.wikipedia.org/wiki/Lua Wikipedia])&lt;br /&gt;
&lt;br /&gt;
Einige werden sich bei dieser Einführung vielleicht gefragt haben, was der Unterschied zwischen Skript- und Programmiersprache ist und was ein Interpreter sein soll. Im folgenden will ich diese beiden Fragen so kurz und einfach wie möglich klären.&lt;br /&gt;
&lt;br /&gt;
Eine '''Programmiersprache''' (z.B. C, C++, Pascal, Delphi) wird - wie der Name schon sagt - verwendet, um Programme zu schreiben. Ein Programm liegt bekannterweise in Form einer Executable (*.exe) vor. Diese kann weitgehend unabhängig von irgendwelchen Betriebssystemen oder der Umgebung selbstständig ausgeführt werden (z.B. durch Doppelklick). Weitgehend deswegen, da einige Programme aufgrund von Speicherersparnissen sogenannte Programmbibliotheken (original Dynamic Link Library, kurz dll) benötigen, um zu funktionieren. Erklärungen dazu findet ihr [http://de.wikipedia.org/wiki/Dynamic_Link_Library hier].&amp;lt;br&amp;gt;&lt;br /&gt;
Um einen Programmquellcode, d.h. einen Text, der in einer Programmiersprache geschrieben wurde, aus dem Textdokumentformat in eine Anwendung (original Executable, kurz exe) umzuwandeln, benötigt man nun einen Compiler (zu Deutsch Kompilierer oder Übersetzer), der die Programmiersprache aus der menschenlesbaren Form in die maschinenlesbare Form umwandelt. Neben dieser Hauptaufgabe übernimmt der Compiler natürlich noch weitere Aufgaben, auf die ich jetzt aber nicht genauer eingehen werde. Infos dazu findet ihr [http://de.wikipedia.org/wiki/Compiler hier].&amp;lt;br&amp;gt;&lt;br /&gt;
Die maschinenlesbare Form ist für Menschen unlesbar.&lt;br /&gt;
&lt;br /&gt;
Eine '''Skriptsprache''' (z.B. JavaScript, DOS-Batch(Win) bzw. Shell-Scripts(UNIX)) hingegen liegt standardmäßig in der menschenlesbaren Form vor. Skriptsprachen werden - wie im ersten Satz bereits erwähnt - vor allem von Programmen benutzt, um benutzerdefinierte Abläufe verwenden zu können. Zur Ausführung von Scripts wird ein sogenannter Interpreter benötigt, der das Skript liest und es Schritt für Schritt in die Maschinensprache umwandelt und ausführt. Manche Skriptsprachen kann man mit einem Precompiler (zu Deutsch Vorkompilierer oder Vorübersetzer) vorkompilieren. Diesen könnte man auch den Vorkauer vom Interpreter nennen, da er das Script schon zum Teil in die Maschinensprache umwandelt, jedoch nicht so extrem wie der Compiler der Programmiersprachen. Das Ergebnis davon ist logischerweise die schnellere Ausführung des Skripts.&lt;br /&gt;
&lt;br /&gt;
Genug der langweiligen Definitionen. Klären wir lieber, was man denn alles braucht, um ein Lua Script zu schreiben.&lt;br /&gt;
&lt;br /&gt;
===Materialien===&lt;br /&gt;
Lua Skripte werden üblicherweise als Textdateien mit der Endung .lua gespeichert. Die Endung ist jedoch nicht von belang. Es kann jede beliebige Endung gewählt werden.&lt;br /&gt;
&lt;br /&gt;
Wie jede normale Textdatei kann man also auch Lua Skripte mit dem standard Texteditor des vorhandenen Betriebssystems schreiben, editieren und lesen. Ich persönlich empfehle jedoch das Programm Notepad++, welches [http://notepad-plus.sourceforge.net/de/site.htm hier] heruntergeladen werden kann. Das Programm ist Freeware und wird regelmäßig aktualisiert und erweitert. Der Vorteil daran ist, dass es ein professionelles Syntax-Highlighting eingebaut hat, welches Schlagwörter und Standardfunktionen farblich oder anderweitig hervorhebt und somit die Übersichtlichkeit erheblich verbessert.&amp;lt;br&amp;gt;&lt;br /&gt;
Standardmäßig wird die Sprache Lua automatisch an der Dateiendung .lua erkannt, solltest Du eine andere Endung verwenden und trotzdem das Lua Syntax-Highlighting verwenden wollen, kannst Du es oben im Menü „Sprachen“ einstellen.&lt;br /&gt;
&lt;br /&gt;
Wer ohne MTA seine kleinen Lua Skripte testen oder ausführen möchte, kann sich [http://luabinaries.luaforge.net/download.html hier] einen kostenlosen standalone Interpreter herunterladen. Wenn Du Dir nicht sicher bist, welche Windows Edition Du hast, dann hast Du wahrscheinlich eine 32 Bit Version, welche auf dieser Seite der „Windows x86 Executables“ entspricht. Die aktuelle Version (Win 32 Bit) dafür gibt es bei einem Klick auf [http://luaforge.net/frs/download.php/3134/lua5_1_3_Win32_bin.zip lua5_1_3_Win32_bin.zip].&amp;lt;br&amp;gt;&lt;br /&gt;
Nach dem Download kann der Standalone Interpreter mit einem Doppelklick auf die „lua5.1.exe“ gestartet werden. Dort kann man dann direkt Lua Befehle eingeben oder ein Script laden. Dies geht wie folgt:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;dofile(&amp;quot;dateiname.lua&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Kommentare==&lt;br /&gt;
Um sein Skript übersichtlicher zu gestalten, kann man mit Kommentaren bestimmte Zeilen eräutern, Bereiche abgrenzen, alten Code deaktivieren, ohne ihn zu entfernen und generell das Skript übersichtlicher gestalten.&amp;lt;br&amp;gt;&lt;br /&gt;
Kommentare werden vom Interpreter vollkommen ignoriert und sind nur für den Menschen lesbar und von Belang.&lt;br /&gt;
&lt;br /&gt;
===Einzeilig===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;-- Dies ist ein einzeiliger Kommentar. Er gilt von -- bis zum Ende dieser Zeile. Automatische Zeilenumbrüche, die eingefügt werden, wenn die Zeilenlänge überschritten wurde, zählen nicht.&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mehrzeilig===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;--[[ Dieser Kommentar&lt;br /&gt;
     geht über beliebig viele Zeilen&lt;br /&gt;
     und endet mit ]]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Variablen==&lt;br /&gt;
===Einführung===&lt;br /&gt;
Eine Variable kann man sich wie eine kleine Kiste vorstellen, auf der außen ein Bezeichner (oder Name) steht und die einen Wert enthält. Während der Bezeichner immer gleich ist, kann der Inhalt variieren.&lt;br /&gt;
Jede Variable hat einen Variablentypen, der bei Programmiersprachen normalerweise zu Beginn des Programmes fest definiert wird und sich nicht ändern kann. Da Lua aber ja keine Programmiersprache ist, muss der Variablentyp zu Beginn und auch sonst nie festgelegt werden und kann sich beliebig oft verändern. Der Interpreter erkennt Variablentypen automatisch und nimmt dem Skripter somit eine Menge Arbeit (vor allem bzgl. der Planung) ab.&lt;br /&gt;
&lt;br /&gt;
===Typen===&lt;br /&gt;
Im Folgenden will ich die wichtigsten Variablentypen auflisten und kurz beschreiben.&lt;br /&gt;
;Integer (ganze Zahlen)&lt;br /&gt;
:Umfasst alle Ganzzahlen, sowohl negative als auch positive.&lt;br /&gt;
:Beispiele: -8, 0, 12, 2&lt;br /&gt;
;Float (Komma- bzw. gebrochene Zahlen)&lt;br /&gt;
:Umfasst alle Fließkommazahlen, sowohl negative als auch positive. Wichtig dabei ist, dass anstelle des Kommas (,) ein Dezimalpunkt (.) zum Trennen des ganzen vom gebrochenen Teil verwendet werden muss.&lt;br /&gt;
:Beispiele: -77.2, 0.0, 3.14159, 9.81&lt;br /&gt;
;String (Zeichenkette)&lt;br /&gt;
:Kann jedes beliebige Zeichen enthalten. Eine maximale Länge ist mir nicht bekannt. Strings müssen immer in Anführungszeichen(&amp;quot; oder ') eingschlossen werden.&lt;br /&gt;
:Beispiele: &amp;quot;hallo&amp;quot;, 'Lua ist toll!', &amp;quot;&amp;quot;, &amp;quot; :D &amp;quot;&lt;br /&gt;
;Boolean (Schalter)&lt;br /&gt;
:Kann zwei verschiedene Werte enthalten: ''true'' (dt. wahr bzw. an) oder ''false'' (dt. falsch bzw. aus). ''true'' entspricht dabei nicht dem Wert 1 und ''false'' nicht dem Wert 0.&lt;br /&gt;
:Beispiele: ''true'', ''false''&lt;br /&gt;
;Nil (Leer oder Nichts)&lt;br /&gt;
:''nil'' ist sowohl ein Wert als auch ein Typ. Eine Variable vom Typ ''nil'' enthält automatisch den Wert ''nil''. ''nil'' bedeutet ganz einfach nichts. Wenn eine Variable ''nil'' ist, existiert sie nicht. ''nil'' entspricht weder dem Wert 0 noch dem Wert ''false'' noch dem Wert &amp;quot;&amp;quot;!&lt;br /&gt;
:Beispiele: ''nil''&lt;br /&gt;
Ich werde auf jeden Variablentypen noch detaillierter eingehen. Außerdem wurden hier die Variablentypen '''function''', '''table''' und '''userdata''' nicht aufgeführt, da diese jeweils ein eigenes Kapitel bekommen.&lt;br /&gt;
&lt;br /&gt;
===Definition===&lt;br /&gt;
Eine Variable definieren bedeutet im Grunde genommen eine Variable anlegen. In Lua muss einer Variable bei der Definition ein Wert zugewiesen werden. ''nil'' ist dabei als Wert auch möglich, macht jedoch wenig Sinn, da jede beliebige Variablenbezeichnung automatisch den Wert ''nil'' enthält.&lt;br /&gt;
&lt;br /&gt;
Man unterscheidet zwischen '''lokalen''' und '''globalen''' Variablen. Um eine Variable als lokal zu definieren muss das Schlüsselwort ''local'' davor geschrieben werden. Lokal bedeutet für uns im Moment noch ganz einfach, dass die Variable nur im aktuellen Script verfügbar ist. Sollten also z.B. von einem Programm zwei verschiedene Lua Skripte geladen sein und benutzt werden, können diese untereinander auf die globalen Variablen des jeweils anderen Skripts zugreifen, auf die lokalen jedoch nicht. Generell empfiehlt es sich, immer lokale Variablen zu nehmen, falls man nicht explizit eine globale benötigt, da so vermieden wird, dass mehrere parallel laufende Skripte aufgrund von gleichen Variablenbezeichnern durcheinander kommen.&lt;br /&gt;
&lt;br /&gt;
====Einzeln====&lt;br /&gt;
Definieren wir uns also nun unsere erste lokale Variable und geben ihr einen ganzzahligen Inhalt:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local zahl = 7 -- weist der lokalen Variable zahl den Wert 7 zu&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Eine globale Variable erhält man, indem man einfach das ''local'' weglässt:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;gZahl = 13 -- weist der globalen Variable gZahl den Wert 13 zu&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Das selbe geht natürlich nun auch mit allen anderen Variablentypen:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local ganzzahl = -5&lt;br /&gt;
local kommazahl = 0.008&lt;br /&gt;
local zeichenkette = &amp;quot;Hello World&amp;quot;&lt;br /&gt;
local schalter = true&lt;br /&gt;
local nichts = nil -- diese Zeile kann man sich im Grunde genommen sparen, da jede nicht definierte Variable automatisch den Wert nil hat&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Längere Strings mit mehreren Zeilenumbrüchen können in einer vereinfachten Weise zugewiesen werden. Dies funktioniert so ähnlich wie bei Kommentaren. Anstelle von Anführungszeichen verwendet man [[ als Anfangs- und ]] als Endmarkierung des Strings.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local text = [[Willkommen auf unserem Server.&lt;br /&gt;
Bitte halte Dich an die Regeln.&lt;br /&gt;
MfG die Administration]]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Alternativ kann in einem String, der in doppelten Anführungszeichen (&amp;quot;) eingeschlossen ist, folgende Steuerzeichen enthalten:&lt;br /&gt;
;\n&lt;br /&gt;
:Entspricht einem Zeilenumbruch.&lt;br /&gt;
;\t&lt;br /&gt;
:Entspricht einem Tabulator.&lt;br /&gt;
;\&amp;quot;&lt;br /&gt;
:Wird verwendet, um doppelte Anführungszeichen in einem String, der von doppelten Anführungszeichen eingeschlossen ist, darzustellen, ohne dass der Interpreter diese fälschlicherweise als Stringende auffasst.&lt;br /&gt;
;\'&lt;br /&gt;
:Wie \&amp;quot;, nur gilt dies in Strings, die von einfachen Anführungszeichen eingeschlossen sind.&lt;br /&gt;
;\\&lt;br /&gt;
:Entspricht einem Backslash (\)&lt;br /&gt;
&lt;br /&gt;
====Mehrere====&lt;br /&gt;
Man kann in einer Zeile mehrere Variablen definieren, indem man sie mit Kommas voneinander trennt. Die Variablentypen können dabei alle unterschiedlich sein. Hier mal ein Beispiel:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local frucht, anzahl, reif = &amp;quot;apfel&amp;quot;, 4, true&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''local'' darf dabei nur einmal am Zeilenanfang stehen und bewirkt, dass alle dahinter aufgelisteten Variablen lokal werden.&amp;lt;br&amp;gt;&lt;br /&gt;
Sollten links neben dem Gleichheitszeichen mehr Variablenbezeichner stehen als rechts Werte, so bleiben die überschüssigen Variablen ''nil''. Im umgekehrten Fall werden überschüssige Werte rechts einfach ignoriert.&lt;br /&gt;
&lt;br /&gt;
==Operatoren==&lt;br /&gt;
===Arithmetische===&lt;br /&gt;
Arithmetische Operatoren werden verwendet, um Berechnungen durchzuführen. Somit kann man entweder mit Variablen, festen Zahlen oder einer Mischung neue Werte berechnen oder verändern.&amp;lt;br&amp;gt;&lt;br /&gt;
Bei Berechnungen gilt stets: '''Punkt- vor Strichrechnung'''.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
;Plus (+)&lt;br /&gt;
:Addiert zwei Werte miteinander.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a, b = 3, 8&lt;br /&gt;
local c = a + b -- a + b entspricht hier der Rechnung 3 + 8, c erhält nun also den Wert 11&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Minus (-)&lt;br /&gt;
:Subtrahiert den zweiten vom ersten Wert.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a, b = 3, 8&lt;br /&gt;
local c = a - b -- a - b entspricht hier der Rechnung 3 - 8, c erhält nun also den Wert -5&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Mal (*)&lt;br /&gt;
:Multipliziert zwei Werte miteinander.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a, b = 3, 8&lt;br /&gt;
local c = a * b -- a * b entspricht hier der Rechnung 3 * 8, c erhält nun also den Wert 24&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Geteilt (/)&lt;br /&gt;
:Dividiert den ersten durch den zweiten Wert. Hierbei entsteht in den meisten Fällen eine Kommazahl!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a, b = 3, 8&lt;br /&gt;
local c = a / b -- a / b entspricht hier der Rechnung 3 / 8, c erhält nun also den Wert 0.375&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Modulo (%)&lt;br /&gt;
:Ermittelt den Rest, der übrig bleibt, wenn man die erste Zahl durch die zweite teilt.&lt;br /&gt;
:Der Modulo-Operator gehört zur Punktrechnung.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a, b = 14, 3&lt;br /&gt;
local c = a % b -- a % b entspricht hier der Rechnung 14 % 3, c erhält nun also den Wert 2, da 14 / 3 = 4 REST 2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Minus (-) (als Vorzeichen)&lt;br /&gt;
:Dient zur Darstellung einer negativen Zahl, also einer Zahl unter 0.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = -3 -- entspricht der Rechnung a = 0 - 3&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Hoch (^)&lt;br /&gt;
:Potenziert die erste Zahl mit der zweiten.&lt;br /&gt;
:Potenzen werden noch '''vor''' der Punktrechnung ausgerechnet.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a, b = 3, 8&lt;br /&gt;
local c = a ^ b -- a ^ b entspricht hier der Rechnung 3 ^ 8 (3&amp;lt;sup&amp;gt;8&amp;lt;/sup&amp;gt;), c erhält nun also den Wert 6561&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logische===&lt;br /&gt;
Logische Operatoren werden Benutzt, um Werte miteinander zu vergleichen und mehrere Bedingungen zu verknüpfen. Wir werden genauer auf sie zurückkommen, wenn es um Bedingungen geht. Bis dahin reicht es, wenn man sich merkt, dass ein logischer Vergleich entweder ''true'' (wenn die Aussage wahr ist) oder ''false'' (wenn die Aussage falsch ist) ergibt.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
;Gleich (==)&lt;br /&gt;
:Prüft, ob zwei Werte gleich sind.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (5 == 5) -- a ist true, da die Aussage wahr ist&lt;br /&gt;
local b = (5 == 8) -- b ist false, da die Aussage falsch ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Ungleich (~=)&lt;br /&gt;
:Prüft, ob zwei Werte ungleich sind.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (5 ~= 5) -- a ist false, da die Aussage falsch ist&lt;br /&gt;
local b = (5 ~= 8) -- b ist true, da die Aussage wahr ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Größer als (&amp;gt;)&lt;br /&gt;
:Prüft, ob der erste Wert größer als der zweite ist.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (5 &amp;gt; 5) -- a ist false, da die Aussage falsch ist&lt;br /&gt;
local b = (5 &amp;gt; 8) -- b ist false, da die Aussage falsch ist&lt;br /&gt;
local c = (8 &amp;gt; 5) -- c ist true, da die Aussage wahr ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Größer als oder gleich (&amp;gt;=)&lt;br /&gt;
:Prüft, ob der erste Wert größer als der zweite ist oder dem zweiten gleicht.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (5 &amp;gt;= 5) -- a ist true, da die Aussage wahr ist&lt;br /&gt;
local b = (5 &amp;gt;= 8) -- b ist false, da die Aussage falsch ist&lt;br /&gt;
local c = (8 &amp;gt;= 5) -- c ist true, da die Aussage wahr ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Kleiner als (&amp;lt;)&lt;br /&gt;
:Prüft, ob der erste Wert kleiner als der zweite ist.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (5 &amp;lt; 5) -- a ist false, da die Aussage falsch ist&lt;br /&gt;
local b = (5 &amp;lt; 8) -- b ist true, da die Aussage wahr ist&lt;br /&gt;
local c = (8 &amp;lt; 5) -- c ist false, da die Aussage falsch ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Kleiner als oder gleich (&amp;lt;=)&lt;br /&gt;
:Prüft, ob der erste Wert kleiner als der zweite ist oder dem zweiten gleicht.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (5 &amp;lt;= 5) -- a ist true, da die Aussage wahr ist&lt;br /&gt;
local b = (5 &amp;lt;= 8) -- b ist true, da die Aussage wahr ist&lt;br /&gt;
local c = (8 &amp;lt;= 5) -- c ist false, da die Aussage falsch ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Und (and)&lt;br /&gt;
:Verknüpft zwei Bedingungen miteinander.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (true and false) -- a ist false, da nicht beide Aussagen wahr sind&lt;br /&gt;
local b = (5 &amp;lt; 8) and (7 == 7) -- b ist true, da beide Aussagen wahr sind&lt;br /&gt;
local c = (8 &amp;gt; 5) and (1 ~= 2) and (0 &amp;lt;= -7) -- c ist false, da die dritte Aussage falsch ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Oder (or)&lt;br /&gt;
:Verknüpft zwei Bedingungen miteinander.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = (true or false) -- a ist true, da die erste Aussage wahr ist&lt;br /&gt;
local b = (5 &amp;lt; 8) or (7 == 7) -- b ist true, da mindestens eine der Aussagen wahr ist&lt;br /&gt;
local c = (8 &amp;gt; 5) or (1 ~= 2) or (0 &amp;lt;= -7) -- c ist true, da mindestens eine der Aussagen wahr ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Nicht (not)&lt;br /&gt;
:Kehrt einen Booleanwert um.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local a = not true -- a ist false&lt;br /&gt;
local b = not false -- b ist true&lt;br /&gt;
local c = not (0 == 8) -- c ist true, da die Aussage falsch ist&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Sonstige===&lt;br /&gt;
Lua hat noch zwei weitere Operatoren, die sich jedoch nicht in die oberen Gruppen eingliedern lassen.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Länge (#)&lt;br /&gt;
:Steht für die Länge eines Strings oder einer Table.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local sprache = &amp;quot;deutsch&amp;quot;&lt;br /&gt;
local laenge = #sprache -- laenge wird hier auf 7 gesetzt, da das Wort &amp;quot;deutsch&amp;quot; 7 Buchstaben hat&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
;Verknüpfung (..)&lt;br /&gt;
:Verknüpft zwei Strings miteinander.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local geschlecht, alter = &amp;quot;männlich&amp;quot;, &amp;quot;18&amp;quot;&lt;br /&gt;
local satz = &amp;quot;Ich bin &amp;quot;..geschlecht..&amp;quot; und &amp;quot;..alter..&amp;quot; Jahre alt.&amp;quot; -- weist satz den Wert &amp;quot;Ich bin männlich und 18 Jahre alt.&amp;quot; zu&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Natürlich können auch alle anderen Variablentypen mit- und untereinander verglichen werden.&amp;lt;br&amp;gt;&lt;br /&gt;
Der Längenoperator (#) sowie der Verknüpfungsoperator (..) sind nur für Strings gedacht, wobei der erste später noch bei Tables eine Rolle spielen wird und der zweite es nicht so genau nimmt mit den Variablentypen. Bei Booleans und ''nil'' jedoch führt er in jedem Fall zu einem Fehler. Wir kommen später noch darauf zu sprechen, wie man soetwas umgeht.&amp;lt;br&amp;gt;&lt;br /&gt;
Für Integer und Floats sind alle Vergleichsoperatoren und die arithmetischen verfügbar. Strings unterstützen nur die Vergleichsoperatoren, wobei man mit den größer/kleiner Operatoren zwei Strings nach dem Alphabet ordnen kann.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&amp;quot;a&amp;quot; &amp;lt; &amp;quot;b&amp;quot; -- ergibt true, da a vor b im Alphabet kommt&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Strings, Booleans und ''nil'' kann man nur untereinander vergleichen, nicht miteinander. Miteinander führt in jedem Fall zu ''false''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Bedingungen==&lt;br /&gt;
===Einführung===&lt;br /&gt;
Bedingungen sind dazu da, um bestimmte Anweisungen nur auszuführen, wenn ein bestimmter Sachverhalt gegeben ist.&lt;br /&gt;
Ein Beispiel wäre, wenn ein Spieler einem anderen Spieler eine private Nachricht senden möchte. Dann kann er das natürlich nur tun, wenn der adressierte Spieler auch online ist.&lt;br /&gt;
Also soll die Nachricht in einem solchen Fall gesendet werden, andernfalls dem Sender jedoch eine Fehlermeldung ausgegeben werden.&lt;br /&gt;
&lt;br /&gt;
===Syntax===&lt;br /&gt;
Die Syntax einer Bedingung, die man übrigens auch „if-Statement“ (if = engl. für wenn) oder im Englischen „condition“ nennt, ist recht simpel.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;if &amp;lt;bedingung&amp;gt; then&lt;br /&gt;
    -- Anweisung(en), die ausgeführt werden soll(en), wenn die Bedingung wahr (=true) ist&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Für &amp;lt;bedingung&amp;gt; darf hier jeder Audruck eingesetzt werden, der letztendlich irgendeinen Wert ergibt.&lt;br /&gt;
Sollte &amp;lt;bedingung&amp;gt; ''nil'' oder ''false'' sein, so wird die Anweisung zwischen then und end nicht ausgeführt, andernfalls wird sie ausgeführt.&lt;br /&gt;
&lt;br /&gt;
===Else-Statement===&lt;br /&gt;
Auf jedes if-Statement darf ein else-Statement (else = engl. für sonst) folgen. Dieses benötigt kein then und auch keine Bedingung, sondern wird ausgeführt, wenn die Bedingung des if-Statements ''nil'' oder ''false'' ist. Das else-Statement ist optional!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;if &amp;lt;bedingung&amp;gt; then&lt;br /&gt;
    -- Anweisung(en), die ausgeführt werden soll(en), wenn die Bedingung erfüllt wird&lt;br /&gt;
else&lt;br /&gt;
    -- Anweisung(en), die ausgeführt werden soll(en), wenn die Bedingung nicht erfüllt wird&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Elseif-Statement===&lt;br /&gt;
Das elseif-Statement ist ein spezielles Statement, was es erlaubt, einer unübersichtlichen Verschachtelung zu entgehen, indem es die Möglichkeit bietet, einem else-Statement auch eine Bedingung zu geben. Ein if-Statement darf beliebig viele elseif-Statements enthalten. Diese müssen jedoch zwischen dem if- und dem else-Statement (falls vorhanden) stehen. Für die Bedingung gilt hier das selbe, wie für das if-Statement. Wichtig ist, dass demnach auch hier ein then erforderlich ist. Genauso wie das else-Statement ist jedoch auch das elseif-Statement optional!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;if &amp;lt;bedingung1&amp;gt; then&lt;br /&gt;
    -- Anweisung(en), die ausgeführt werden soll(en), wenn die Bedingung 1 erfüllt wird&lt;br /&gt;
elseif &amp;lt;bedingung2&amp;gt; then&lt;br /&gt;
    -- Anweisung(en), die ausgeführt werden soll(en), wenn die Bedingung 2 erfüllt wird&lt;br /&gt;
else&lt;br /&gt;
    -- Anweisung(en), die ausgeführt werden soll(en), wenn weder Bedingung 1 noch Bedingung 2 erfüllt werden&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Bedingungen formulieren===&lt;br /&gt;
Bei der Bedingung eines if-Statements muss nicht zwangsläufig ein Boolean herauskommen. Wie bereits erwähnt, ist die Bedingung immer dann wahr, wenn sie weder ''nil'' noch ''false'' ist.&lt;br /&gt;
D.h., dass auch Werte wie 0, &amp;quot;Hallo&amp;quot; und 3.14159 als „wahr“ gelten. Natürlich ist das auch bei ''true'' der Fall.&lt;br /&gt;
&lt;br /&gt;
Um komplexere Bedingungen zu formulieren, werden auf jeden Fall die bereits aufgelisteten logischen Operatoren benötigt.&lt;br /&gt;
Mit diesen kann man für jeden nur erdenklichen Fall eine Bedingung formulieren.&lt;br /&gt;
&lt;br /&gt;
Wenn logische (Vergleichs-)Operatoren (==, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=) angewandt werden, kommt dabei immer ein Boolean raus, wie man auch schon an den gegebenen Beispielen erkennen kann.&lt;br /&gt;
Verknüfungen (and, or) sind dazu gedacht, um z.B. zu überprüfen, ob mehrere oder wenigstens eine Bedingung von vielen erfüllt werden oder nicht. Der not-Operator ermöglicht es, zu überprüfen, ob eine Bedingung nicht erfüllt wird.&lt;br /&gt;
&lt;br /&gt;
Zu dem and- und dem or-Operator möchte ich an dieser Stelle noch etwas ergänzen. Der and-Operator wird zunächst einmal dazu verwendet, um herauszufinden, ob zwei Bedingungen gleichzeitig erfüllt sind. Der or-Operator wird dazu benutzt, um herauszufinden, ob eine von zweien oder beide Bedingungen erfüllt sind.&lt;br /&gt;
&lt;br /&gt;
Weder der and- noch der or-Operator geben aber zwangsläufig einen Boolean zurück.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local foo = wert1 and wert2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Sollte wert1 ''nil'' oder ''false'' sein, so entspricht dieser Ausdruck dem folgenden:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local foo = wert1&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Ist wert1 weder ''nil'' noch ''false'', so entspricht der Ausdruck dem hier:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local foo = wert2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Bei or ist es ähnlich, nur umgekehrt.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local foo = wert1 or wert2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Sollte wert1 ''nil'' oder ''false'' sein, so entspricht dieser Ausdruck dem folgenden:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local foo = wert2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Ist wert1 weder ''nil'' noch ''false'', so entspricht der Ausdruck dem hier:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local foo = wert1&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Beispiele===&lt;br /&gt;
====50-50-Chance====&lt;br /&gt;
Dieses Beispiel simuliert einen Münzwurf. math.random() und print() sind standard Lua-Funktionen. Zum Thema Funktionen komme ich später. Für dieses Beispiel reicht es, wenn ihr wisst, dass math.random() eine Zufallszahl (float) zwischen 0 und 1 zurückgibt und print(&amp;quot;text&amp;quot;) den in den Klammern eingeschlossenen String in die Konsole ausgibt.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local zufall = math.random()&lt;br /&gt;
if (zufall &amp;lt; 0.5) then&lt;br /&gt;
    print(&amp;quot;Kopf&amp;quot;)&lt;br /&gt;
else&lt;br /&gt;
    print(&amp;quot;Zahl&amp;quot;)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
====Der Nutzen von elseif====&lt;br /&gt;
Im Folgenden wollen wir herausfinden, ob eine Zahl positiv, negativ oder 0 ist. Dazu möchte ich zuerst ein Beispiel ohne und danach eines mit elseif zeigen, um meine Aussage, dass elseif Verschachtelungen spart, zu verifizieren.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local zahl = 14&lt;br /&gt;
&lt;br /&gt;
--ohne elseif&lt;br /&gt;
if (zahl &amp;lt; 0) then&lt;br /&gt;
    print(&amp;quot;Die Zahl ist negativ.&amp;quot;)&lt;br /&gt;
else&lt;br /&gt;
    if (zahl == 0) then&lt;br /&gt;
        print(&amp;quot;Die Zahl entspricht 0.&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
        print(&amp;quot;Die Zahl ist positiv.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--mit elseif&lt;br /&gt;
if (zahl &amp;lt; 0) then&lt;br /&gt;
    print(&amp;quot;Die Zahl ist negativ.&amp;quot;)&lt;br /&gt;
elseif (zahl == 0) then&lt;br /&gt;
    print(&amp;quot;Die Zahl entspricht 0.&amp;quot;)&lt;br /&gt;
else&lt;br /&gt;
    print(&amp;quot;Die Zahl ist positiv.&amp;quot;)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Je komplexer das ganze if-Statement, desto nützlicher wird elseif sein.&lt;br /&gt;
====Eingebettetes Pseudo-if-Statement====&lt;br /&gt;
In vielen Script- und Programmiersprachen gibt es ein gekürztes if-Statement. In Javascript z.B. geht das wie folgt:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;var nachricht = &amp;quot;Du benutzt zurzeit &amp;quot; + (ie ? &amp;quot;den Internet Explorer&amp;quot; : &amp;quot;einen guten Browser&amp;quot;) + &amp;quot;.&amp;quot;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Wir gehen dabei davon aus, dass in der Variable ie ein Boolean gespeichert ist, der ''true'' ist, wenn der Benutzer den Internet Explorer benutzt, ansonsten ''false''.&lt;br /&gt;
Diese Art von eingebetteten if-Statements gibt es noch in vielen anderen Sprachen, unter anderen in PHP, Java und C(++). In meinem Beispiel kann man sich das ? als then und den : als else vorstellen. Dann sollte es eigentlich nicht allzu schwer sein, diese Art von if-Statement zu verstehen.&lt;br /&gt;
&lt;br /&gt;
So direkt gibt es das bei Lua nicht, aber mit and und or kann man sich ein Konstrukt bauen, welches auf die gleiche Weise funktioniert. Dazu werde ich einfach mal das obere Beispiel in Lua umwandeln, auch, wenn Lua eigentlich nicht viel mit Browsern am Hut hat.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local nachricht = &amp;quot;Du benutzt zurzeit &amp;quot;..(ie and &amp;quot;den Internet Explorer&amp;quot; or &amp;quot;einen guten Browser&amp;quot;)..&amp;quot;.&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Zuerst ist das and an der Reihe. Es schmeißt den String &amp;quot;den Internet Explorer&amp;quot; raus, wenn ie ''false'' (oder ''nil'') ist und zurück bleibt auf jeden Fall ''false'' (oder ''nil''). Das wird dann vom or rausgeschmissen und zurück bleibt &amp;quot;einen guten Browser&amp;quot;.&lt;br /&gt;
Wenn ie weder ''false'' noch ''nil'' ist, schmeißt and die Vairable ie raus und zurück bleibt &amp;quot;den Internet Explorer&amp;quot;. Da dieser String weder ''false'' noch ''nil'' ist, wird er vom or beibelassen und &amp;quot;einen guten Browser&amp;quot; rausgeschmissen.&lt;br /&gt;
Entschuldigt meine Ausdrucksweise mit dem rausschmeißen, aber das schien mir die beste Möglichkeit, diese Methode verständlich zu erklären.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Tabellen==&lt;br /&gt;
===Einführung===&lt;br /&gt;
Tabellen sind spezielle Variablen, die mehrere Werte enthalten können.&lt;br /&gt;
Damit wir Tabellen verwenden können, führe ich nun erst einmal den Variablentyp „table“ ein. Mit einer table-Variable kann man ersteinmal kaum Operationen durchführen. Dazu benötigt man Funktionen, zu denen wir aber erst später kommen.&lt;br /&gt;
&lt;br /&gt;
===Definition===&lt;br /&gt;
Um eine Variable als (leere) table zu definieren, benutzt man diesen Ausdruck:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle = {}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ohne Funktionen macht das noch recht wenig Sinn. Um einer Tabelle direkt mehrere Werte zuzuweisen, schreibt man diese einfach durch Kommata getrennt zwischen die geschweiften Klammern.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle1 = { &amp;quot;Apfel&amp;quot;, 14, 3.14159, true }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Eine table kann alle möglichen Typen von Variablen enthalten. So zum Beispiel auch andere Tabellen.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle2 = { 1, { 1.25, 1.5, 1.75 }, 2, { 2.25, 2.5, 2.75 } }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Um nun auf die Elemente einer table zugreifen zu können, benutzt man Indizes (Indizes ist der Plural von Index). Jedes Element in einer table hat einen Index. Wenn man die Tabellen so definiert, wie ich es gemacht habe, so wird jedem Element ein integer als Index zugewiesen, wobei das erste Element die 1 als Index bekommt, das zweite die 2 usw.&lt;br /&gt;
Der ungefähre Wert von Pi (3.14159) in der oberen Tabelle hat den Index 3. Um anhand eines Indizes ein Element einer Tabelle abzufragen, schreibt man den Index einfach in eckigen Klammern hinter den Tabellennamen.&lt;br /&gt;
tabelle1[3] entspricht also dem Wert 3.14159.&lt;br /&gt;
Wenn das Element der Tabelle selbst noch eine Tabelle ist, wie z.B. das Element mit dem index 2 aus tabelle2, dann setzt man die Indizes einfach hintereinander. Der Wert 2.25 ist demnach in tabelle2[4][1] gespeichert.&lt;br /&gt;
&lt;br /&gt;
===Ganzzahlige Indizes===&lt;br /&gt;
Um gezielt bestimmten Indizes einen Wert zuzuweisen, kann man folgende Schreibweise verwenden:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local auskunft = { [11] = &amp;quot;elf&amp;quot;, [88] = &amp;quot;achtundachtzig&amp;quot;, [0] = &amp;quot;null&amp;quot; }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Dabei spielt es keine Rolle, in welcher Reihenfolge die Indizes einen Wert zugewiesen bekommen und es spiel auch keine Rolle, ob die Indizes positiv oder negativ sind.&lt;br /&gt;
Es muss jedoch beachtet werden, dass etwas wie { [1] = &amp;quot;eins&amp;quot;, &amp;quot;zwei&amp;quot; } dem Index 1 den Wert &amp;quot;zwei&amp;quot; zuweisen würde, da Lua immer bei 1 anfängt zu zählen, egal, ob der Scripter den Index 1 bereits definiert hat.&lt;br /&gt;
&lt;br /&gt;
===Zeichenketten als Indizes===&lt;br /&gt;
Ein Index kann auch ein String sein. Dazu verwendet man folgende Schreibweise:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;lua konstanten = { [&amp;quot;pi&amp;quot;] = 3.14159, [&amp;quot;e&amp;quot;] = 2.71828 }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Ansprechen kann man diese Werte genauso wie bei integer-Indizes. konstanten[&amp;quot;pi&amp;quot;] ist also 3.14159.&lt;br /&gt;
&lt;br /&gt;
Eine Besonderheit bei Zeichenketten als Index ist, dass es eine vereinfachte Schreibweise gibt. Sowohl bei der Definition als auch bei der Abfrage der Elemente. Das obige Beispiel kann auch so realisiert werden:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;lua konstanten = { pi = 3.14159, e = 2.71828 }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Zum Abfragen der Elemente kann man die Schreibweise konstanten.pi bzw. konstanten.e verwenden.&lt;br /&gt;
Man sollte aber bedenken, dass Schlüsselwörter wie z.B. if oder local als Indizes besser mit [&amp;quot;if&amp;quot;] und [&amp;quot;local&amp;quot;] definiert werden.&lt;br /&gt;
&lt;br /&gt;
===Beliebige Indizes===&lt;br /&gt;
Ein Index muss nicht unbedingt ein integer oder ein string sein. Genauer gesagt kann ein Index ein beliebiger Wert (außer ''nil'') sein.&lt;br /&gt;
Somit wäre z.B. auch das möglich:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle = { [true] = &amp;quot;wahr&amp;quot;, [3.14159] = &amp;quot;pi&amp;quot;, [0] = 1, 123 }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Die Zahl 123 hätte hier übrigens den Index 1.&lt;br /&gt;
&lt;br /&gt;
===Einzelzuweisungen===&lt;br /&gt;
Man muss nicht immer alle Werte einer table auf einmal definieren. Jedes Tabellenelement lässt sich wie eine normale Variable behandeln.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle = {}&lt;br /&gt;
tabelle[true] = &amp;quot;wahr&amp;quot;&lt;br /&gt;
tabelle.pi = 3.14159&lt;br /&gt;
tabelle[2] = { 1, 2, 3 }&lt;br /&gt;
tabelle[2][0] = 0&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jedes undefinierte Element hat - genauso wie jede undefinierte Variable - den Wert ''nil''.&lt;br /&gt;
&lt;br /&gt;
===Verlinkungen===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle1 = { 1, 2, 3 }&lt;br /&gt;
local tabelle2 = tabelle1&lt;br /&gt;
tabelle1[1] = 4&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In der zweiten Zeile dieses Beispiels wird die tabelle1 nicht in die Variable tabelle2 kopiert, sondern tabelle2 verweist ab sofort auf tabelle1. Am Ende des Codes wäre also tabelle2[1] auch 4, obwohl es nicht explizit zugewiesen wurde.&lt;br /&gt;
&lt;br /&gt;
Um eine Tabelle zu kopieren, könnt ihr euch die Useful Function [[table.copy]] aus der Wiki kopieren und diese dazu verwenden.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Schleifen==&lt;br /&gt;
===Einführung===&lt;br /&gt;
Schleifen verwendet man immer dann, wenn man eine oder mehrere Anweisungen mehr als einmal direkt hintereinander ausführen möchte oder wenn man eine oder mehrere Anweisungen für jedes Element einer table ausführen möchte.&lt;br /&gt;
Es gibt drei verschiedene Arten von Schleifen. Diese werde ich jetzt hier einzeln vorstellen.&lt;br /&gt;
&lt;br /&gt;
===While-Schleife===&lt;br /&gt;
Die while-Schleife wiederholt eine oder mehrere Anweisungen solange, bis eine bestimmte Bedingung nicht mehr erfüllt wird.&lt;br /&gt;
Die Syntax ist die folgende:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;while [bedingung] do&lt;br /&gt;
    -- Anweisung(en)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Beispiel:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local zahl = 10&lt;br /&gt;
while (zahl &amp;gt;= 0) do&lt;br /&gt;
    print(zahl)&lt;br /&gt;
    zahl = zahl - 1&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Das Beispiel gibt nacheinander alle Zahlen von 10 bis 0 aus. Nach der Schleife hat zahl dann den Wert -1.&lt;br /&gt;
&lt;br /&gt;
===Repeat-Until-Schleife===&lt;br /&gt;
Die repeat-until-Schleife wiederholt eine oder mehrere Anweisungen solange, bis eine bestimmte Bedingung erfüllt ist. Sie führt diese Anweisung(en) aber in jedem Fall einmal aus.&lt;br /&gt;
Die Syntax lautet:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;repeat&lt;br /&gt;
    -- Anweisung(en)&lt;br /&gt;
until [bedingung]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Das obere Beispiel lässt sich hiermit wie folgt realisieren:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local zahl = 10&lt;br /&gt;
repeat&lt;br /&gt;
    print(zahl)&lt;br /&gt;
    zahl = zahl - 1&lt;br /&gt;
until (zahl &amp;lt; 0)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===For-Schleife===&lt;br /&gt;
Es gibt zwei verschiedene for-Schleifen. Einmal die einfache numerische for-Schleife und zum Anderen die generische for-Schleife, mit der man u.a. alle Elemente einer tabelle durchlaufen kann. Mit der generischen for-Schleife kann man noch ganz andere wesentlich komplexere Operationen durchführen, die ich hier aber nicht erklären werde, da sie auch - zumindest beim Scripten für MTA - nicht wirklich benötigt werden.&lt;br /&gt;
====Numerisch====&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;for [laufvariable], [maximum], [schrittweite] do&lt;br /&gt;
    -- Anweisung(en)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Die Laufvariable wird nach jedem Durchlauf der Schleife um die Schrittweite erhöht, bis sie größer oder gleich dem Maximum ist. Alle drei Werte müssen numerisch sein, d.h. ein integer oder ein float. Die Schrittweite kann auch weggelassen werden. Sie ist dann automatisch 1.&lt;br /&gt;
Unser Beispiel von oben sähe mit einer for-Schleife so aus:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;for i=10, 0, -1 do&lt;br /&gt;
    print(i)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Die Variable i ist nur innerhalb der Schleife verfügbar. Damit sie auch nach der Schleife noch verfügbar ist, muss man sie schon vor der Schleife deklarieren.&lt;br /&gt;
====Generisch====&lt;br /&gt;
Die generische for-Schleife wird hauptsächlich dazu verwendet, um tables zu durchlaufen. Ich werde sie daher auch nur in diesem Zusammenhang erläutern.&lt;br /&gt;
Die Syntax für den Fall, dass man eine table durchlaufen will, ist:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;for [index], [wert] in pairs([tabelle]) do&lt;br /&gt;
    -- Anweisung(en)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Diese Schleife geht durch alle Elemente der Tabelle und führt die Anweisungen somit für alle Elemente der Tabelle aus, wobei Index jedes Mal dem aktuellen Index des Tabellenelements und Wert jedes Mal dem aktuellen Wert des Tabellenelements entspricht.&lt;br /&gt;
Anstelle von pairs() kann man auch ipairs() nehmen, wenn man nur alle ganzzahligen Indizes durchlaufen möchte.&lt;br /&gt;
Hier mal ein Beispiel:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local tabelle = { eins = 1, &amp;quot;hallo&amp;quot;, pi = 3.14159 }&lt;br /&gt;
&lt;br /&gt;
-- mit pairs&lt;br /&gt;
for index, wert in pairs(tabelle) do&lt;br /&gt;
  print(tostring(index)..&amp;quot;=&amp;quot;..tostring(wert)..&amp;quot;, &amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
-- Ausgabe: &amp;quot;eins=1, 1=hallo, pi=3.14159, &amp;quot;&lt;br /&gt;
&lt;br /&gt;
-- mit ipairs&lt;br /&gt;
for index, wert in ipairs(tabelle) do&lt;br /&gt;
  print(tostring(index)..&amp;quot;=&amp;quot;..tostring(wert)..&amp;quot;, &amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
-- Ausgabe: &amp;quot;1=hallo, &amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
tostring() ist übrigens eine Funktion, die eine beliebige Variable in einen string umwandelt. Wenn man Variablen mit einem string verknüpfen will und sich nicht sicher ist, ob diese Variablen string sind oder nicht, sollte man auf jeden Fall diese Funktion verwenden, da ansonsten Fehler auftreten können. (Lua gibt einen Error aus, wenn man z.B. soetwas versucht: &amp;quot;Hallo &amp;quot;..nil..&amp;quot;.&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
===Schleifenabbruch===&lt;br /&gt;
Mit dem Schlüsselwort break kann man eine Schleife sofort abbrechen.&lt;br /&gt;
Hier ein kurzes Beispiel dazu:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local zahl = 10&lt;br /&gt;
while (true) do&lt;br /&gt;
    print(zahl)&lt;br /&gt;
    zahl = zahl - 1&lt;br /&gt;
    if (zahl &amp;lt; 0) then&lt;br /&gt;
        break&lt;br /&gt;
    end&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Diese Schleife würde auch alle Zahlen von 10 bis 0 nacheinander ausgeben, nur dass der Abbruch manuell erfolgt, wenn zahl negativ wird. Ohne diese Bedingung würde die Schleife endlos laufen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Funktionen==&lt;br /&gt;
===Einführung===&lt;br /&gt;
Funktionen sind im Grunde genommen Anweisungsblöcke, die - meist in Abhängigkeit von übergebenen Werten - mehrmals an unterschiedlichen Orten im Script bzw. zu unterschiedlichen Zeiten ausgeführt werden sollen.&lt;br /&gt;
Da eine Funktion - sofern sie mehr als einmal ausgeführt werden soll bzw. mehr als einmal benötigt wird - auch in einer Variable gespeichert werden kann, kann man den Variablentyp function einführen, der in Lua auch tatsächlich existiert.&lt;br /&gt;
Funktionen können Werte übergeben bekommen und auch Werte zurückgeben.&lt;br /&gt;
&lt;br /&gt;
===Definition===&lt;br /&gt;
Die allgemeine Syntax für das Definieren einer Funktion ist die folgende:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function [funktionsname]([parameterliste])&lt;br /&gt;
    -- Anweisung(en)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ein Beispiel für eine Funktion, die das Quadrat einer Zahl zurückgibt, wäre:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function quadrat(zahl)&lt;br /&gt;
    return zahl * zahl&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternativ kann eine Funktion übrigens auch so einer Variable zugewiesen werden:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;quadrat = function (zahl) return zahl * zahl end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Rückgabewerte===&lt;br /&gt;
return wird verwendet, um die Funktion einen Wert zurückgeben zu lassen. Nach einem return-Befehl bricht die Funktion alle Tätigkeiten ab und ist beendet.&lt;br /&gt;
Um einen Rückgabewert verwenden zu können, müssen wir aber ersteinmal wissen, wie man eine Funktion dazu bringt, die Anweisungen, die sie enthält, auszuführen.&lt;br /&gt;
Das geht allgemein mit funktionsname(parameterliste).&lt;br /&gt;
Als Beispiel für unsere quadrat-Funktion:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local vier = quadrat(2)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wenn wir quadrat(2) ausführen, dann wird der obrige Code ausgeführt, wobei die Variable zahl den Wert 2 zugewiesen bekommt. zahl ist dabei jedoch nur innerhalb der Funktion definiert.&lt;br /&gt;
Die Variable vier bekommt nun den Wert 2 * 2, also 4 zugewiesen.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local vier = quadrat&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
würde die Funktion quadrat in die Variable vier kopieren. Man könnte nun also auch vier(2) aufrufen, um 4 zu bekommen.&lt;br /&gt;
&lt;br /&gt;
Eine Funktion kann auch mehrere Funktionswerte zurückgeben. Das ist vor allem dann sinnvoll, wenn es sich um Positionen handelt, was bei MTA ja nicht selten vorkommt.&lt;br /&gt;
Beispiel:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function berechnungen(zahl1, zahl2)&lt;br /&gt;
    return zahl1 + zahl2, zahl1 - zahl2, zahl1 * zahl2, zahl1 / zahl2&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local summe, differenz, produkt, division = berechnungen(5, 10)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Damit wird summe = 15, differenz = 5, produkt = 50 und division = 2.&lt;br /&gt;
&lt;br /&gt;
===Lua Standardfunktionen===&lt;br /&gt;
Funktionen wie tostring, print und math.random sind Standardfunktionen von Lua. Eine komplette Liste aller Lua Standardfunktionen bekommt ihr auf der [http://www.lua.org/manual/5.1/#index offiziellen Lua Webseite] (Englisch).&lt;br /&gt;
&lt;br /&gt;
Die Standard-string-Funktionen erlauben eine besondere Syntax, die ich hier kurz erläutern möchte, da sie von vielen erfahrenen Scriptern genutzt wird und es hilfreich ist, wenn man etwas damit anfangen kann.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local name = &amp;quot;Firzen Polas&amp;quot;&lt;br /&gt;
local laenge = string.len(name)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Dieser Code weist der Variable laenge die Länge des strings &amp;quot;Firzen Polas&amp;quot;, also 12, zu.&lt;br /&gt;
Alternativ kann man auch den folgenden Code verwenden:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local name = &amp;quot;Firzen Polas&amp;quot;&lt;br /&gt;
local laenge = name:len()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Vorraussetzung ist, dass die Variable vor dem Doppelpunkt ein string ist. Bei den math- und table-Funktionen funktioniert dies nicht.&lt;br /&gt;
&lt;br /&gt;
===Rekursive Funktionen===&lt;br /&gt;
Rekursive Funktionen sind eine effektive Alternative zu Schleifen - zumindest in manchen seltenen Fällen. Das berühmteste Beispiel ist das Berechnen einer Fakultät.&lt;br /&gt;
Zur Information: n! (sprich: n Fakultät) bezeichnet das Produkt aller Ganzzahlen von n bis 1, also quasi 1*2*3*4*...*n.&lt;br /&gt;
Beispiel: 3! = 1 * 2 * 3 = 6&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function fakultaet(zahl)&lt;br /&gt;
    if (zahl &amp;gt; 0) then&lt;br /&gt;
        return zahl * fakultaet(zahl - 1)&lt;br /&gt;
    else&lt;br /&gt;
        return 1&lt;br /&gt;
    end&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Mit Schleife sähe das so aus:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function fakultaet(zahl)&lt;br /&gt;
    if (zahl == 0) then&lt;br /&gt;
        return 1&lt;br /&gt;
    end&lt;br /&gt;
    for i=zahl-1, 1, -1 do&lt;br /&gt;
        zahl = zahl * i&lt;br /&gt;
    end&lt;br /&gt;
    return zahl&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Variable Parameterzahl===&lt;br /&gt;
Manchmal benötigt eine Funktion nicht zwingend eine bestimmte Anzahl von Parametern oder soll eine variable Anzahl an Parametern akzeptieren.&lt;br /&gt;
Dies lässt sich realisieren mit drei Punkten am Ende der Parameterliste.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function aufsummieren(...)&lt;br /&gt;
    local parameter = {...}&lt;br /&gt;
    local summe = 0&lt;br /&gt;
    for _, zahl in pairs(parameter)&lt;br /&gt;
        summe = summe + tonumber(zahl)&lt;br /&gt;
    end&lt;br /&gt;
    return summe&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
... entspricht dabei innerhalb der Funktion der Parameterliste als normale Liste.&lt;br /&gt;
D.h., wenn man aufsummieren(1, 2, 3, 4) aufruft, dann wird parameter = {1, 2, 3, 4}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Fragen, Anregungen, Kritik==&lt;br /&gt;
Sollten noch irgendwelche Fragen offen sein, so könnt ihr jederzeit in unserem [irc://irc.gtanet.com/#mta.german IRC Channel] oder in unserem [http://mtasa.ath.cx/wbblite/ Forum] vorbeischauen und eure Fragen dort loswerden.&lt;br /&gt;
Außerdem haben wir in unserem IRC Channel einen Lua Bot, an dem ihr Funktionen, die auf den standard Lua Funktionen basieren, ausprobieren könnt.&lt;br /&gt;
&lt;br /&gt;
Anregungen und Kritik nehme ich dort auch entgegen. Alternativ könnt ihr diese hier in die Diskussion schreiben.&lt;br /&gt;
Falls ihr Fehler findet, behebt diese bitte oder gebt mir bescheid.&lt;br /&gt;
&lt;br /&gt;
Ich hoffe, das Tutorial konnte euch weiterhelfen. Demnächst wird es noch ein weiteres Tutorial geben, was auf MTA spezialisiert ist und grundlegende Techniken und Möglichkeiten erklärt.&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=20363</id>
		<title>User talk:Dragon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=20363"/>
		<updated>2009-07-05T15:18:00Z</updated>

		<summary type="html">&lt;p&gt;Dragon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;section name=&amp;quot;Todo&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;
&amp;gt;extend magnetwheels functionality&lt;br /&gt;
|    -different modes, detect near ground and walls&lt;br /&gt;
-----&amp;gt;camera fixes ... ?&lt;br /&gt;
|    |    -remove quick changing, flickering&lt;br /&gt;
|    |    -possibility to deactivate, maybe request it&lt;br /&gt;
|    -remove ability to use it as a way of flying&lt;br /&gt;
&amp;gt;extend xxxs functionality if playing animations backwards becomes possible&lt;br /&gt;
|    -user controls, mime hot coffee... if i get permission to do so lols&lt;br /&gt;
|    -maybe add female part too, multiplayer like&lt;br /&gt;
|    -camera&lt;br /&gt;
&amp;gt;add new features to scoreboard&lt;br /&gt;
-----&amp;gt;click players and get options what to do, PM, votekick, etc.&lt;br /&gt;
|    |    export a function to include new fields, for admin kick, band, spectate and such&lt;br /&gt;
|    -clientside settings&lt;br /&gt;
|    -request name column to become smaller or shrink, or code and submit patch for it&lt;br /&gt;
&amp;gt;spacecowboys gamemode&lt;br /&gt;
|    -to much to do to list it here&lt;br /&gt;
&amp;gt;dark resource&lt;br /&gt;
|    -let this become a stealth map or something with included lua to make it &amp;quot;dark&amp;quot; ;P&lt;br /&gt;
|    -set the timer correctly so the darkness rectangle doesn't stack and activate, deactivate correctly for goggles&lt;br /&gt;
|    -somehow add a hint that goggles are really useful on this map so more people take it on stealth start&lt;br /&gt;
&amp;gt;utsounds&lt;br /&gt;
|    -add accuracy&lt;br /&gt;
|    -get the original facts when which sound is played&lt;br /&gt;
|    -get ready for release&lt;br /&gt;
|    -sound volume settings&lt;br /&gt;
|    -settings for server owner&lt;br /&gt;
|    -clean up code... -argh&lt;br /&gt;
|    -better quality for some sounds&lt;br /&gt;
|    -remove headshot code and include it instead, offer setting for sniper 1 hit kill or put it in an own resource&lt;br /&gt;
|    -a help file..??&lt;br /&gt;
&amp;gt;admin&lt;br /&gt;
|    -possibility to dis include resource types in resource list so servers with many maps have a better survey of their resources&lt;br /&gt;
|    -fix autologin option somehow&lt;br /&gt;
|    -maybe help getting rid of warnings, errors and bring back its old functionality&lt;br /&gt;
&amp;gt;lag compensation&lt;br /&gt;
|    -maybe ask talidan for a fix and an included testing session&lt;br /&gt;
|    -search for the revision its uselessness is caused by&lt;br /&gt;
|    -testing between dp2.3 and current&lt;br /&gt;
&amp;gt;find cause for currently emerging BAD DESYNC&lt;br /&gt;
&amp;gt;bullet holes and scratches for cars script&lt;br /&gt;
&amp;gt;chatbubbles&lt;br /&gt;
|    -make it use dx functions&lt;br /&gt;
-----&amp;gt;fix overlapping&lt;br /&gt;
|    |    -make it work&lt;br /&gt;
|    |    -make it look smooth&lt;br /&gt;
|    |    -find a good way to implement this, test CAREFULLY&lt;br /&gt;
-----&amp;gt;implement settings for users preferences&lt;br /&gt;
|    |    -colors&lt;br /&gt;
|    |    -time&lt;br /&gt;
|    |    -with or without needle&lt;br /&gt;
|    |    -player names or no player names&lt;br /&gt;
|    -fix destroy timer so messages get deleted properly&lt;br /&gt;
|    -maybe replace images and use draw functions as well&lt;br /&gt;
|    -release it&lt;br /&gt;
|    -ask for it to become part of optional resources&lt;br /&gt;
&amp;gt;dragonsmusic&lt;br /&gt;
|    -cycling between own stand alone resources which play the music, so you don't need to download all of them at once&lt;br /&gt;
|    -MOAR SONGS&lt;br /&gt;
&amp;gt;external http download issue?!&lt;br /&gt;
&amp;gt;flashbang&lt;br /&gt;
|    -sound volume depending on distance&lt;br /&gt;
|    -when closer longer blind, when far away only for short time&lt;br /&gt;
|    -depending where on screen it is&lt;br /&gt;
|    -bug with rocketlauncher and sniper aim&lt;br /&gt;
|    -dxrectangle instead, find a way to combine it with sound blending&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=20298</id>
		<title>User talk:Dragon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=20298"/>
		<updated>2009-06-29T12:29:16Z</updated>

		<summary type="html">&lt;p&gt;Dragon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;section name=&amp;quot;Todo&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;
&amp;gt;extend magnetwheels functionality&lt;br /&gt;
|    -different modes, detect near ground and walls&lt;br /&gt;
-----&amp;gt;camera fixes ... ?&lt;br /&gt;
|    |    -remove quick changing, flickering&lt;br /&gt;
|    |    -possibility to deactivate, maybe request it&lt;br /&gt;
|    -remove ability to use it as a way of flying&lt;br /&gt;
&amp;gt;extend xxxs functionality if playing animations backwards becomes possible&lt;br /&gt;
|    -user controls, mime hot coffee... if i get permission to do so lols&lt;br /&gt;
|    -maybe add female part too, multiplayer like&lt;br /&gt;
|    -camera&lt;br /&gt;
&amp;gt;add new features to scoreboard&lt;br /&gt;
-----&amp;gt;click players and get options what to do, PM, votekick, etc.&lt;br /&gt;
|    |    export a function to include new fields, for admin kick, band, spectate and such&lt;br /&gt;
|    -clientside settings&lt;br /&gt;
|    -request name column to become smaller or shrink, or code and submit patch for it&lt;br /&gt;
&amp;gt;spacecowboys gamemode&lt;br /&gt;
|    -to much to do to list it here&lt;br /&gt;
&amp;gt;dark resource&lt;br /&gt;
|    -let this become a stealth map or something with included lua to make it &amp;quot;dark&amp;quot; ;P&lt;br /&gt;
|    -set the timer correctly so the darkness rectangle doesn't stack and activate, deactivate correctly for goggles&lt;br /&gt;
|    -somehow add a hint that goggles are really useful on this map so more people take it on stealth start&lt;br /&gt;
&amp;gt;utsounds&lt;br /&gt;
|    -add accuracy&lt;br /&gt;
|    -get the original facts when which sound is played&lt;br /&gt;
|    -get ready for release&lt;br /&gt;
|    -sound volume settings&lt;br /&gt;
|    -settings for server owner&lt;br /&gt;
|    -clean up code... -argh&lt;br /&gt;
|    -better quality for some sounds&lt;br /&gt;
|    -remove headshot code and include it instead, offer setting for sniper 1 hit kill or put it in an own resource&lt;br /&gt;
|    -a help file..??&lt;br /&gt;
&amp;gt;admin&lt;br /&gt;
|    -possibility to dis include resource types in resource list so servers with many maps have a better survey of their resources&lt;br /&gt;
|    -fix autologin option somehow&lt;br /&gt;
|    -maybe help getting rid of warnings, errors and bring back its old functionality&lt;br /&gt;
&amp;gt;lag compensation&lt;br /&gt;
|    -maybe ask talidan for a fix and an included testing session&lt;br /&gt;
|    -search for the revision its uselessness is caused by&lt;br /&gt;
|    -testing between dp2.3 and current&lt;br /&gt;
&amp;gt;find cause for currently emerging BAD DESYNC&lt;br /&gt;
&amp;gt;bullet holes and scratches for cars script&lt;br /&gt;
&amp;gt;chatbubbles&lt;br /&gt;
|    -make it use dx functions&lt;br /&gt;
-----&amp;gt;fix overlapping&lt;br /&gt;
|    |    -make it work&lt;br /&gt;
|    |    -make it look smooth&lt;br /&gt;
|    |    -find a good way to implement this, test CAREFULLY&lt;br /&gt;
-----&amp;gt;implement settings for users preferences&lt;br /&gt;
|    |    -colors&lt;br /&gt;
|    |    -time&lt;br /&gt;
|    |    -with or without needle&lt;br /&gt;
|    |    -player names or no player names&lt;br /&gt;
|    -fix destroy timer so messages get deleted properly&lt;br /&gt;
|    -maybe replace images and use draw functions as well&lt;br /&gt;
|    -release it&lt;br /&gt;
|    -ask for it to become part of optional resources&lt;br /&gt;
&amp;gt;dragonsmusic&lt;br /&gt;
|    -cycling between own stand alone resources which play the music, so you don't need to download all of them at once&lt;br /&gt;
|    -MOAR SONGS&lt;br /&gt;
&amp;gt;external http download issue?!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=20295</id>
		<title>User talk:Dragon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=20295"/>
		<updated>2009-06-29T11:46:06Z</updated>

		<summary type="html">&lt;p&gt;Dragon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;section name=&amp;quot;Todo&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;
&amp;gt;extend magnetwheels functionality&lt;br /&gt;
|    -different modes, detect near ground and walls&lt;br /&gt;
-----&amp;gt;camera fixes ... ?&lt;br /&gt;
|    |    -remove quick changing, flickering&lt;br /&gt;
|    |    -possibility to deactivate, maybe request it&lt;br /&gt;
|    -remove ability to use it as a way of flying&lt;br /&gt;
&amp;gt;extend xxxs functionality if playing animations backwards becomes possible&lt;br /&gt;
|    -user controls, mime hot coffee... if i get permission to do so lols&lt;br /&gt;
|    -maybe add female part too, multiplayer like&lt;br /&gt;
|    -camera&lt;br /&gt;
&amp;gt;add new features to scoreboard&lt;br /&gt;
-----&amp;gt;click players and get options what to do, PM, votekick, etc.&lt;br /&gt;
|    |    export a function to include new fields, for admin kick, band, spectate and such&lt;br /&gt;
|    -clientside settings&lt;br /&gt;
|    -request name column to become smaller or shrink, or code and submit patch for it&lt;br /&gt;
&amp;gt;spacecowboys gamemode&lt;br /&gt;
|    -to much to do to list it here&lt;br /&gt;
&amp;gt;dark resource&lt;br /&gt;
|    -let this become a stealth map or something with included lua to make it &amp;quot;dark&amp;quot; ;P&lt;br /&gt;
|    -set the timer correctly so the darkness rectangle doesn't stack and activate, deactivate correctly for goggles&lt;br /&gt;
|    -somehow add a hint that goggles are really useful on this map so more people take it on stealth start&lt;br /&gt;
&amp;gt;utsounds&lt;br /&gt;
|    -get ready for release&lt;br /&gt;
|    -sound volume settings&lt;br /&gt;
|    -settings for serverowner&lt;br /&gt;
|    -clean up code... -argh&lt;br /&gt;
|    -better quality for some sounds&lt;br /&gt;
|    -remove headshot code and include it instead, offer setting for sniper 1 hit kill or put it in an own resource&lt;br /&gt;
|    -a help file..??&lt;br /&gt;
&amp;gt;admin&lt;br /&gt;
|    -possibility to dis include resource types in resource list so servers with many maps have a better survey of their resources&lt;br /&gt;
|    -fix autologin option somehow&lt;br /&gt;
|    -maybe help getting rid of warnings, errors and bring back its old functionality&lt;br /&gt;
&amp;gt;lag compensation&lt;br /&gt;
|    -maybe ask talidan for a fix and an included testing session&lt;br /&gt;
|    -search for the revision its uselessness is caused by&lt;br /&gt;
|    -testing between dp2.3 and current&lt;br /&gt;
&amp;gt;find cause for currently emerging BAD DESYNC&lt;br /&gt;
&amp;gt;bullet holes and scratches for cars script&lt;br /&gt;
&amp;gt;chatbubbles&lt;br /&gt;
|    -make it use dx functions&lt;br /&gt;
-----&amp;gt;fix overlapping&lt;br /&gt;
|    |    -make it work&lt;br /&gt;
|    |    -make it look smooth&lt;br /&gt;
|    |    -find a good way to implement this, test CAREFULLY&lt;br /&gt;
-----&amp;gt;implement settings for users preferences&lt;br /&gt;
|    |    -colors&lt;br /&gt;
|    |    -time&lt;br /&gt;
|    |    -with or without needle&lt;br /&gt;
|    |    -player names or no player names&lt;br /&gt;
|    -fix destroy timer so messages get deleted properly&lt;br /&gt;
|    -maybe replace images and use draw functions as well&lt;br /&gt;
|    -release it&lt;br /&gt;
|    -ask for it to become part of optional resources&lt;br /&gt;
&amp;gt;dragonsmusic&lt;br /&gt;
|    -cycling between own stand alone resources which play the music, so you don't need to download all of them at once&lt;br /&gt;
|    -MOAR SONGS&lt;br /&gt;
&amp;gt;external http download issue?!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=20294</id>
		<title>User talk:Dragon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=20294"/>
		<updated>2009-06-29T11:42:47Z</updated>

		<summary type="html">&lt;p&gt;Dragon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;section name=&amp;quot;Todo&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;
&amp;gt;extend magnetwheels functionality&lt;br /&gt;
|    -different modes, detect near ground and walls&lt;br /&gt;
-----&amp;gt;camera fixes ... ?&lt;br /&gt;
|    |    -remove quick changing, flickering&lt;br /&gt;
|    |    -possibility to deactivate, maybe request it&lt;br /&gt;
|    -remove ability to use it as a way of flying&lt;br /&gt;
&amp;gt;extend xxxs functionality if playing animations backwards becomes possible&lt;br /&gt;
|    -user controls, mime hot coffee... if i get permission to do so lols&lt;br /&gt;
|    -maybe add female part too, multiplayer like&lt;br /&gt;
|    -camera&lt;br /&gt;
&amp;gt;add new features to scoreboard&lt;br /&gt;
-----&amp;gt;click players and get options what to do, PM, votekick, etc.&lt;br /&gt;
|    |    export a function to include new fields, for admin kick, band, spectate and such&lt;br /&gt;
|    -clientside settings&lt;br /&gt;
|    -request name column to become smaller or shrink, or code and submit patch for it&lt;br /&gt;
&amp;gt;spacecowboys gamemode&lt;br /&gt;
|    -to much to do to list it here&lt;br /&gt;
&amp;gt;dark resource&lt;br /&gt;
|    -let this become a stealth map or something with included lua to make it &amp;quot;dark&amp;quot; ;P&lt;br /&gt;
|    -set the timer correctly so the darkness rectangle doesn't stack and activate, deactivate correctly for goggles&lt;br /&gt;
|    -somehow add a hint that goggles are really useful on this map so more people take it on stealth start&lt;br /&gt;
&amp;gt;utsounds&lt;br /&gt;
|    -get ready for release&lt;br /&gt;
|    -sound volume settings&lt;br /&gt;
|    -settings for serverowner&lt;br /&gt;
|    -clean up code... -argh&lt;br /&gt;
|    -better quality for some sounds&lt;br /&gt;
|    -remove headshot code and include it instead, offer setting for sniper 1 hit kill or put it in an own resource&lt;br /&gt;
|    -a help file..??&lt;br /&gt;
&amp;gt;admin&lt;br /&gt;
|    -possibility to dis include resource types in resource list so servers with many maps have a better survey of their resources&lt;br /&gt;
|    -fix autologin option somehow&lt;br /&gt;
|    -maybe help getting rid of warnings, errors and bring back its old functionality&lt;br /&gt;
&amp;gt;lag compensation&lt;br /&gt;
|    -maybe ask talidan for a fix and an included testing session&lt;br /&gt;
|    -search for the revision its uselessness is caused by&lt;br /&gt;
|    -testing between dp2.3 and current&lt;br /&gt;
&amp;gt;find cause for currently emerging BAD DESYNC&lt;br /&gt;
&amp;gt;bullet holes and scratches for cars script&lt;br /&gt;
&amp;gt;chatbubbles&lt;br /&gt;
|    -make it use dx functions&lt;br /&gt;
-----&amp;gt;fix overlapping&lt;br /&gt;
|    |    -make it work&lt;br /&gt;
|    |    -make it look smooth&lt;br /&gt;
|    |    -find a good way to implement this, test CAREFULLY&lt;br /&gt;
-----&amp;gt;implement settings for users preferences&lt;br /&gt;
|    |    -colors&lt;br /&gt;
|    |    -time&lt;br /&gt;
|    |    -with or without needle&lt;br /&gt;
|    |    -player names or no player names&lt;br /&gt;
|    -fix destroy timer so messages get deleted properly&lt;br /&gt;
|    -maybe replace images and use draw functions as well&lt;br /&gt;
|    -release it&lt;br /&gt;
|    -ask for it to become part of optional resources&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=20293</id>
		<title>User talk:Dragon</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User_talk:Dragon&amp;diff=20293"/>
		<updated>2009-06-29T11:39:08Z</updated>

		<summary type="html">&lt;p&gt;Dragon: New page: &amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; todo:  &amp;gt;extend magnetwheels functionality |    -different modes, detect near ground and walls -----&amp;gt;camera fixes ... ? |    |...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;
&lt;br /&gt;
&amp;gt;extend magnetwheels functionality&lt;br /&gt;
|    -different modes, detect near ground and walls&lt;br /&gt;
-----&amp;gt;camera fixes ... ?&lt;br /&gt;
|    |    -remove quick changing, flickering&lt;br /&gt;
|    |    -possibility to deactivate, maybe request it&lt;br /&gt;
|    -remove ability to use it as a way of flying&lt;br /&gt;
&amp;gt;extend xxxs functionality if playing animations backwards becomes possible&lt;br /&gt;
|    -user controls, mime hot coffee... if i get permission to do so lols&lt;br /&gt;
|    -maybe add female part too, multiplayer like&lt;br /&gt;
|    -camera&lt;br /&gt;
&amp;gt;add new features to scoreboard&lt;br /&gt;
-----&amp;gt;click players and get options what to do, PM, votekick, etc.&lt;br /&gt;
|    |    export a function to include new fields, for admin kick, band, spectate and such&lt;br /&gt;
|    -clientside settings&lt;br /&gt;
|    -request name column to become smaller or shrink, or code and submit patch for it&lt;br /&gt;
&amp;gt;spacecowboys gamemode&lt;br /&gt;
|    -to much to do to list it here&lt;br /&gt;
&amp;gt;dark resource&lt;br /&gt;
|    -let this become a stealth map or something with included lua to make it &amp;quot;dark&amp;quot; ;P&lt;br /&gt;
|    -set the timer correctly so the darkness rectangle doesn't stack and activate, deactivate correctly for goggles&lt;br /&gt;
|    -somehow add a hint that goggles are really useful on this map so more people take it on stealth start&lt;br /&gt;
&amp;gt;utsounds&lt;br /&gt;
|    -get read for release&lt;br /&gt;
|    -sound volume settings&lt;br /&gt;
|    -settings for serverowner&lt;br /&gt;
|    -clean up code... -argh&lt;br /&gt;
|    -better quality for some sounds&lt;br /&gt;
|    -remove headshot code and include it instead, offer setting for sniper 1 hit kill or put it in an own resource&lt;br /&gt;
|    -a help file..??&lt;br /&gt;
&amp;gt;admin&lt;br /&gt;
|    -possibility to dis include resource types in resource list so servers with many maps have a better survey of their resources&lt;br /&gt;
|    -fix autologin option somehow&lt;br /&gt;
|    -maybe help getting rid of warnings, errors and bring back its old functionality&lt;br /&gt;
&amp;gt;lag compensation&lt;br /&gt;
|    -maybe ask talidan for a fix and an included testing session&lt;br /&gt;
|    -search for the revision its uselessness is caused by&lt;br /&gt;
|    -testing between dp2.3 and current&lt;br /&gt;
&amp;gt;find cause for currently emerging BAD DESYNC&lt;br /&gt;
&amp;gt;bullet holes and scratches for cars script&lt;br /&gt;
&amp;gt;chatbubbles&lt;br /&gt;
|    -make it use dx functions&lt;br /&gt;
-----&amp;gt;fix overlapping&lt;br /&gt;
|    |    -make it work&lt;br /&gt;
|    |    -make it look smooth&lt;br /&gt;
|    |    -find a good way to implement this, test CAREFULLY&lt;br /&gt;
-----&amp;gt;implement settings for users preferences&lt;br /&gt;
|    |    -colors&lt;br /&gt;
|    |    -time&lt;br /&gt;
|    |    -with or without needle&lt;br /&gt;
|    |    -player names or no player names&lt;br /&gt;
|    -fix destroy timer so messages get deleted properly&lt;br /&gt;
|    -maybe replace images and use draw functions as well&lt;br /&gt;
|    -release it&lt;br /&gt;
|    -ask for it to become part of optional resources&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=ShowCursor&amp;diff=20218</id>
		<title>ShowCursor</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ShowCursor&amp;diff=20218"/>
		<updated>2009-06-27T15:46:33Z</updated>

		<summary type="html">&lt;p&gt;Dragon: changed chatbox to chatbox input line and added console and help manager, since all of them prevent cursor from being not shown by showCursor function.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function is used to show or hide a [[player]]'s cursor.&lt;br /&gt;
&lt;br /&gt;
Note that, regardless of the cursor state you set using this function, the cursor will always be visible while the menu, the chatbox input line, the console or the help manager are open.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool showCursor ( player thePlayer, bool show, [ bool toggleControls = true ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePlayer:''' The [[player]] you want to show or hide the cursor of.&lt;br /&gt;
*'''show:''' A boolean value determining whether to show (''true'') or hide (''false'') the cursor.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*'''toggleControls:''' A boolean value determining whether to disable controls whilst the cursor is showing.  ''true'' implies controls are disabled, ''false'' implies controls remain enabled.&lt;br /&gt;
}}&lt;br /&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;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool showCursor ( bool show, [ bool toggleControls = true ]  )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''show:''' A boolean value determining whether to show (''true'') or hide (''false'') the cursor.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
{{New feature|3|1.0|&lt;br /&gt;
*'''toggleControls:''' A boolean value determining whether to disable controls whilst the cursor is showing.  ''true'' implies controls are disabled, ''false'' implies controls remain enabled.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the player's cursor was shown or hidden successfully, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example shows the cursor for a player named &amp;quot;Dave&amp;quot;, then outputs a message if it was shown successfully.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local thePlayer = getPlayerFromNick ( &amp;quot;Dave&amp;quot; )              -- get the player named Dave&lt;br /&gt;
if thePlayer then                                           -- if we got him&lt;br /&gt;
    showCursor ( thePlayer, true )                          -- make his cursor show&lt;br /&gt;
    if isCursorShowing ( thePlayer ) then                   -- did it show?&lt;br /&gt;
        outputChatBox ( &amp;quot;Cursor is now showing for Dave.&amp;quot; ) -- print a message to the chat box&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;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example shows the cursor all the time&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
showCursor ( true ) -- Shows cursor&lt;br /&gt;
showCursor ( false ) -- Doesnt Show Cursor&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Cursor_functions}}&lt;/div&gt;</summary>
		<author><name>Dragon</name></author>
	</entry>
</feed>