<?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=Skully</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=Skully"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Skully"/>
	<updated>2026-04-08T11:14:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=AddEventHandler&amp;diff=75183</id>
		<title>AddEventHandler</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=AddEventHandler&amp;diff=75183"/>
		<updated>2022-06-26T00:56:26Z</updated>

		<summary type="html">&lt;p&gt;Skully: Fix invalid characters.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}} &lt;br /&gt;
{{Important Note|Do '''NOT''' use the same name for your handler function as the event name, as this can lead to confusion if multiple handler functions are used. On the same note, for multiple reasons, it is '''NOT''' a good idea to export the same functions that you use locally as remote event handlers.}}&lt;br /&gt;
This function will add an [[event]] handler. An event handler is a function that will be called when the event it's attached to is triggered. See [[event system]] for more information on how the event system works.&lt;br /&gt;
{{Important Note|See code for this note below}}&lt;br /&gt;
&lt;br /&gt;
Event handlers are functions that are called when a particular event happens. Each event specifies a specific set of variables that are passed to the event handler and can be read by your function. The following global variables are available for use in handler functions:&lt;br /&gt;
*'''source''': the element that triggered the event&lt;br /&gt;
*'''this''': the element that the event handler is attached to&lt;br /&gt;
*'''sourceResource''': the resource that triggered the event&lt;br /&gt;
*'''sourceResourceRoot''': the root element of the resource that triggered the event&lt;br /&gt;
*'''client''': the client that triggered the event using [[triggerServerEvent]]. Not set if the event was not triggered from a client.&lt;br /&gt;
{{New_feature|3|1.0|&lt;br /&gt;
*'''eventName''': the name of the event which triggered the handler function.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
It is important to remember that events pass up and down the [[element tree]]. An event triggered on the root element is triggered on every element in the tree. An event triggered on any other element is triggered on its ancestors (its parent element and its parent's parent etc) and its children, grandchildren and great-grandchildren. You can use the ''propagate'' argument to specify if you wish your handler to receive events that have propagated up or down the tree.&lt;br /&gt;
&lt;br /&gt;
The order in which event handlers are triggered is undefined, you should not rely on one event handler being executed before another.&lt;br /&gt;
{{Note|See [[Script security]] for tips on preventing cheaters when using events and element data}}&lt;br /&gt;
{{Note|See [[Event_Source_Element|Event Source Element]] for a descriptive visualization of the event system handling an event trigger.}}&lt;br /&gt;
&lt;br /&gt;
Each function closure can only be added once to each event. On the second attempt to add the function closure to the same event a warning will be emitted to the debug console and the call to addEventHandler will fail.&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool addEventHandler ( string eventName, element attachedTo, function handlerFunction [, bool propagate = true, string priority = &amp;quot;normal&amp;quot; ] )    &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''eventName:''' The name of the [[event]] you want to attach the handler function to. '''Note: The maximum allowed length is 100 ASCII characters (that is, English letters and numerals)'''&lt;br /&gt;
*'''attachedTo:''' The [[element]] you wish to attach the handler to. The handler will only be called when the event it is attached to is triggered for this element, or one of its children. Often, this can be the root element (meaning the handler will be called when the event is triggered for ''any'' element).&lt;br /&gt;
*'''handlerFunction:''' The handler function you wish to call when the event is triggered. This function will be passed all of the event's parameters as arguments, but it isn't required that it takes all of them.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''propagate:''' A boolean representing whether the handler will be triggered if the event was propagated down or up the [[element tree]] (starting from the source), and not triggered directly on attachedTo (that is, handlers attached with this argument set to ''false'' will only be triggered if ''source == this''). In GUI events you will probably want to set this to ''false''.&lt;br /&gt;
{{New_feature|3.0131|1.3.1|&lt;br /&gt;
*'''priority :''' A string representing the trigger order priority relative to other event handlers of the same name. Possible values are:&lt;br /&gt;
**'''&amp;quot;high&amp;quot;'''&lt;br /&gt;
**'''&amp;quot;normal&amp;quot;'''&lt;br /&gt;
**'''&amp;quot;low&amp;quot;'''&lt;br /&gt;
''It is also possible to add finer priority control by appending a positive or negative number to the priority string. For example (in priority order for reference): &amp;quot;high+4&amp;quot; &amp;quot;high&amp;quot; &amp;quot;high-1&amp;quot; &amp;quot;normal-6&amp;quot; &amp;quot;normal-7&amp;quot; &amp;quot;low+1&amp;quot; &amp;quot;low&amp;quot; &amp;quot;low-1&amp;quot;''&lt;br /&gt;
{{Important Note|Anything bound to a specific element will be run before other handlers that are bound to something higher in the element tree (like root) This means that &amp;quot;high+10&amp;quot; bound to root '''won't''' trigger before &amp;quot;normal&amp;quot; bound directly to an element.}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the event handler was attached successfully. Returns ''false'' if the specified event could not be found or any parameters were invalid.&lt;br /&gt;
&lt;br /&gt;
==Remarks==&lt;br /&gt;
Due to the additional set of global variables, the event-trigger specific variables it is '''NOT a good idea to use the same function locally as well as directly as an event handler'''. Event handlers often make use of the source element variable which would often find no use in generic functions. Inside of server-side remote event handlers it is important to add protections against exploits due to unexpected client event triggers or network-based load situations while generic functions, due to being part of a controlled call-stack, do not in general face the same issues. It is recommended to adapt a '''good-natured distancing''' principle between code meant to run from local logic in separation to code meant to run from remote logic.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;!-- This code is wrong. It WILL crash the server eventually because it is registering a new event handler every time &amp;quot;eventName&amp;quot; event is called.&lt;br /&gt;
&amp;lt;section name=&amp;quot;Code for important note above&amp;quot; class=&amp;quot;Important&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This code might not work as you expect: The handler added here won't be called until the next time the event is triggered. On the other hand, removing events works as expected.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEvent(&amp;quot;eventName&amp;quot;)&lt;br /&gt;
addEventHandler(&amp;quot;eventName&amp;quot;, root, function()&lt;br /&gt;
    print(&amp;quot;Existing called&amp;quot;)&lt;br /&gt;
    addEventHandler(&amp;quot;eventName&amp;quot;, root, function()&lt;br /&gt;
        print(&amp;quot;newly added called&amp;quot;)&lt;br /&gt;
    end)&lt;br /&gt;
end)&lt;br /&gt;
-- first time calling the event&lt;br /&gt;
triggerEvent(&amp;quot;eventName&amp;quot;, root) -- prints &amp;quot;Existing called&amp;quot;&lt;br /&gt;
-- second time - now both handlers are called&lt;br /&gt;
triggerEvent(&amp;quot;eventName&amp;quot;, root) -- prints &amp;quot;Existing called&amp;quot;, &amp;quot;newly added called&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This serverside example sends a message to everyone in the server when a player spawns.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- define our handler function&lt;br /&gt;
function onPlayerSpawnHandler ( )&lt;br /&gt;
	-- get the player's name, source is the player because he was spawned&lt;br /&gt;
	local playerName = getPlayerName( source )&lt;br /&gt;
	-- output in the chat box that they've spawned&lt;br /&gt;
	outputChatBox ( playerName .. &amp;quot; has spawned!&amp;quot; )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler( &amp;quot;onPlayerSpawn&amp;quot;, root, onPlayerSpawnHandler ) -- root is a predefined global variable for getRootElement()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.3.0-9.03795|Added priority argument}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Event_functions}}&lt;br /&gt;
[[ru:addEventHandler]]&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CURL_Errors&amp;diff=75168</id>
		<title>CURL Errors</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CURL_Errors&amp;diff=75168"/>
		<updated>2022-06-18T00:04:47Z</updated>

		<summary type="html">&lt;p&gt;Skully: Fix inline heading.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Historical}}&lt;br /&gt;
List of CURL Errors, updates can be found [https://curl.haxx.se/libcurl/c/libcurl-errors.html here]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''CURLE_OK (0)'''&lt;br /&gt;
&lt;br /&gt;
All fine. Proceed as usual.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_UNSUPPORTED_PROTOCOL (1)'''&lt;br /&gt;
&lt;br /&gt;
The URL you passed to libcurl used a protocol that this libcurl does not support. The support might be a compile-time option that you didn't use, it can be a misspelled protocol string or just a protocol libcurl has no code for.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FAILED_INIT (2)'''&lt;br /&gt;
&lt;br /&gt;
Very early initialization code failed. This is likely to be an internal error or problem.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_URL_MALFORMAT (3)'''&lt;br /&gt;
&lt;br /&gt;
The URL was not properly formatted.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_COULDNT_RESOLVE_PROXY (5)'''&lt;br /&gt;
&lt;br /&gt;
Couldn't resolve proxy. The given proxy host could not be resolved.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_COULDNT_RESOLVE_HOST (6)'''&lt;br /&gt;
&lt;br /&gt;
Couldn't resolve host. The given remote host was not resolved.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_COULDNT_CONNECT (7)'''&lt;br /&gt;
&lt;br /&gt;
Failed to connect() to host or proxy.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FTP_WEIRD_SERVER_REPLY (8)'''&lt;br /&gt;
&lt;br /&gt;
After connecting to a FTP server, libcurl expects to get a certain reply back. This error code implies that it got a strange or bad reply. The given remote server is probably not an OK FTP server.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_REMOTE_ACCESS_DENIED (9)'''&lt;br /&gt;
&lt;br /&gt;
We were denied access to the resource given in the URL. For FTP, this occurs while trying to change to the remote directory.&lt;br /&gt;
'''&lt;br /&gt;
CURLE_FTP_WEIRD_PASS_REPLY (11)'''&lt;br /&gt;
&lt;br /&gt;
After having sent the FTP password to the server, libcurl expects a proper reply. This error code indicates that an unexpected code was returned.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FTP_WEIRD_PASV_REPLY (13)'''&lt;br /&gt;
&lt;br /&gt;
libcurl failed to get a sensible result back from the server as a response to either a PASV or a EPSV command. The server is flawed.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FTP_WEIRD_227_FORMAT (14)'''&lt;br /&gt;
&lt;br /&gt;
FTP servers return a 227-line as a response to a PASV command. If libcurl fails to parse that line, this return code is passed back.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FTP_CANT_GET_HOST (15)'''&lt;br /&gt;
&lt;br /&gt;
An internal failure to lookup the host used for the new connection.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FTP_COULDNT_SET_TYPE (17)'''&lt;br /&gt;
&lt;br /&gt;
Received an error when trying to set the transfer mode to binary or ASCII.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_PARTIAL_FILE (18)'''&lt;br /&gt;
&lt;br /&gt;
A file transfer was shorter or larger than expected. This happens when the server first reports an expected transfer size, and then delivers data that doesn't match the previously given size.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FTP_COULDNT_RETR_FILE (19)'''&lt;br /&gt;
&lt;br /&gt;
This was either a weird reply to a 'RETR' command or a zero byte transfer complete.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_QUOTE_ERROR (21)'''&lt;br /&gt;
&lt;br /&gt;
When sending custom &amp;quot;QUOTE&amp;quot; commands to the remote server, one of the commands returned an error code that was 400 or higher (for FTP) or otherwise indicated unsuccessful completion of the command.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_HTTP_RETURNED_ERROR (22)'''&lt;br /&gt;
&lt;br /&gt;
This is returned if CURLOPT_FAILONERROR is set TRUE and the HTTP server returns an error code that is &amp;gt;= 400. (This error code was formerly known as CURLE_HTTP_NOT_FOUND.)&lt;br /&gt;
&lt;br /&gt;
'''CURLE_WRITE_ERROR (23)'''&lt;br /&gt;
&lt;br /&gt;
An error occurred when writing received data to a local file, or an error was returned to libcurl from a write callback.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_UPLOAD_FAILED (25)'''&lt;br /&gt;
&lt;br /&gt;
Failed starting the upload. For FTP, the server typically denied the STOR command. The error buffer usually contains the server's explanation for this. (This error code was formerly known as CURLE_FTP_COULDNT_STOR_FILE.)&lt;br /&gt;
&lt;br /&gt;
'''CURLE_READ_ERROR (26)'''&lt;br /&gt;
&lt;br /&gt;
There was a problem reading a local file or an error returned by the read callback.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_OUT_OF_MEMORY (27)'''&lt;br /&gt;
&lt;br /&gt;
A memory allocation request failed. This is serious badness and things are severely screwed up if this ever occurs.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_OPERATION_TIMEDOUT (28)'''&lt;br /&gt;
&lt;br /&gt;
Operation timeout. The specified time-out period was reached according to the conditions.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FTP_PORT_FAILED (30)'''&lt;br /&gt;
&lt;br /&gt;
The FTP PORT command returned error. This mostly happens when you haven't specified a good enough address for libcurl to use. See CURLOPT_FTPPORT.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FTP_COULDNT_USE_REST (31)'''&lt;br /&gt;
&lt;br /&gt;
The FTP REST command returned error. This should never happen if the server is sane.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_RANGE_ERROR (33)'''&lt;br /&gt;
&lt;br /&gt;
The server does not support or accept range requests.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_HTTP_POST_ERROR (34)'''&lt;br /&gt;
&lt;br /&gt;
This is an odd error that mainly occurs due to internal confusion.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SSL_CONNECT_ERROR (35)'''&lt;br /&gt;
&lt;br /&gt;
A problem occurred somewhere in the SSL/TLS handshake. You really want the error buffer and read the message there as it pinpoints the problem slightly more. Could be certificates (file formats, paths, permissions), passwords, and others.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FTP_BAD_DOWNLOAD_RESUME (36)'''&lt;br /&gt;
&lt;br /&gt;
Attempting FTP resume beyond file size.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FILE_COULDNT_READ_FILE (37)'''&lt;br /&gt;
&lt;br /&gt;
A file given with FILE:// couldn't be opened. Most likely because the file path doesn't identify an existing file. Did you check file permissions?&lt;br /&gt;
&lt;br /&gt;
'''CURLE_LDAP_CANNOT_BIND (38)'''&lt;br /&gt;
&lt;br /&gt;
LDAP cannot bind. LDAP bind operation failed.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_LDAP_SEARCH_FAILED (39)'''&lt;br /&gt;
&lt;br /&gt;
LDAP search failed.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FUNCTION_NOT_FOUND (41)'''&lt;br /&gt;
&lt;br /&gt;
Function not found. A required zlib function was not found.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_ABORTED_BY_CALLBACK (42)'''&lt;br /&gt;
&lt;br /&gt;
Aborted by callback. A callback returned &amp;quot;abort&amp;quot; to libcurl.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_BAD_FUNCTION_ARGUMENT (43)'''&lt;br /&gt;
&lt;br /&gt;
Internal error. A function was called with a bad parameter.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_INTERFACE_FAILED (45)'''&lt;br /&gt;
&lt;br /&gt;
Interface error. A specified outgoing interface could not be used. Set which interface to use for outgoing connections' source IP address with CURLOPT_INTERFACE. (This error code was formerly known as CURLE_HTTP_PORT_FAILED.)&lt;br /&gt;
&lt;br /&gt;
'''CURLE_TOO_MANY_REDIRECTS (47)'''&lt;br /&gt;
&lt;br /&gt;
Too many redirects. When following redirects, libcurl hit the maximum amount. Set your limit with CURLOPT_MAXREDIRS.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_UNKNOWN_TELNET_OPTION (48)'''&lt;br /&gt;
&lt;br /&gt;
An option set with CURLOPT_TELNETOPTIONS was not recognized/known. Refer to the appropriate documentation.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_TELNET_OPTION_SYNTAX (49)'''&lt;br /&gt;
&lt;br /&gt;
A telnet option string was Illegally formatted.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_PEER_FAILED_VERIFICATION (51)'''&lt;br /&gt;
&lt;br /&gt;
The remote server's SSL certificate or SSH md5 fingerprint was deemed not OK.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_GOT_NOTHING (52)'''&lt;br /&gt;
&lt;br /&gt;
Nothing was returned from the server, and under the circumstances, getting nothing is considered an error.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SSL_ENGINE_NOTFOUND (53)'''&lt;br /&gt;
&lt;br /&gt;
The specified crypto engine wasn't found.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SSL_ENGINE_SETFAILED (54)'''&lt;br /&gt;
&lt;br /&gt;
Failed setting the selected SSL crypto engine as default!&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SEND_ERROR (55)'''&lt;br /&gt;
&lt;br /&gt;
Failed sending network data.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_RECV_ERROR (56)'''&lt;br /&gt;
&lt;br /&gt;
Failure with receiving network data.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SSL_CERTPROBLEM (58)'''&lt;br /&gt;
&lt;br /&gt;
problem with the local client certificate.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SSL_CIPHER (59)'''&lt;br /&gt;
&lt;br /&gt;
Couldn't use specified cipher.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SSL_CACERT (60)'''&lt;br /&gt;
&lt;br /&gt;
Peer certificate cannot be authenticated with known CA certificates.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_BAD_CONTENT_ENCODING (61)'''&lt;br /&gt;
&lt;br /&gt;
Unrecognized transfer encoding.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_LDAP_INVALID_URL (62)'''&lt;br /&gt;
&lt;br /&gt;
Invalid LDAP URL.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_FILESIZE_EXCEEDED (63)'''&lt;br /&gt;
&lt;br /&gt;
Maximum file size exceeded.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_USE_SSL_FAILED (64)'''&lt;br /&gt;
&lt;br /&gt;
Requested FTP SSL level failed.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SEND_FAIL_REWIND (65)'''&lt;br /&gt;
&lt;br /&gt;
When doing a send operation curl had to rewind the data to retransmit, but the rewinding operation failed.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SSL_ENGINE_INITFAILED (66)'''&lt;br /&gt;
&lt;br /&gt;
Initiating the SSL Engine failed.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_LOGIN_DENIED (67)'''&lt;br /&gt;
&lt;br /&gt;
The remote server denied curl to login (Added in 7.13.1)&lt;br /&gt;
&lt;br /&gt;
'''CURLE_TFTP_NOTFOUND (68)'''&lt;br /&gt;
&lt;br /&gt;
File not found on TFTP server.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_TFTP_PERM (69)'''&lt;br /&gt;
&lt;br /&gt;
Permission problem on TFTP server.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_REMOTE_DISK_FULL (70)'''&lt;br /&gt;
&lt;br /&gt;
Out of disk space on the server.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_TFTP_ILLEGAL (71)'''&lt;br /&gt;
&lt;br /&gt;
Illegal TFTP operation.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_TFTP_UNKNOWNID (72)'''&lt;br /&gt;
&lt;br /&gt;
Unknown TFTP transfer ID.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_REMOTE_FILE_EXISTS (73)'''&lt;br /&gt;
&lt;br /&gt;
File already exists and will not be overwritten.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_TFTP_NOSUCHUSER (74)'''&lt;br /&gt;
&lt;br /&gt;
This error should never be returned by a properly functioning TFTP server.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_CONV_FAILED (75)'''&lt;br /&gt;
&lt;br /&gt;
Character conversion failed.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_CONV_REQD (76)'''&lt;br /&gt;
&lt;br /&gt;
Caller must register conversion callbacks.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SSL_CACERT_BADFILE (77)'''&lt;br /&gt;
&lt;br /&gt;
Problem with reading the SSL CA cert (path? access rights?)&lt;br /&gt;
&lt;br /&gt;
'''CURLE_REMOTE_FILE_NOT_FOUND (78)'''&lt;br /&gt;
&lt;br /&gt;
The resource referenced in the URL does not exist.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SSH (79)'''&lt;br /&gt;
&lt;br /&gt;
An unspecified error occurred during the SSH session.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SSL_SHUTDOWN_FAILED (80)'''&lt;br /&gt;
&lt;br /&gt;
Failed to shut down the SSL connection.&lt;br /&gt;
&lt;br /&gt;
'''CURLE_AGAIN (81)'''&lt;br /&gt;
&lt;br /&gt;
Socket is not ready for send/recv wait till it's ready and try again. This return code is only returned from curl_easy_recv(3) and curl_easy_send(3) (Added in 7.18.2)&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SSL_CRL_BADFILE (82)'''&lt;br /&gt;
&lt;br /&gt;
Failed to load CRL file (Added in 7.19.0)&lt;br /&gt;
&lt;br /&gt;
'''CURLE_SSL_ISSUER_ERROR (83)'''&lt;br /&gt;
&lt;br /&gt;
Issuer check failed (Added in 7.19.0)&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=IsPlayerInWater&amp;diff=72413</id>
		<title>IsPlayerInWater</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsPlayerInWater&amp;diff=72413"/>
		<updated>2021-09-22T06:08:32Z</updated>

		<summary type="html">&lt;p&gt;Skully: Change deprecated function alternative.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
{{Deprecated|isElementInWater}}&lt;br /&gt;
&lt;br /&gt;
This function is used to determine whether or not a player is currently in water. Player is in water only if breath bar appears.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool isPlayerInWater ( player thePlayer )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePlayer:''' The [[player]] you are checking.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the player is in water, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Serverside example&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example shows all players that are in water in a list to the player who enters the 'playersInWater' command.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function showPlayersInWater(sourcePlayer, command)&lt;br /&gt;
	local players = getElementsByType(&amp;quot;player&amp;quot;)&lt;br /&gt;
	local list = &amp;quot;&amp;quot;&lt;br /&gt;
	for k,v in ipairs(players) do&lt;br /&gt;
		if isPlayerInWater(v) then&lt;br /&gt;
			list = list .. &amp;quot; &amp;quot; .. getClientName(v)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	outputChatBox(&amp;quot;Players pretending to be trouts: &amp;quot; .. list, sourcePlayer)&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;playersInWater&amp;quot;, showPlayersInWater)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Player functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CreateFire&amp;diff=72021</id>
		<title>CreateFire</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CreateFire&amp;diff=72021"/>
		<updated>2021-09-08T01:53:18Z</updated>

		<summary type="html">&lt;p&gt;Skully: Fixed English and clarified explanation of size argument.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
[[Image:Fire.png|thumb|200px|Fire with default size (1.8)]]&lt;br /&gt;
&lt;br /&gt;
Creates a patch of fire that will spread a bit and die out after a while. Because it's a client side only function, other players won't see it, so custom events or custom objects will be needed to make a fire visible to some players.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool createFire ( float x, float y, float z [, float size = 1.8 ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''x, y, z:''' the coordinates when the initial patch of fire will be created.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''size:''' a float value indicating the size of the initial patch of fire, this value also affects the duration of how long the fire remains.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if successful, ''false'' if bad arguments were passed or the limit of active fires was reached. There can be a maximum of 60 active fires.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
This example adds a /fire command, which creates a patch of fire in the position of the player that types it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local function burn(commandName, theSize)&lt;br /&gt;
   if tonumber(theSize) then&lt;br /&gt;
        local x, y, z = getElementPosition(getLocalPlayer())&lt;br /&gt;
        createFire(x, y, z, tonumber(theSize))&lt;br /&gt;
        outputChatBox(&amp;quot;Burn, buuuuurn &amp;gt;:]&amp;quot;)&lt;br /&gt;
   else&lt;br /&gt;
        outputChatBox(&amp;quot;Syntax: /fire &amp;lt;size&amp;gt;&amp;quot;)&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;fire&amp;quot;, burn)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client fire functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=IsResourceProtected&amp;diff=67206</id>
		<title>IsResourceProtected</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsResourceProtected&amp;diff=67206"/>
		<updated>2020-08-07T09:16:27Z</updated>

		<summary type="html">&lt;p&gt;Skully: /* Added script example. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server function}}&lt;br /&gt;
&amp;lt;!-- Describe in plain english what this function does. Don't go into details, just give an overview --&amp;gt;&lt;br /&gt;
{{New feature/item|3.0158|1.5.7|20468|&lt;br /&gt;
This will check if a resource is currently protected, as defined in [[Server_mtaserver.conf#resource|mtaserver.conf]].&lt;br /&gt;
}}&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool isResourceProtected(resource theResource)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
{{OOP||[[resource]]:isProtected|protected}}&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
&amp;lt;!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --&amp;gt;&lt;br /&gt;
*'''theResource:''' the resource to check&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
&amp;lt;!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --&amp;gt;&lt;br /&gt;
Returns ''true'' if the resource is 'protected', ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example creates a command which allows you to check if the given resource with the name provided is protected. The command is &amp;quot;/isprotected [Resource Name]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function resourceProtectedCommand(thePlayer, command, resourceName)&lt;br /&gt;
    if resourceName then -- If the player provided a resource name.&lt;br /&gt;
        local theResource = getResourceFromName(resourceName) -- Get the resource element.&lt;br /&gt;
        if theResource then -- If we have an element, the resource must exist.&lt;br /&gt;
            local protectedResource = isResourceProtected(theResource) -- Check to see if the resource is protected.&lt;br /&gt;
            if protectedResource then -- if it is protected.&lt;br /&gt;
                outputChatBox(&amp;quot;This resource is a protected resource in the server config.&amp;quot;, thePlayer, 0, 255, 0)&lt;br /&gt;
            else -- If the resource is not protected.&lt;br /&gt;
                outputChatBox(&amp;quot;This resource is not a protected resource in the server config.&amp;quot;, thePlayer, 0, 255, 0)&lt;br /&gt;
            end&lt;br /&gt;
        else -- A resource with the name didn't exist.&lt;br /&gt;
            outputChatBox(&amp;quot;A resource with the name '&amp;quot; .. resourceName .. &amp;quot;' does not exist!&amp;quot;, thePlayer, 255, 0, 0)&lt;br /&gt;
        end&lt;br /&gt;
    else -- The player didn't provide a resource name.&lt;br /&gt;
        outputChatBox(&amp;quot;Please specify a resource name.&amp;quot;, thePlayer, 255, 0, 0)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;isprotected&amp;quot;, resourceProtectedCommand)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&amp;lt;!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --&amp;gt;&lt;br /&gt;
{{Resource_functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetKeyState&amp;diff=67091</id>
		<title>GetKeyState</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetKeyState&amp;diff=67091"/>
		<updated>2020-07-26T03:22:55Z</updated>

		<summary type="html">&lt;p&gt;Skully: /* Removed unrequired boolean comparison and fixed punctuation. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client function}}&lt;br /&gt;
This function determines if a certain key is pressed or not.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' 'ralt' may trigger both 'ralt' and 'lctrl', this is due to AltGr&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool getKeyState ( string keyName )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''keyName:''' The name of the key you're checking state of. See [[Key names]].&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the specified key is pressed, ''false'' if it isn't or if an invalid key name is passed.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This clientside example prints a message when &amp;quot;p&amp;quot; is pressed, and a different one for the &amp;quot;control+p&amp;quot; combination.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- define a function that outputs a message if control is pressed, and a different one if it isn't&lt;br /&gt;
function printMessageFunction()&lt;br /&gt;
	-- if the left or right control keys are pressed, the user has pressed the &amp;quot;lctrl + p&amp;quot; combo.&lt;br /&gt;
	if getKeyState(&amp;quot;lctrl&amp;quot;) or getKeyState(&amp;quot;rctrl&amp;quot;) then&lt;br /&gt;
		outputChatBox (&amp;quot;You have pressed 'Left Control + P'.&amp;quot;)&lt;br /&gt;
	-- if none of those were pressed, the player just pressed the &amp;quot;p&amp;quot; key.&lt;br /&gt;
	else&lt;br /&gt;
		outputChatBox (&amp;quot;You have pressed 'p'.&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
-- bind the &amp;quot;p&amp;quot; key to our function&lt;br /&gt;
bindKey(&amp;quot;p&amp;quot;, &amp;quot;down&amp;quot;, printMessageFunction)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client_input_functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnDgsCheckBoxChange&amp;diff=55173</id>
		<title>OnDgsCheckBoxChange</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnDgsCheckBoxChange&amp;diff=55173"/>
		<updated>2018-06-02T22:21:19Z</updated>

		<summary type="html">&lt;p&gt;Skully: /* Fixed not calling exported function. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client event}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This event is triggered each time the dgs check box state has changed.&lt;br /&gt;
&lt;br /&gt;
==Parameters== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool state&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the dgs check box.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
&lt;br /&gt;
local cb1 = DGS:dgsCreateCheckBox(300,300,200,30, &amp;quot;CheckBox Test 1&amp;quot;, false)&lt;br /&gt;
local cb2 = DGS:dgsCreateCheckBox(300,320,200,30, &amp;quot;CheckBox Test 2&amp;quot;, false)&lt;br /&gt;
&lt;br /&gt;
function onStateChanged(state)&lt;br /&gt;
	if source == cb1 and state == true then&lt;br /&gt;
		outputChatBox(&amp;quot;Selected CheckBox 1&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onDgsCheckBoxChange&amp;quot;, root, onStateChanged)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
===DGS events===&lt;br /&gt;
{{DGSEVENTS}}&lt;br /&gt;
===Client event functions===&lt;br /&gt;
{{Client_event_functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetNearestVehicle&amp;diff=55104</id>
		<title>GetNearestVehicle</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetNearestVehicle&amp;diff=55104"/>
		<updated>2018-05-24T04:41:01Z</updated>

		<summary type="html">&lt;p&gt;Skully: /* Fixed minor typo. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;vehicle getNearestVehicle( element thePlayer )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''thePlayer''': The player you want to get the nearest vehicle of.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Return a vehicle element if success, false if there's no vehicles in a 10meter circle..&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server- and/or clientside Script&amp;quot; class=&amp;quot;both&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 getNearestVehicle(player,distance)&lt;br /&gt;
	local tempTable = {}&lt;br /&gt;
	local lastMinDis = distance-0.0001&lt;br /&gt;
	local nearestVeh = false&lt;br /&gt;
	local px,py,pz = getElementPosition(player)&lt;br /&gt;
	local pint = getElementInterior(player)&lt;br /&gt;
	local pdim = getElementDimension(player)&lt;br /&gt;
&lt;br /&gt;
	for _,v in pairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
		local vint,vdim = getElementInterior(v),getElementDimension(v)&lt;br /&gt;
		if vint == pint and vdim == pdim then&lt;br /&gt;
			local vx,vy,vz = getElementPosition(v)&lt;br /&gt;
			local dis = getDistanceBetweenPoints3D(px,py,pz,vx,vy,vz)&lt;br /&gt;
			if dis &amp;lt; distance then&lt;br /&gt;
				if dis &amp;lt; lastMinDis then &lt;br /&gt;
					lastMinDis = dis&lt;br /&gt;
					nearestVeh = v&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return nearestVeh&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclePanelState&amp;diff=54607</id>
		<title>GetVehiclePanelState</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclePanelState&amp;diff=54607"/>
		<updated>2018-04-07T00:25:23Z</updated>

		<summary type="html">&lt;p&gt;Skully: Fixed broken redirect.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function returns the current state of a specifed panel on the vehicle. A vehicle can have up to 7 panels.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int getVehiclePanelState ( vehicle theVehicle, int panel )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
{{OOP||[[vehicle]]:getPanelState||setVehiclePanelState}}&lt;br /&gt;
&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''theVehicle:''' the [[vehicle]] that you wish to know the panel state of.&lt;br /&gt;
*'''panel:''' an ''integer'' specifying the panel you want to know the state of. Not every vehicle has every panel. Possible values are:&lt;br /&gt;
** '''0:''' Front-left panel&lt;br /&gt;
** '''1:''' Front-right panel&lt;br /&gt;
** '''2:''' Rear-left panel&lt;br /&gt;
** '''3:''' Rear-right panel&lt;br /&gt;
** '''4:''' Windscreen&lt;br /&gt;
** '''5:''' Front bumper&lt;br /&gt;
** '''6:''' Rear bumper&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns an [[int]] indicating the state of the specified the panel. This is a value between 0 and 3, with 0 indicating the panel is undamaged and 3 indicating it is very damaged.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This function creates an admiral and outputs every panel's state in the chatbox.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local admiral = createVehicle ( 445, 0, 0, 10 )&lt;br /&gt;
for i=0, 6 do&lt;br /&gt;
    local panel = getVehiclePanelState ( admiral, i )&lt;br /&gt;
    outputChatBox ( tostring ( panel ) )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Vehicle functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetVehiclePanelState&amp;diff=54603</id>
		<title>SetVehiclePanelState</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetVehiclePanelState&amp;diff=54603"/>
		<updated>2018-04-06T22:29:57Z</updated>

		<summary type="html">&lt;p&gt;Skully: Added OOP syntax.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
&lt;br /&gt;
This function allows you to change the state of one of the six panels vehicle's can have. When executed on the server-side resources, the damage will be synched for all players, whereas the change is only client-side if the function is used in a client resource. &lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool setVehiclePanelState ( vehicle theVehicle, int panelID, int state )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[vehicle]]:setPanelState||getVehiclePanelState}}&lt;br /&gt;
&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''theVehicle:''' The [[vehicle]] you would like to modify the panel of.&lt;br /&gt;
*'''panelID:''' An ID specifying the part of the vehicle. Possible values are:&lt;br /&gt;
&lt;br /&gt;
*'''Cars:'''&lt;br /&gt;
** '''0:''' Front-left panel&lt;br /&gt;
** '''1:''' Front-right panel&lt;br /&gt;
** '''2:''' Rear-left panel&lt;br /&gt;
** '''3:''' Rear-right panel&lt;br /&gt;
** '''4:''' Windscreen&lt;br /&gt;
** '''5:''' Front bumper&lt;br /&gt;
** '''6:''' Rear bumper&lt;br /&gt;
&lt;br /&gt;
*'''Planes:'''&lt;br /&gt;
**'''0:''' Engine Smoke (left engine for a Nevada or a Beagle)&lt;br /&gt;
**'''1:''' Engine Smoke (right engine for a Nevada or a Beagle)&lt;br /&gt;
**'''2:''' Rudder&lt;br /&gt;
**'''3:''' Elevators&lt;br /&gt;
**'''4:''' Ailerons&lt;br /&gt;
**'''5:''' Unknown&lt;br /&gt;
**'''6:''' Unknown&lt;br /&gt;
&lt;br /&gt;
''NOTE:'' Settings are not applicable for all vehicles of these types, for instance panel 0 effects a Dodo, but does nothing to a hydra.&lt;br /&gt;
&lt;br /&gt;
*'''state:''' How damaged the part is on the scale of 0 to 3, with 0 being undamaged and 3 being very damaged. How this is manifested depends on the panel and the vehicle.&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns ''true'' if the panel state has been updated, ''false'' otherwise&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 1: 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;
-- create a new vehicle&lt;br /&gt;
local newcar = createVehicle ( 520, 1024, 1024, 1024 )&lt;br /&gt;
-- break the front bumper off&lt;br /&gt;
setVehiclePanelState ( newcar, 5, 3 )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Vehicle functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetVehicleDoorState&amp;diff=54602</id>
		<title>SetVehicleDoorState</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetVehicleDoorState&amp;diff=54602"/>
		<updated>2018-04-06T22:21:19Z</updated>

		<summary type="html">&lt;p&gt;Skully: Added OOP syntax.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function sets the state of the specified door on a vehicle.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool setVehicleDoorState ( vehicle theVehicle, int door, int state )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[vehicle]]:setDoorState||getVehicleDoorState}}&lt;br /&gt;
&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''theVehicle:''' The [[vehicle]] that you wish to change the door state of.&lt;br /&gt;
*'''door:''' An integer representing which door to set the state of. Valid values are:&lt;br /&gt;
**'''0:''' Hood&lt;br /&gt;
**'''1:''' Trunk&lt;br /&gt;
**'''2:''' Front left&lt;br /&gt;
**'''3:''' Front right&lt;br /&gt;
**'''4:''' Rear left&lt;br /&gt;
**'''5:''' Rear right&lt;br /&gt;
*'''state:''' An integer representing the state to set the door to. Valid values are:&lt;br /&gt;
**'''0:''' Shut, intact&lt;br /&gt;
**'''1:''' Ajar, intact&lt;br /&gt;
**'''2:''' Shut, damaged&lt;br /&gt;
**'''3:''' Ajar, damaged&lt;br /&gt;
**'''4:''' Missing&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns ''true'' if the door state was successfully set, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- create a new vehicle&lt;br /&gt;
local newcar = createVehicle ( 520, 1024, 1024, 1024 )&lt;br /&gt;
-- break its front left door off&lt;br /&gt;
state = setVehicleDoorState ( newcar, 2, 4 )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Vehicle functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetVehicleLightState&amp;diff=54601</id>
		<title>SetVehicleLightState</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetVehicleLightState&amp;diff=54601"/>
		<updated>2018-04-06T22:05:38Z</updated>

		<summary type="html">&lt;p&gt;Skully: Defined associated light to lights parameter.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sets the state of the light on the vehicle.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool setVehicleLightState ( vehicle theVehicle, int light, int state )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[vehicle]]:setLightState||getVehicleLightState}}&lt;br /&gt;
&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''theVehicle:''' A handle to the [[vehicle]] that you wish to change the light state of.&lt;br /&gt;
*'''light:''' A whole number determining the individual light:&lt;br /&gt;
**'''0:''' Front left&lt;br /&gt;
**'''1:''' Front right&lt;br /&gt;
**'''2:''' Rear right&lt;br /&gt;
**'''3:''' Rear left&lt;br /&gt;
&lt;br /&gt;
*'''state:''' A whole number determining the new state of the light. ''0'' represents normal lights, and ''1'' represents broken lights.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the light state was set successfully, ''false'' if invalid arguments were passed to the function.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
newcar = createVehicle ( 520, 1024, 1024, 1024 )   -- create a new vehicle&lt;br /&gt;
state = setVehicleLightState ( newcar, 0,  1 )     -- break the left front light&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Vehicle functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User:Skully&amp;diff=53988</id>
		<title>User:Skully</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User:Skully&amp;diff=53988"/>
		<updated>2018-02-19T22:38:20Z</updated>

		<summary type="html">&lt;p&gt;Skully: /* Hello! */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Hello!==&lt;br /&gt;
&lt;br /&gt;
I like dank memes, thanks for stopping by.&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
*[https://forum.mtasa.com/profile/57023-skully/ Forum Profile]&lt;br /&gt;
*[https://github.com/ImSkully GitHub Profile]&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=PasswordHash&amp;diff=53987</id>
		<title>PasswordHash</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=PasswordHash&amp;diff=53987"/>
		<updated>2018-02-19T19:53:02Z</updated>

		<summary type="html">&lt;p&gt;Skully: Updated options parameter to be required.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Shared function}}&lt;br /&gt;
{{Note box|Using '''passwordHash''' is the recommended way of storing passwords.}}&lt;br /&gt;
{{New feature/item|3.0154|1.5.4|11277|&lt;br /&gt;
This function creates a new password hash using a specified hashing algorithm.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|It is strongly recommended to use the async version of the function (i.e. provide a callback function). Otherwise, you will experience short freezes due to the slow nature of the bcrypt algorithm}}&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string passwordHash ( string password, string algorithm, table options = {} [, function callback ])  &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''password:''' The password to hash.&lt;br /&gt;
*'''algorithm:''' The algorithm to use:&lt;br /&gt;
** ''bcrypt'': use the bcrypt hashing algorithm. Hash length: 60 characters. &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Note that only the prefix ''$2y$'' is supported (older prefixes can cause security issues).&amp;lt;/span&amp;gt;&lt;br /&gt;
*'''options:''' table with options for the hashing algorithm, as detailed below.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
{{New feature/item|3.0154|1.5.4|11281|&lt;br /&gt;
*'''callback:''' providing a callback will run this function asynchronously, the arguments to the callback are the same as the returned values below.&lt;br /&gt;
}}&lt;br /&gt;
===Options for each hashing algorithm===&lt;br /&gt;
* ''bcrypt'':&lt;br /&gt;
** ''cost'' (int), default: 10.  Visit [http://security.stackexchange.com/questions/17207/recommended-of-rounds-for-bcrypt this link] to determine the number of rounds appropriate for your server.&lt;br /&gt;
** ''salt'' (string), default: automatically generate salt &lt;br /&gt;
*** an empty string will automatically generate a salt with the ''cost'' provided&lt;br /&gt;
*** if a string is provided, the given salt is used (do not do this!)&lt;br /&gt;
*** the provided string should be longer or equal than 22 characters&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the hash as a string if hashing was successful, ''false'' otherwise. If a callback was provided, the aforementioned values are arguments to the callback, and this function will always return ''true''.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
{{Warning|If you will be using &amp;quot;Example 1&amp;quot; then you will have to save account data &amp;quot;hash_password&amp;quot; after server restart, otherwise this script will no longer work.}}&lt;br /&gt;
This example makes use of [https://wiki.multitheftauto.com/wiki/PasswordHash passwordHash] and [https://wiki.multitheftauto.com/wiki/PasswordVerify passwordVerify] in account creation and account login to boost up security.&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example 1&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
* Use '''&amp;lt;/accountCreate [username] [password]&amp;gt;''' to create an account.&lt;br /&gt;
* Use '''&amp;lt;/accountLogin [username] [password]&amp;gt;''' to login in account.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- lets add command handler that will handle the account creation&lt;br /&gt;
addCommandHandler(&amp;quot;accountCreate&amp;quot;,function(source,cmd,username,password)&lt;br /&gt;
	if (username and password) then&lt;br /&gt;
		local hashedPassword = passwordHash(password,&amp;quot;bcrypt&amp;quot;) -- create new hash for password&lt;br /&gt;
		if (hashedPassword) then -- check if hash has been generated&lt;br /&gt;
			local account = addAccount(username,hashedPassword) -- now lets add account with new hash what we got when we made it for password.&lt;br /&gt;
			if (account) then&lt;br /&gt;
				setAccountData(account,&amp;quot;hash_password&amp;quot;,hashedPassword) -- store accounts password hash in order to verify it when it's needed.&lt;br /&gt;
				outputChatBox(&amp;quot;Account successfuly created! Now please login. Syntax &amp;lt;/accountLogin [username] [password]&amp;gt;&amp;quot;,source,20,160,20)&lt;br /&gt;
			else&lt;br /&gt;
				outputChatBox(&amp;quot;Account already exists! Please try again with different username.&amp;quot;,source,20,160,20)&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			outputChatBox(&amp;quot;Securing your password failed! Please try again or contact an administrator.&amp;quot;,source,160,20,20)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		outputChatBox(&amp;quot;Wrong parameters! Correct Syntax &amp;lt;/accountCreate [username] [password]&amp;gt;&amp;quot;,source,160,20,20)&lt;br /&gt;
	end&lt;br /&gt;
end);&lt;br /&gt;
&lt;br /&gt;
-- lets add command handler that will handle the account login&lt;br /&gt;
addCommandHandler(&amp;quot;accountLogin&amp;quot;,function(source,cmd,username,password)&lt;br /&gt;
	if (username and password) then&lt;br /&gt;
		local account = getAccount(username) -- get entered account&lt;br /&gt;
		if (account) then -- check if entered account exists&lt;br /&gt;
			local hashedPassword = getAccountData(account,&amp;quot;hash_password&amp;quot;) -- lets get hashed password&lt;br /&gt;
			if (passwordVerify(password,hashedPassword)) then -- check if hash and entered password matches&lt;br /&gt;
				if logIn(source,account,hashedPassword) then -- now lets login player into account&lt;br /&gt;
					outputChatBox(&amp;quot;Login successfull. Welcome, &amp;quot;..getAccountName(account)..&amp;quot;!&amp;quot;,source,20,160,20)&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				outputChatBox(&amp;quot;Password is incorrect!&amp;quot;,source,160,20,20)&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			outputChatBox(&amp;quot;Account doesn't exist! Please try again with different account.&amp;quot;,source,160,20,20)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		outputChatBox(&amp;quot;Wrong parameters! Correct Syntax &amp;lt;/accountLogin [username] [password]&amp;gt;&amp;quot;,source,160,20,20)&lt;br /&gt;
	end&lt;br /&gt;
end);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Utility functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Sha256&amp;diff=53969</id>
		<title>Sha256</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Sha256&amp;diff=53969"/>
		<updated>2018-02-17T05:34:08Z</updated>

		<summary type="html">&lt;p&gt;Skully: Fixed typo and hyperlinked function.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
&lt;br /&gt;
{{Note box|returns an uppercase string, so make sure you string.upper() anything else you are checking against that has been sha256'd elsewhere.}}&lt;br /&gt;
{{Tip|The sha module and this function may conflict with eachother, if you use this function uninstall the module!}}&lt;br /&gt;
{{Warning|It is strongly recommended to use [[passwordHash]] to hash passwords, because Sha256 is easily decodable.}}&lt;br /&gt;
&lt;br /&gt;
Calculates the sha256 hash of the specified string.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;string sha256 ( string str )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''str:''' the string to hash.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the sha256 hash of the input string if successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.3.1-9.04836|1.3.1-9.04836|}}&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler ( &amp;quot;sha&amp;quot;, -- Create a command&lt;br /&gt;
	function ( thePlayer, command, input )&lt;br /&gt;
		if ( input ) then -- Check if the string exist&lt;br /&gt;
			local sha256hash = sha256( input ) -- Generate the hash&lt;br /&gt;
			outputChatBox( sha256hash ) -- Output the hash in the chat&lt;br /&gt;
		end&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;
{{Utility functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User:Skully&amp;diff=53877</id>
		<title>User:Skully</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User:Skully&amp;diff=53877"/>
		<updated>2018-02-05T01:00:29Z</updated>

		<summary type="html">&lt;p&gt;Skully: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Hello!==&lt;br /&gt;
&lt;br /&gt;
I like dank memes, thanks for stopping by.&lt;br /&gt;
&lt;br /&gt;
'''Forum Profile:''' https://forum.mtasa.com/profile/57023-skully/&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User_talk:Thisdp&amp;diff=53876</id>
		<title>User talk:Thisdp</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User_talk:Thisdp&amp;diff=53876"/>
		<updated>2018-02-05T00:59:19Z</updated>

		<summary type="html">&lt;p&gt;Skully: Created page with &amp;quot;== DGS Wiki == Thanks for the great work on your resource and the Wiki itself, it's extremely useful! --~~~~&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== DGS Wiki ==&lt;br /&gt;
Thanks for the great work on your resource and the Wiki itself, it's extremely useful! --[[User:Skully|Skully]] ([[User talk:Skully|talk]]) 00:58, 5 February 2018 (UTC)&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User:Skully&amp;diff=53875</id>
		<title>User:Skully</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User:Skully&amp;diff=53875"/>
		<updated>2018-02-05T00:54:15Z</updated>

		<summary type="html">&lt;p&gt;Skully: Created page with &amp;quot;Hello!  I like dank memes, thanks for stopping by.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hello!&lt;br /&gt;
&lt;br /&gt;
I like dank memes, thanks for stopping by.&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DgsComboBoxGetSelectedItem&amp;diff=53874</id>
		<title>DgsComboBoxGetSelectedItem</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DgsComboBoxGetSelectedItem&amp;diff=53874"/>
		<updated>2018-02-05T00:52:21Z</updated>

		<summary type="html">&lt;p&gt;Skully: /* Fixed error in example not calling exported function. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function returns the index of the selected dgs combobox item.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
int dgsComboBoxGetSelectedItem ( element comboBox )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''comboBox:''' the dgs combobox you want to know the selected item index of&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns the index of the selected item if the specified dgs combobox is valid and has a selected item, ''-1'' if no item is selected, ''false'' or ''nil'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example outputs selected item's text and ID to the chat.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
&lt;br /&gt;
comboBox = DGS:dgsCreateComboBox(200,200,100,30,false)&lt;br /&gt;
for i=1,5 do&lt;br /&gt;
	DGS:dgsComboBoxAddItem(comboBox,i..&amp;quot;test&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;getSelected&amp;quot;,function (command)&lt;br /&gt;
	local item = DGS:dgsComboBoxGetSelectedItem (comboBox)&lt;br /&gt;
	local text = DGS:dgsComboBoxGetItemText(comboBox, item)&lt;br /&gt;
	outputChatBox(&amp;quot;Currently selected item with ID: &amp;quot; .. tostring(item) .. &amp;quot; and with text: &amp;quot; .. text)&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{DGSFUNCTIONS}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=TriggerClientEvent&amp;diff=53870</id>
		<title>TriggerClientEvent</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=TriggerClientEvent&amp;diff=53870"/>
		<updated>2018-02-03T20:21:24Z</updated>

		<summary type="html">&lt;p&gt;Skully: Parameter order fixed.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--{{Needs_Checking|Something needs to be said about the steps required to help keep an event inside a resource. i.e. Setting 'theElement' to resourceRoot here, and setting the matching event handler's 'attachedTo' also to resourceRoot.}}&lt;br /&gt;
--&amp;gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function triggers an event previously registered on a client. This is the primary means of passing information between the server and the client. Clients have a similar [[triggerServerEvent]] function that can do the reverse. You can treat this function as if it was an asynchronous function call, using [[triggerServerEvent]] to pass back any returned information if necessary.&lt;br /&gt;
&lt;br /&gt;
Almost any data types can be passed as expected, including [[element]]s and complex nested [[table]]s. Non-element MTA data types like xmlNodes or resource pointers will not be able to be passed as they do not necessarily have a valid representation on the client.&lt;br /&gt;
&lt;br /&gt;
Events are sent reliably, so clients will receive them, but there may be (but shouldn't be) a significant delay before they are received. You should take this into account when using them.&lt;br /&gt;
&lt;br /&gt;
Keep in mind the bandwidth issues when using events - don't pass a large list of arguments unless you really need to. It is marginally more efficient to pass one large event than two smaller ones.&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool triggerClientEvent ( [table/element sendTo=getRootElement()], string name, element sourceElement, [arguments...] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
{{OOP||[[player]]:triggerEvent||}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''sourceElement:''' The element that is the [[Event system#Event handlers|source]] of the event.&lt;br /&gt;
*'''name:''' The name of the event to trigger client side. You should register this event with [[addEvent]] and add at least one event handler using [[addEventHandler]].&lt;br /&gt;
{{Note|To save client CPU, you should avoid setting '''sourceElement''' to the [[root element]] where possible. Using [[GetThisResource|resourceRoot]] is usually sufficient if the event is handled by the same resource on the client.}}&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''sendTo:''' The event will be sent to all [[player]]s that are children of the specified element. By default this is the root element, and hence the event is sent to all players. If you specify a single player it will just be sent to that player. This argument can also be a table of player elements.&lt;br /&gt;
*'''arguments...:''' A list of arguments to trigger with the event. You can pass any lua data type (except functions). You can also pass [[element]]s.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the event trigger has been sent, ''false'' if invalid arguments were specified.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
===Example 1===&lt;br /&gt;
This example shows how you can pass a simple &amp;quot;Hello World&amp;quot; message from the server to the all the clients using an event.&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;
function greetingHandler ( message )&lt;br /&gt;
    outputChatBox ( &amp;quot;The server says: &amp;quot; .. message )&lt;br /&gt;
end&lt;br /&gt;
addEvent( &amp;quot;onGreeting&amp;quot;, true )&lt;br /&gt;
addEventHandler( &amp;quot;onGreeting&amp;quot;, localPlayer, greetingHandler )&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 greetingCommand ( playerSource, commandName )&lt;br /&gt;
    triggerClientEvent ( playerSource, &amp;quot;onGreeting&amp;quot;, playerSource, &amp;quot;Hello World!&amp;quot; )&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;greet&amp;quot;, greetingCommand )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the command &amp;quot;greet&amp;quot; is executed (by typing it in the server console or the player's console), the server's ''greetingCommand'' function is called. This triggers the client side event ''onGreeting'' with the string ''&amp;quot;Hello World!&amp;quot;''. This event is then handled by the ''greetingHandler'' function client side which then displays the message.&lt;br /&gt;
&lt;br /&gt;
===Example 2===&lt;br /&gt;
This example shows how you can pass a simple &amp;quot;Hello World&amp;quot; message from the server to '''a single''' client using an event.&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;
function greetingHandler ( message )&lt;br /&gt;
    outputChatBox ( &amp;quot;The server says: &amp;quot; .. message )&lt;br /&gt;
end&lt;br /&gt;
addEvent( &amp;quot;onGreeting&amp;quot;, true )&lt;br /&gt;
addEventHandler( &amp;quot;onGreeting&amp;quot;, localPlayer, greetingHandler )&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 greetingCommandOne ( playerSource, commandName, playerName )&lt;br /&gt;
    if playerName then&lt;br /&gt;
        local thePlayer = getPlayerFromName ( playerName )&lt;br /&gt;
        if thePlayer then&lt;br /&gt;
            triggerClientEvent ( thePlayer, &amp;quot;onGreeting&amp;quot;, thePlayer, &amp;quot;Hello World!&amp;quot; )&lt;br /&gt;
        else&lt;br /&gt;
            -- invalid player name specified&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        -- No player name specified&lt;br /&gt;
    end &lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;greet_one&amp;quot;, greetingCommandOne )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This works like the first example except an extra ''thePlayer'' argument is specified for triggerClientEvent.&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.3.0-9.04570|Added option to use a list of player elements for the 'sendTo' argument}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Event functions}}&lt;br /&gt;
[[ru:triggerClientEvent]]&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Resource:DGS&amp;diff=53865</id>
		<title>Resource:DGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Resource:DGS&amp;diff=53865"/>
		<updated>2018-02-02T19:08:49Z</updated>

		<summary type="html">&lt;p&gt;Skully: Another adjustment to fix grammatical issues and english.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pageclass class=&amp;quot;resource&amp;quot; subcaption=&amp;quot;Resource&amp;quot;&amp;gt;&amp;lt;/pageclass&amp;gt;&lt;br /&gt;
[[Image:DGSNetStatus.png|300px|thumb|right|DGS Network Monitor]]&lt;br /&gt;
&lt;br /&gt;
This resource is designed to allow you to create directX GUI's as an alternative to the original MTA:SA GUI functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Full Name''': Thisdp's DirectX Graphical User Interface System (DxGUI Lib)&lt;br /&gt;
&lt;br /&gt;
'''Author''': [[User:thisdp|thisdp]] &lt;br /&gt;
&lt;br /&gt;
'''State''': OpenSource (WIP)&lt;br /&gt;
&lt;br /&gt;
'''GitHub Source''': https://github.com/thisdp/dgs/tree/master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Features=&lt;br /&gt;
&lt;br /&gt;
[[Image:DGSS.png|400px|thumb|right|]] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''How does it work?'''&lt;br /&gt;
*DGS is just like the original gui system that is based on element system. I use a simple way that can make it easier to understand.&lt;br /&gt;
*DGS elements are rendered in &amp;quot;onClientRender&amp;quot;. There is two or more tables store DGS elements. When &amp;quot;onClientRender&amp;quot; is called, &amp;quot;for&amp;quot; loop will loop and calculate every DGS element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's different?'''&lt;br /&gt;
*This resource is based on dx* functions. It allows us to edit our gui and make it in customlization.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Update System'''&lt;br /&gt;
*It have an update system that can keep your DGS latest.&lt;br /&gt;
*When a newer version has been pushed, it will detected and notice you to update dgs.&lt;br /&gt;
*Execute command &amp;quot;'''updatedgs'''&amp;quot; to check the least version and update your DGS.&lt;br /&gt;
*You can check the version of DGS by command &amp;quot;dgsver&amp;quot; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Update Logs'''&lt;br /&gt;
*'''You can view the update logs here: [http://angel.mtaip.cn:233/dgsUpdate/ Update Log]'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''You Should Know'''&lt;br /&gt;
*Scroll Pane, Grid List, Combo Box, Memo and Edit box use Render Target, which means if you don't have enough video memory, '''Render Target won't be created.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Dx_7.PNG|400px|thumb|right|Example DGS Cmd]] &lt;br /&gt;
&lt;br /&gt;
'''Examples scripts'''&lt;br /&gt;
*1.https://community.multitheftauto.com/index.php?p=resources&amp;amp;s=details&amp;amp;id=14757 By ([[User:Ahmed Ly|Ahmed Ly]] ,Mahmod Algeriany)&lt;br /&gt;
*2. Also File test.lua its have more Examples You can See it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Auto Completion'''&lt;br /&gt;
*1. Link: http://www.mediafire.com/file/m6dm7815d5dihax/lua.zip  By [[User:Ahmed Ly|Ahmed Ly]] &lt;br /&gt;
*2. '''Note''': You must put it in file Notepad++\plugins\APIs.&lt;br /&gt;
*3. Not all of DGS Functions are added, but the rest will be added soon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Debug'''&lt;br /&gt;
* You can enter the debug mode by executing the command &amp;quot;'''debugdgs'''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DGS Type'''&lt;br /&gt;
[[Image:Dx Dgs.jpg|400px|thumb|right|Hurt World GUI Example]] &lt;br /&gt;
* Button (dgs-dxbutton): A button.&lt;br /&gt;
* Command (dgs-dxcmd): A command just like windows.&lt;br /&gt;
* Ellipse Detect Area (dgs-dxeda): An oval detect area.&lt;br /&gt;
* Edit (dgs-dxedit): An edit.&lt;br /&gt;
* Memo (dgs-dxmemo): A memo.&lt;br /&gt;
* Gridlist (dgs-dxgridlist): A grid list.&lt;br /&gt;
* Image (dgs-dximage): A dynamic image.&lt;br /&gt;
* Label (dgs-dxlabel): A text label.&lt;br /&gt;
* Ellipse Detect Area (EDA)&lt;br /&gt;
* ScrollBar (dgs-dxscrollbar): A scroll bar.&lt;br /&gt;
* ScrollPane (dgs-dxscrollpane): A scroll pane.&lt;br /&gt;
* Tab Panel (dgs-dxtabpanel + dgs-dxtab) : A tab panel. &lt;br /&gt;
* Window (dgs-dxwindow): A window.&lt;br /&gt;
* Progress Bar (dgs-dxprogressbar): A Progress Bar.&lt;br /&gt;
* Radio Button (dgs-dxradiobutton): A Radio Button.&lt;br /&gt;
* Combo Box (dgs-dxcombobox + dgs-dxcombobox-Box) : A combo box.&lt;br /&gt;
* Check Box (dgs-dxcheckbox) : A check box that with 3 states (checked, unchecked and indeterminate).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Notice'''&lt;br /&gt;
*It is recommended to change the resource name to 'dgs'.&lt;br /&gt;
*This is a resource, if you want to use the functions exported by this resource, you should use a exported function call in your code, such as &amp;quot;'''exports.dgs:dgsCreateLabel(0, 0, 0.5, 0.1, &amp;quot;text&amp;quot;, true)'''&amp;quot;.&lt;br /&gt;
*Here is a feasible way to shorten the name of an exported function:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs --shorten the export function prefix&lt;br /&gt;
label = DGS:dgsCreateLabel(0,0,0.5,0.1,&amp;quot;text&amp;quot;,false) --create a label&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Special thanks to the following for their help''':&lt;br /&gt;
[[Image:Tab.PNG |200px|thumb|right|Example tab panel and label .]] &lt;br /&gt;
* Axel: Gives some tips and provide some functions.&lt;br /&gt;
* Senpai: Helps write wiki.&lt;br /&gt;
* ZoNe: Helps write wiki.&lt;br /&gt;
* DiGiTal: Helps write wiki.&lt;br /&gt;
* #Dv^: Helps write wiki.&lt;br /&gt;
&lt;br /&gt;
Special thanks to:&lt;br /&gt;
* Ahmed Ly: Helps write wiki, release auto completion for N++.&lt;br /&gt;
&lt;br /&gt;
='''DGS Element Properties'''=&lt;br /&gt;
{{DGSPROPERTIES}}&lt;br /&gt;
&lt;br /&gt;
='''Client Functions'''=&lt;br /&gt;
{{DGSFUNCTIONS}}&lt;br /&gt;
&lt;br /&gt;
=Client Events=&lt;br /&gt;
{{DGSEVENTS}}&lt;br /&gt;
&lt;br /&gt;
=Last=&lt;br /&gt;
'''Everyone is welcome to make suggestions, test the script, help make adjustments/finish the wiki, etc.'''&lt;br /&gt;
[[Category:Resource]]&lt;br /&gt;
&lt;br /&gt;
[[ZH-CN:Dgs]]&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Resource:DGS&amp;diff=53864</id>
		<title>Resource:DGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Resource:DGS&amp;diff=53864"/>
		<updated>2018-02-02T19:05:25Z</updated>

		<summary type="html">&lt;p&gt;Skully: Adjusted grammar and fixed english.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pageclass class=&amp;quot;resource&amp;quot; subcaption=&amp;quot;Resource&amp;quot;&amp;gt;&amp;lt;/pageclass&amp;gt;&lt;br /&gt;
[[Image:DGSNetStatus.png|300px|thumb|right|DGS Network Monitor]]&lt;br /&gt;
&lt;br /&gt;
This resource is designed to allow you to create directX GUI's as an alternative to the original MTA:SA GUI functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Full Name''': Thisdp's DirectX Graphical User Interface System (DxGUI Lib)&lt;br /&gt;
&lt;br /&gt;
'''Author''': [[User:thisdp|thisdp]] &lt;br /&gt;
&lt;br /&gt;
'''State''': OpenSource (WIP)&lt;br /&gt;
&lt;br /&gt;
'''GitHub Source''': https://github.com/thisdp/dgs/tree/master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Features=&lt;br /&gt;
&lt;br /&gt;
[[Image:DGSS.png|400px|thumb|right|]] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''How does it work?'''&lt;br /&gt;
*DGS is just like the original gui system that is based on element system. I use a simple way that can make it easier to understand.&lt;br /&gt;
*DGS elements are rendered in &amp;quot;onClientRender&amp;quot;. There is two or more tables store DGS elements. When &amp;quot;onClientRender&amp;quot; is called, &amp;quot;for&amp;quot; loop will loop and calculate every DGS element.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What's different?'''&lt;br /&gt;
*This resource is based on dx* functions. It allows us to edit our gui and make it in customlization.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Update System'''&lt;br /&gt;
*It have an update system that can keep your DGS latest.&lt;br /&gt;
*When a newer version has been pushed, it will detected and notice you to update dgs.&lt;br /&gt;
*Execute command &amp;quot;'''updatedgs'''&amp;quot; to check the least version and update your DGS.&lt;br /&gt;
*You can check the version of DGS by command &amp;quot;dgsver&amp;quot; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Update Logs'''&lt;br /&gt;
*'''[http://angel.mtaip.cn:233/dgsUpdate/ Update Log]'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''You Should Know'''&lt;br /&gt;
*'''Scroll Pane/Grid List/Combo Box/Memo/Edit use Render Target, which means if you don't have enough video memory, Render Target won't be created.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Dx_7.PNG|400px|thumb|right|Example DGS Cmd]] &lt;br /&gt;
&lt;br /&gt;
'''Examples scripts'''&lt;br /&gt;
*1.https://community.multitheftauto.com/index.php?p=resources&amp;amp;s=details&amp;amp;id=14757 By ([[User:Ahmed Ly|Ahmed Ly]] ,Mahmod Algeriany)&lt;br /&gt;
*2. Also File test.lua its have more Examples You can See it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Auto Completion'''&lt;br /&gt;
*1.link:http://www.mediafire.com/file/m6dm7815d5dihax/lua.zip  By [[User:Ahmed Ly|Ahmed Ly]] &lt;br /&gt;
*'''Note''':&lt;br /&gt;
*2.You must put it in file Notepad++\plugins\APIs.&lt;br /&gt;
*3.Not all of DGS Functions are added, but the rest will be added soon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Debug'''&lt;br /&gt;
*You can enter the debug mode by executing the command &amp;quot;'''debugdgs'''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''DGS Type'''&lt;br /&gt;
[[Image:Dx Dgs.jpg|400px|thumb|right|Hurt World GUI Example]] &lt;br /&gt;
* Button (dgs-dxbutton): A button.&lt;br /&gt;
* Command (dgs-dxcmd): A command just like windows.&lt;br /&gt;
* Ellipse Detect Area (dgs-dxeda): An oval detect area.&lt;br /&gt;
* Edit (dgs-dxedit): An edit.&lt;br /&gt;
* Memo (dgs-dxmemo): A memo.&lt;br /&gt;
* Gridlist (dgs-dxgridlist): A grid list.&lt;br /&gt;
* Image (dgs-dximage): A dynamic image.&lt;br /&gt;
* Label (dgs-dxlabel): A text label.&lt;br /&gt;
* Ellipse Detect Area (EDA)&lt;br /&gt;
* ScrollBar (dgs-dxscrollbar): A scroll bar.&lt;br /&gt;
* ScrollPane (dgs-dxscrollpane): A scroll pane.&lt;br /&gt;
* Tab Panel (dgs-dxtabpanel + dgs-dxtab) : A tab panel. &lt;br /&gt;
* Window (dgs-dxwindow): A window.&lt;br /&gt;
* Progress Bar (dgs-dxprogressbar): A Progress Bar.&lt;br /&gt;
* Radio Button (dgs-dxradiobutton): A Radio Button.&lt;br /&gt;
* Combo Box (dgs-dxcombobox + dgs-dxcombobox-Box) : A combo box.&lt;br /&gt;
* Check Box (dgs-dxcheckbox) : A check box that with 3 states (checked, unchecked and indeterminate).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Notice'''&lt;br /&gt;
*It is recommended to change the resource name to 'dgs'.&lt;br /&gt;
*This is a resource, if you want to use the functions exported by this resource, you should use a exported function call in your code, such as &amp;quot;'''exports.dgs:dgsCreateLabel(0, 0, 0.5, 0.1, &amp;quot;text&amp;quot;, true)'''&amp;quot;.&lt;br /&gt;
*Here is a feasible way to shorten the name of an exported function:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs --shorten the export function prefix&lt;br /&gt;
label = DGS:dgsCreateLabel(0,0,0.5,0.1,&amp;quot;text&amp;quot;,false) --create a label&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Special thanks to the following for their help''' :&lt;br /&gt;
[[Image:Tab.PNG |200px|thumb|right|Example tab panel and label .]] &lt;br /&gt;
* Axel: Gives some tips and provide some functions.&lt;br /&gt;
* Senpai: Helps write wiki.&lt;br /&gt;
* ZoNe: Helps write wiki.&lt;br /&gt;
* DiGiTal: Helps write wiki.&lt;br /&gt;
* #Dv^: Helps write wiki.&lt;br /&gt;
--&amp;gt;Especially For:&lt;br /&gt;
* Ahmed Ly: Helps write wiki, release auto completion for N++.&lt;br /&gt;
&lt;br /&gt;
='''DGS Element Properties'''=&lt;br /&gt;
{{DGSPROPERTIES}}&lt;br /&gt;
&lt;br /&gt;
='''Client Functions'''=&lt;br /&gt;
{{DGSFUNCTIONS}}&lt;br /&gt;
&lt;br /&gt;
=Client Events=&lt;br /&gt;
{{DGSEVENTS}}&lt;br /&gt;
&lt;br /&gt;
=Last=&lt;br /&gt;
'''Everyone is welcome to make suggestions, test the script, help make adjustments/finish the wiki, etc.'''&lt;br /&gt;
[[Category:Resource]]&lt;br /&gt;
&lt;br /&gt;
[[ZH-CN:Dgs]]&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=ToggleControl&amp;diff=52292</id>
		<title>ToggleControl</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ToggleControl&amp;diff=52292"/>
		<updated>2017-09-14T13:53:46Z</updated>

		<summary type="html">&lt;p&gt;Skully: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
Enables or disables the use of a GTA control for a specific player.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool toggleControl ( player thePlayer, string control, bool enabled ) &amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePlayer:''' The player you wish to toggle the control ability of.&lt;br /&gt;
*'''control:''' The control that you want to toggle the ability of. See [[control names]] for a list of possible controls.&lt;br /&gt;
*'''enabled:''' A boolean value representing whether or not the key will be usable or not.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool toggleControl ( string control, bool enabled ) &amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''control:''' The control that you want to toggle the ability of. See [[control names]] for a list of possible controls.&lt;br /&gt;
*'''enabled:''' A boolean value representing whether or not the key will be usable or not.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
This function ''true'' if the control was set successfully, ''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;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This function will disable the use of the vehicle secondary-fire key for anyone in a Hydra, consequently removing the ability to fire rockets.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function disableFireForHydra ( theVehicle, seat, jacked )&lt;br /&gt;
    if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra&lt;br /&gt;
        toggleControl ( source, &amp;quot;vehicle_secondary_fire&amp;quot;, false ) -- disable their fire key&lt;br /&gt;
    else -- if they entered another vehicle&lt;br /&gt;
        toggleControl ( source, &amp;quot;vehicle_secondary_fire&amp;quot;, true ) -- enable their fire key&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerVehicleEnter&amp;quot;, getRootElement(), disableFireForHydra )&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 function will disable the use of the vehicle secondary-fire key for anyone in a Hydra, consequently removing the ability to fire rockets.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function disableFireForHydra ( theVehicle, seat )&lt;br /&gt;
    if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra&lt;br /&gt;
        toggleControl ( &amp;quot;vehicle_secondary_fire&amp;quot;, false ) -- disable their fire key&lt;br /&gt;
    else -- if they entered another vehicle&lt;br /&gt;
        toggleControl ( &amp;quot;vehicle_secondary_fire&amp;quot;, true ) -- enable their fire key&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onClientPlayerVehicleEnter&amp;quot;, getLocalPlayer(), disableFireForHydra )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Input functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementSpeed&amp;diff=52291</id>
		<title>GetElementSpeed</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementSpeed&amp;diff=52291"/>
		<updated>2017-09-14T13:51:19Z</updated>

		<summary type="html">&lt;p&gt;Skully: /* Optional arguments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the speed of an element in m/s, km/h or mph.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float/nil getElementSpeed ( element theElement [, int/string unit=&amp;quot;m/s&amp;quot; ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''theElement''': the [[element]] you want to get the speed of. Compatible [[element]] types are:&lt;br /&gt;
** [[Player|Players]]&lt;br /&gt;
** [[Ped|Peds]]&lt;br /&gt;
** [[Object|Objects]]&lt;br /&gt;
** [[Vehicle|Vehicles]]&lt;br /&gt;
** [[Projectile|Projectiles]]&lt;br /&gt;
&lt;br /&gt;
===Optional arguments===&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
* '''Unit''': The unit of the speed returned. If not specified, the unit will be ''m/s''. It can be specified as a ''[[string]]'' or ''number'' as follows:&lt;br /&gt;
** '''0''' or '''m/s''': meters per second (speed unit of the [http://en.wikipedia.org/wiki/International_System_of_Units International System of Units], used in formal contexts).&lt;br /&gt;
** '''1''' or '''km/h''': kilometres per hour (the most common speed unit, used in most countries).&lt;br /&gt;
** '''2''' or '''mph''': miles per hour (used in some English-speaking countries).&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
This function returns a ''number'' containing the [[element]]'s speed if the arguments provided are valid. It returns ''[[nil]]'' plus an ''error'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Function source&amp;quot; class=&amp;quot;both&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
'''It is recommended to use MTA:SA 1.4''' or higher with this function to use [[OOP]].&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getElementSpeed(theElement, unit)&lt;br /&gt;
    -- Check arguments for errors&lt;br /&gt;
    assert(isElement(theElement), &amp;quot;Bad argument 1 @ getElementSpeed (element expected, got &amp;quot; .. type(theElement) .. &amp;quot;)&amp;quot;)&lt;br /&gt;
    local elementType = getElementType(theElement)&lt;br /&gt;
    assert(elementType == &amp;quot;player&amp;quot; or elementType == &amp;quot;ped&amp;quot; or elementType == &amp;quot;object&amp;quot; or elementType == &amp;quot;vehicle&amp;quot; or elementType == &amp;quot;projectile&amp;quot;, &amp;quot;Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got &amp;quot; .. elementType .. &amp;quot;)&amp;quot;)&lt;br /&gt;
    assert((unit == nil or type(unit) == &amp;quot;string&amp;quot; or type(unit) == &amp;quot;number&amp;quot;) and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == &amp;quot;m/s&amp;quot; or unit == &amp;quot;km/h&amp;quot; or unit == &amp;quot;mph&amp;quot;), &amp;quot;Bad argument 2 @ getElementSpeed (invalid speed unit)&amp;quot;)&lt;br /&gt;
    -- Default to m/s if no unit specified and 'ignore' argument type if the string contains a number&lt;br /&gt;
    unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))&lt;br /&gt;
    -- Setup our multiplier to convert the velocity to the specified unit&lt;br /&gt;
    local mult = (unit == 0 or unit == &amp;quot;m/s&amp;quot;) and 50 or ((unit == 1 or unit == &amp;quot;km/h&amp;quot;) and 180 or 111.84681456)&lt;br /&gt;
    -- Return the speed by calculating the length of the velocity vector, after converting the velocity to the specified unit&lt;br /&gt;
    return (Vector3(getElementVelocity(theElement)) * mult).length&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;Clientside example&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example draws the local player's speed rounded to a single decimal in the top-right corner of the screen in different units.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sx = guiGetScreenSize()&lt;br /&gt;
local function drawSpeed()&lt;br /&gt;
    local speedms, speedkmh, speedmph = getElementSpeed(localPlayer), getElementSpeed(localPlayer, 1), getElementSpeed(localPlayer, 2)&lt;br /&gt;
    local roundedSpeedms, roundedSpeedkmh, roundedSpeedmph = math.floor(speedms) == speedms and speedms or string.format(speedms, &amp;quot;%.1f&amp;quot;), math.floor(speedkmh) == speedkmh and speedkmh or string.format(speedkmh, &amp;quot;%.1f&amp;quot;), math.floor(speedmph) == speedmph and speedmph or string.format(speedmph, &amp;quot;%.1f&amp;quot;)&lt;br /&gt;
    local speedoText = &amp;quot;Current speed: &amp;quot; .. roundedSpeedms .. &amp;quot; m/s | &amp;quot; .. roundedSpeedkmh .. &amp;quot; km/h | &amp;quot; .. roundedSpeedmph .. &amp;quot; mph&amp;quot;&lt;br /&gt;
    dxDrawText(speedoText, sx - dxGetTextWidth(speedoText), 0)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientPreRender&amp;quot;, root, drawSpeed)&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;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementSpeed&amp;diff=52290</id>
		<title>GetElementSpeed</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementSpeed&amp;diff=52290"/>
		<updated>2017-09-14T13:50:00Z</updated>

		<summary type="html">&lt;p&gt;Skully: /* English improved. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the speed of an element in m/s, km/h or mph.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float/nil getElementSpeed ( element theElement [, int/string unit=&amp;quot;m/s&amp;quot; ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''theElement''': the [[element]] you want to get the speed of. Compatible [[element]] types are:&lt;br /&gt;
** [[Player|Players]]&lt;br /&gt;
** [[Ped|Peds]]&lt;br /&gt;
** [[Object|Objects]]&lt;br /&gt;
** [[Vehicle|Vehicles]]&lt;br /&gt;
** [[Projectile|Projectiles]]&lt;br /&gt;
&lt;br /&gt;
===Optional arguments===&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
* '''unit''': the unit of the speed returned. If not specified, the unit will be ''m/s''. It can be specified as a ''[[string]]'' or ''number'' as follows:&lt;br /&gt;
** '''0''' or '''m/s''': meters per second (speed unit of the [http://en.wikipedia.org/wiki/International_System_of_Units International System of Units], used in formal contexts).&lt;br /&gt;
** '''1''' or '''km/h''': kilometres per hour (the most common speed unit, used in most countries).&lt;br /&gt;
** '''2''' or '''mph''': miles per hour (used in some English-speaking countries).&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
This function returns a ''number'' containing the [[element]]'s speed if the arguments provided are valid. It returns ''[[nil]]'' plus an ''error'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Function source&amp;quot; class=&amp;quot;both&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
'''It is recommended to use MTA:SA 1.4''' or higher with this function to use [[OOP]].&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getElementSpeed(theElement, unit)&lt;br /&gt;
    -- Check arguments for errors&lt;br /&gt;
    assert(isElement(theElement), &amp;quot;Bad argument 1 @ getElementSpeed (element expected, got &amp;quot; .. type(theElement) .. &amp;quot;)&amp;quot;)&lt;br /&gt;
    local elementType = getElementType(theElement)&lt;br /&gt;
    assert(elementType == &amp;quot;player&amp;quot; or elementType == &amp;quot;ped&amp;quot; or elementType == &amp;quot;object&amp;quot; or elementType == &amp;quot;vehicle&amp;quot; or elementType == &amp;quot;projectile&amp;quot;, &amp;quot;Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got &amp;quot; .. elementType .. &amp;quot;)&amp;quot;)&lt;br /&gt;
    assert((unit == nil or type(unit) == &amp;quot;string&amp;quot; or type(unit) == &amp;quot;number&amp;quot;) and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == &amp;quot;m/s&amp;quot; or unit == &amp;quot;km/h&amp;quot; or unit == &amp;quot;mph&amp;quot;), &amp;quot;Bad argument 2 @ getElementSpeed (invalid speed unit)&amp;quot;)&lt;br /&gt;
    -- Default to m/s if no unit specified and 'ignore' argument type if the string contains a number&lt;br /&gt;
    unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))&lt;br /&gt;
    -- Setup our multiplier to convert the velocity to the specified unit&lt;br /&gt;
    local mult = (unit == 0 or unit == &amp;quot;m/s&amp;quot;) and 50 or ((unit == 1 or unit == &amp;quot;km/h&amp;quot;) and 180 or 111.84681456)&lt;br /&gt;
    -- Return the speed by calculating the length of the velocity vector, after converting the velocity to the specified unit&lt;br /&gt;
    return (Vector3(getElementVelocity(theElement)) * mult).length&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;Clientside example&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example draws the local player's speed rounded to a single decimal in the top-right corner of the screen in different units.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sx = guiGetScreenSize()&lt;br /&gt;
local function drawSpeed()&lt;br /&gt;
    local speedms, speedkmh, speedmph = getElementSpeed(localPlayer), getElementSpeed(localPlayer, 1), getElementSpeed(localPlayer, 2)&lt;br /&gt;
    local roundedSpeedms, roundedSpeedkmh, roundedSpeedmph = math.floor(speedms) == speedms and speedms or string.format(speedms, &amp;quot;%.1f&amp;quot;), math.floor(speedkmh) == speedkmh and speedkmh or string.format(speedkmh, &amp;quot;%.1f&amp;quot;), math.floor(speedmph) == speedmph and speedmph or string.format(speedmph, &amp;quot;%.1f&amp;quot;)&lt;br /&gt;
    local speedoText = &amp;quot;Current speed: &amp;quot; .. roundedSpeedms .. &amp;quot; m/s | &amp;quot; .. roundedSpeedkmh .. &amp;quot; km/h | &amp;quot; .. roundedSpeedmph .. &amp;quot; mph&amp;quot;&lt;br /&gt;
    dxDrawText(speedoText, sx - dxGetTextWidth(speedoText), 0)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientPreRender&amp;quot;, root, drawSpeed)&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;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementSpeed&amp;diff=52289</id>
		<title>GetElementSpeed</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementSpeed&amp;diff=52289"/>
		<updated>2017-09-14T13:49:02Z</updated>

		<summary type="html">&lt;p&gt;Skully: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the speed of an element in m/s, km/h or mph.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float/nil getElementSpeed ( element theElement [, int/string unit=&amp;quot;m/s&amp;quot; ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''theElement''': the [[element]] you want to get the speed of. Compatible [[element]] types are:&lt;br /&gt;
** [[Player|Players]]&lt;br /&gt;
** [[Ped|Peds]]&lt;br /&gt;
** [[Object|Objects]]&lt;br /&gt;
** [[Vehicle|Vehicles]]&lt;br /&gt;
** [[Projectile|Projectiles]]&lt;br /&gt;
&lt;br /&gt;
===Optional arguments===&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
* '''unit''': the unit of the speed returned. If not specified, the unit will be ''m/s''. It can be specified as a ''[[string]]'' or ''number'' as follows:&lt;br /&gt;
** '''0''' or '''m/s''': meters per second (speed unit of the [http://en.wikipedia.org/wiki/International_System_of_Units International System of Units], used in formal contexts).&lt;br /&gt;
** '''1''' or '''km/h''': kilometres per hour (the most common speed unit, used in most countries).&lt;br /&gt;
** '''2''' or '''mph''': miles per hour (used in some English-speaking countries).&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
This function returns a ''number'' containing the [[element]]'s speed if the arguments provided are valid. It returns ''[[nil]]'' plus an ''error'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Function source&amp;quot; class=&amp;quot;both&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
'''It is recommended to use MTA:SA 1.4''' or higher with this function to use [[OOP]].&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getElementSpeed(theElement, unit)&lt;br /&gt;
    -- Check arguments for errors&lt;br /&gt;
    assert(isElement(theElement), &amp;quot;Bad argument 1 @ getElementSpeed (element expected, got &amp;quot; .. type(theElement) .. &amp;quot;)&amp;quot;)&lt;br /&gt;
    local elementType = getElementType(theElement)&lt;br /&gt;
    assert(elementType == &amp;quot;player&amp;quot; or elementType == &amp;quot;ped&amp;quot; or elementType == &amp;quot;object&amp;quot; or elementType == &amp;quot;vehicle&amp;quot; or elementType == &amp;quot;projectile&amp;quot;, &amp;quot;Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got &amp;quot; .. elementType .. &amp;quot;)&amp;quot;)&lt;br /&gt;
    assert((unit == nil or type(unit) == &amp;quot;string&amp;quot; or type(unit) == &amp;quot;number&amp;quot;) and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == &amp;quot;m/s&amp;quot; or unit == &amp;quot;km/h&amp;quot; or unit == &amp;quot;mph&amp;quot;), &amp;quot;Bad argument 2 @ getElementSpeed (invalid speed unit)&amp;quot;)&lt;br /&gt;
    -- Default to m/s if no unit specified and 'ignore' argument type if the string contains a number&lt;br /&gt;
    unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))&lt;br /&gt;
    -- Setup our multiplier to convert the velocity to the specified unit&lt;br /&gt;
    local mult = (unit == 0 or unit == &amp;quot;m/s&amp;quot;) and 50 or ((unit == 1 or unit == &amp;quot;km/h&amp;quot;) and 180 or 111.84681456)&lt;br /&gt;
    -- Return the speed by calculating the length of the velocity vector, after converting the velocity to the specified unit&lt;br /&gt;
    return (Vector3(getElementVelocity(theElement)) * mult).length&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;Clientside example&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example draws the local player's speed rounded to a single decimal in the up-right corner of the screen in different units.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sx = guiGetScreenSize()&lt;br /&gt;
local function drawSpeed()&lt;br /&gt;
    local speedms, speedkmh, speedmph = getElementSpeed(localPlayer), getElementSpeed(localPlayer, 1), getElementSpeed(localPlayer, 2)&lt;br /&gt;
    local roundedSpeedms, roundedSpeedkmh, roundedSpeedmph = math.floor(speedms) == speedms and speedms or string.format(speedms, &amp;quot;%.1f&amp;quot;), math.floor(speedkmh) == speedkmh and speedkmh or string.format(speedkmh, &amp;quot;%.1f&amp;quot;), math.floor(speedmph) == speedmph and speedmph or string.format(speedmph, &amp;quot;%.1f&amp;quot;)&lt;br /&gt;
    local speedoText = &amp;quot;Current speed: &amp;quot; .. roundedSpeedms .. &amp;quot; m/s | &amp;quot; .. roundedSpeedkmh .. &amp;quot; km/h | &amp;quot; .. roundedSpeedmph .. &amp;quot; mph&amp;quot;&lt;br /&gt;
    dxDrawText(speedoText, sx - dxGetTextWidth(speedoText), 0)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onClientPreRender&amp;quot;, root, drawSpeed)&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;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Skully</name></author>
	</entry>
</feed>