<?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=Yeleha</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=Yeleha"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Yeleha"/>
	<updated>2026-04-11T14:21:31Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetElementLighting&amp;diff=81668</id>
		<title>SetElementLighting</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetElementLighting&amp;diff=81668"/>
		<updated>2025-01-06T09:24:25Z</updated>

		<summary type="html">&lt;p&gt;Yeleha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{New feature/item|3.0161|1.6.0|22862|This function changes the lighting value for the specified [[element]]. This can be a [[player]], [[ped]], [[vehicle]], [[object]], [[Element/Weapon|weapon]].}}&lt;br /&gt;
&lt;br /&gt;
{{Note|Lighting is calculated in real-time every frame. Therefore, to correctly override the lighting, you should use this function in combination with the [[onClientPedsProcessed]] event, not only for peds, but also for vehicles and objects.}}&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 setElementLighting ( element theElement, float lighting )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[element]]:setLighting|lighting|getElementLighting}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theElement:''' The [[element]] whose lighting you want to change.&lt;br /&gt;
*'''lighting:''' The lighting value that you want to set.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns true if the function was successful, false otherwise. This function can fail if called right after element creation.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example sets the lighting value of all players and vehicles to 10&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;addEventHandler(&amp;quot;onClientPedsProcessed&amp;quot;,root,function()&lt;br /&gt;
    for _, v in pairs(getElementsByType('player')) do&lt;br /&gt;
        setElementLighting(v, 10)&lt;br /&gt;
    end&lt;br /&gt;
    for _, v in pairs(getElementsByType('vehicle')) do&lt;br /&gt;
        setElementLighting(v, 10)&lt;br /&gt;
    end&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This example sets the lighting value to 10 only for our player, while keeping other players at the default value.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;addEventHandler(&amp;quot;onClientPedsProcessed&amp;quot;,root,function()&lt;br /&gt;
    setElementLighting(localPlayer, 10)&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client element functions}}&lt;/div&gt;</summary>
		<author><name>Yeleha</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetElementLighting&amp;diff=81667</id>
		<title>SetElementLighting</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetElementLighting&amp;diff=81667"/>
		<updated>2025-01-06T09:22:42Z</updated>

		<summary type="html">&lt;p&gt;Yeleha: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{New feature/item|3.0161|1.6.0|22862|This function changes the lighting value for the specified [[element]]. This can be a [[player]], [[ped]], [[vehicle]], [[object]], [[Element/Weapon|weapon]].}}&lt;br /&gt;
&lt;br /&gt;
{{Note|Lighting is calculated in real-time every frame. Therefore, to correctly override the lighting, you should use this function in combination with the [[onClientPedsProcessed]] event, not only for peds, but also for vehicles and objects.}}&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 setElementLighting ( element theElement, float lighting )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[element]]:setLighting|lighting|getElementLighting}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theElement:''' The [[element]] whose lighting you want to change.&lt;br /&gt;
*'''lighting:''' The lighting value that you want to set.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns true if the function was successful, false otherwise. This function can fail if called right after element creation.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;addEventHandler(&amp;quot;onClientPedsProcessed&amp;quot;,root,function()&lt;br /&gt;
    for _, v in pairs(getElementsByType('player')) do -- All players lighting set to 10&lt;br /&gt;
        setElementLighting(v, 10)&lt;br /&gt;
    end&lt;br /&gt;
    for _, v in pairs(getElementsByType('vehicle')) do -- All vehicles lighting set to 10&lt;br /&gt;
        setElementLighting(v, 10)&lt;br /&gt;
    end&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;addEventHandler(&amp;quot;onClientPedsProcessed&amp;quot;,root,function()&lt;br /&gt;
    setElementLighting(localPlayer, 10) -- Set the lighting value of our player to 10&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Client element functions}}&lt;/div&gt;</summary>
		<author><name>Yeleha</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Server_Browser_Rules&amp;diff=81655</id>
		<title>Server Browser Rules</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Server_Browser_Rules&amp;diff=81655"/>
		<updated>2025-01-05T13:15:16Z</updated>

		<summary type="html">&lt;p&gt;Yeleha: Add the Slovak language&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|The system described in this article is still work-in-progress!|true}} &lt;br /&gt;
{{Note|Developers are working on creating a new Server Browser Interface. Check these issues on GitHub: [https://github.com/multitheftauto/mtasa-blue/issues/2104 Add banner, server description and tags  #2104] [https://github.com/multitheftauto/mtasa-blue/issues/998 Revamp server browser #998] [https://github.com/multitheftauto/mtasa-blue/issues/759 Language filter/search #759]}} &lt;br /&gt;
&lt;br /&gt;
==Information==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;'''Server Browser Rules'''&amp;quot; are ''key-value'' string pairs defined server-side.&lt;br /&gt;
&lt;br /&gt;
These values are automatically transmitted/announced/broadcasted by your MTA Server using the ASE (All-Seeing Eye) protocol, when queried on the ASE UDP Port (server port + 123).&lt;br /&gt;
&lt;br /&gt;
This data is to be received and parsed by MTA Clients (in the Server Browser) to display the list of online MTA servers with custom information for each server.&lt;br /&gt;
&lt;br /&gt;
==Setting &amp;amp; Getting==&lt;br /&gt;
&lt;br /&gt;
These ''rules'' can be set in your MTA Server's configuration file ([[Server_mtaserver.conf]]) using the following XML format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;rule name=&amp;quot;NAME_HERE&amp;quot; value=&amp;quot;VALUE_HERE&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They can also be defined and obtained using these two server-side functions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[setRuleValue]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[getRuleValue]]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Expected Values==&lt;br /&gt;
&lt;br /&gt;
The maximum amount of characters allowed in a rule value is '''200'''.&lt;br /&gt;
&lt;br /&gt;
The Server Browser looks for the following information (optional) provided by servers:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Key !! Explanation !! Accepted values || Example&lt;br /&gt;
|-&lt;br /&gt;
| '''description''' || Human-readable brief description of your server || Text || Custom cars and maps! Join various minigames from racing to drifting&lt;br /&gt;
|-&lt;br /&gt;
| '''languages''' || Comma separated list of languages that your server supports || [[#Allowed Languages|See Allowed Languages]] || en, ru, ar&lt;br /&gt;
|-&lt;br /&gt;
| '''tags''' || Comma separated list of tags that describe your server || [[#Allowed Tags|See Allowed Tags]] || freeroam, minigames, race, pvp, drifting&lt;br /&gt;
|-&lt;br /&gt;
| '''website_url''' || Website URL of your server || Valid URL starting with https:// || https://example-website.com&lt;br /&gt;
|-&lt;br /&gt;
| '''social_url_1''' || Social media URL #1 || Valid URL starting with https:// || https://discord.com/invite/example&lt;br /&gt;
|-&lt;br /&gt;
| '''social_url_2''' || Social media URL #2 || Valid URL starting with https:// || https://youtube.com/@exampleChannel&lt;br /&gt;
|-&lt;br /&gt;
| '''social_url_3''' || Social media URL #3 || Valid URL starting with https:// || https://facebook.com/examplePage&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Full Example==&lt;br /&gt;
&lt;br /&gt;
Below is an example configuration that you can include in '''mtaserver.conf''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;rule name=&amp;quot;description&amp;quot; value=&amp;quot;Custom cars and maps! Join various minigames from racing to drifting&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;rule name=&amp;quot;languages&amp;quot; value=&amp;quot;en, ru, ar&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;rule name=&amp;quot;tags&amp;quot; value=&amp;quot;freeroam, minigames, race, pvp, drifting&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;rule name=&amp;quot;website_url&amp;quot; value=&amp;quot;https://example-website.com&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;rule name=&amp;quot;social_url_1&amp;quot; value=&amp;quot;https://discord.com/invite/example&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;rule name=&amp;quot;social_url_2&amp;quot; value=&amp;quot;https://youtube.com/@exampleChannel&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;rule name=&amp;quot;social_url_3&amp;quot; value=&amp;quot;https://facebook.com/examplePage&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Allowed Languages==&lt;br /&gt;
&lt;br /&gt;
WIP&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Tag !! Language !! Flag&lt;br /&gt;
|-&lt;br /&gt;
| '''en''' || English || 🇺🇸&lt;br /&gt;
|-&lt;br /&gt;
| '''pt-pt''' || European Portuguese || 🇵🇹&lt;br /&gt;
|-&lt;br /&gt;
| '''pt-br''' || Brazilian Portuguese || 🇧🇷&lt;br /&gt;
|-&lt;br /&gt;
| '''es''' || Spanish || 🇪🇸&lt;br /&gt;
|-&lt;br /&gt;
| '''fr''' || French || 🇫🇷&lt;br /&gt;
|-&lt;br /&gt;
| '''de''' || German || 🇩🇪&lt;br /&gt;
|-&lt;br /&gt;
| '''it''' || Italian || 🇮🇹&lt;br /&gt;
|-&lt;br /&gt;
| '''ru''' || Russian || 🇷🇺&lt;br /&gt;
|-&lt;br /&gt;
| '''zh''' || Chinese (Simplified) || 🇨🇳&lt;br /&gt;
|-&lt;br /&gt;
| '''zh-tw''' || Chinese (Traditional, Taiwan) || 🇹🇼&lt;br /&gt;
|-&lt;br /&gt;
| '''ja''' || Japanese || 🇯🇵&lt;br /&gt;
|-&lt;br /&gt;
| '''ko''' || Korean || 🇰🇷&lt;br /&gt;
|-&lt;br /&gt;
| '''ar''' || Arabic || 🇸🇦&lt;br /&gt;
|-&lt;br /&gt;
| '''hi''' || Hindi || 🇮🇳&lt;br /&gt;
|-&lt;br /&gt;
| '''bn''' || Bengali || 🇧🇩&lt;br /&gt;
|-&lt;br /&gt;
| '''tr''' || Turkish || 🇹🇷&lt;br /&gt;
|-&lt;br /&gt;
| '''nl''' || Dutch || 🇳🇱&lt;br /&gt;
|-&lt;br /&gt;
| '''sv''' || Swedish || 🇸🇪&lt;br /&gt;
|-&lt;br /&gt;
| '''no''' || Norwegian || 🇳🇴&lt;br /&gt;
|-&lt;br /&gt;
| '''da''' || Danish || 🇩🇰&lt;br /&gt;
|-&lt;br /&gt;
| '''fi''' || Finnish || 🇫🇮&lt;br /&gt;
|-&lt;br /&gt;
| '''pl''' || Polish || 🇵🇱&lt;br /&gt;
|-&lt;br /&gt;
| '''sk''' || Slovak || 🇸🇰&lt;br /&gt;
|-&lt;br /&gt;
| '''cs''' || Czech || 🇨🇿&lt;br /&gt;
|-&lt;br /&gt;
| '''hu''' || Hungarian || 🇭🇺&lt;br /&gt;
|-&lt;br /&gt;
| '''ro''' || Romanian || 🇷🇴&lt;br /&gt;
|-&lt;br /&gt;
| '''el''' || Greek || 🇬🇷&lt;br /&gt;
|-&lt;br /&gt;
| '''he''' || Hebrew || 🇮🇱&lt;br /&gt;
|-&lt;br /&gt;
| '''vi''' || Vietnamese || 🇻🇳&lt;br /&gt;
|-&lt;br /&gt;
| '''th''' || Thai || 🇹🇭&lt;br /&gt;
|-&lt;br /&gt;
| '''id''' || Indonesian || 🇮🇩&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Allowed Tags====&lt;br /&gt;
&lt;br /&gt;
WIP&lt;br /&gt;
&lt;br /&gt;
==Useful Information==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://github.com/multitheftauto/mtasa-blue/pull/3761 github.com/multitheftauto/mtasa-blue: PR #3761]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://en.wikipedia.org/wiki/The_All-Seeing_Eye wikipedia.org: The All-Seeing Eye]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://int64.org/docs/gamestat-protocols/ase.html int64.org: All-Seeing Eye Protocol]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Yeleha</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedAnimation&amp;diff=79882</id>
		<title>SetPedAnimation</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedAnimation&amp;diff=79882"/>
		<updated>2024-07-14T06:07:58Z</updated>

		<summary type="html">&lt;p&gt;Yeleha: Issue fixed, removed from table.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server client function}}&lt;br /&gt;
&lt;br /&gt;
Sets the current [[Animations|animation]] of a [[player]] or [[ped]]. Not specifying the type of animation will automatically cancel the current one.&lt;br /&gt;
{{Warning|It is possible that an animation will be cancelled if you use setElementFrozen on the ped, but this does not happen all the time.}}&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 setPedAnimation ( ped thePed [, string block = nil, string anim = nil, int time = -1, bool loop = true, bool updatePosition = true,&lt;br /&gt;
                       bool interruptable = true, bool freezeLastFrame = true, int blendTime = 250, bool retainPedState = false ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[ped]]:setAnimation||getPedAnimation}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed:''' the [[player]] or [[ped]] you want to apply an [[Animations|animation]] to.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''block:''' the [[Animations|animation]] block's name.&lt;br /&gt;
*'''anim:''' the name of the [[Animations|animation]] within the block.&lt;br /&gt;
*'''time:''' how long the animation will run for in milliseconds.&lt;br /&gt;
*'''loop:''' indicates whether or not the animation will loop.&lt;br /&gt;
*'''updatePosition:''' will change the actual coordinates of the ped according to the animation. Use this for e.g. walking animations.&lt;br /&gt;
*'''interruptable:''' if set to ''false'' other tasks wont be able to interupt the animation. Setting this to 'false' also gives this function more power to override other animations that are running. For example, squatting after a jump can be terminated.&lt;br /&gt;
*'''freezeLastFrame:''' if set to ''true'' after animation the last frame will be frozen, otherwise the animation will end and controls will return.&lt;br /&gt;
*'''blendTime:''' how long the animation will mixed with the previous one in milliseconds.&lt;br /&gt;
{{New items|3.0157|1.5.7|&lt;br /&gt;
*'''retainPedState:''' will restore the task which was playing before calling this function. Useful for restoring the crouch task after animation ends. This may be extended in the future to support other states/tasks.&lt;br /&gt;
|16632}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if succesful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Examples==&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 example creates a ped, rotates him, and makes him walk:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function makePed()&lt;br /&gt;
	local thePed = createPed(56, 1, 1, 4, 315)&lt;br /&gt;
	setPedAnimation(thePed, &amp;quot;ped&amp;quot;, &amp;quot;WOMAN_walknorm&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;makemyped&amp;quot;, makePed)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example makes the player sit down and stand up using the command /sit.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local playerSitState = {}&lt;br /&gt;
&lt;br /&gt;
function toggleSit(thePlayer)&lt;br /&gt;
	local playerSitting = playerSitState[thePlayer]&lt;br /&gt;
&lt;br /&gt;
	if (not playerSitting) then&lt;br /&gt;
		setPedAnimation(thePlayer, &amp;quot;ped&amp;quot;, &amp;quot;seat_down&amp;quot;, -1, false, false, false, false)&lt;br /&gt;
		playerSitState[thePlayer] = true -- store the player state in the table&lt;br /&gt;
&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	setPedAnimation(thePlayer) -- if you use again this command then your character stand up&lt;br /&gt;
	playerSitState[thePlayer] = nil -- remove player sit state from table&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;sit&amp;quot;, toggleSit)&lt;br /&gt;
&lt;br /&gt;
function onPlayerQuitClearSitState()&lt;br /&gt;
	playerSitState[source] = nil -- clear state at player quit, to prevent memory leak&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerQuit&amp;quot;, root, onPlayerQuitClearSitState)&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.5.7-9.16632|Added retainPedState argument}}&lt;br /&gt;
&lt;br /&gt;
==Issues==&lt;br /&gt;
{{Issues|&lt;br /&gt;
{{Issue|1110|retainPedState in setPedAnimation() does not work when latency reduction is set to 1}}&lt;br /&gt;
{{Issue|953|setPedAnimation() &amp;quot;interrupt&amp;quot; and &amp;quot;time&amp;quot; has no effect in certain situations}}&lt;br /&gt;
{{Issue|467|Ped animations don't sync for new players}}&lt;br /&gt;
{{Issue|463|setPedAnimation() does not work when a ped is attached and floating in air}}&lt;br /&gt;
{{Issue|1173|setPedAnimation() removes player jetpack}}&lt;br /&gt;
{{Issue|884|setPedAnimation() messes up collisions of peds inside vehicles}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Ped_functions}}&lt;br /&gt;
[[ru:setPedAnimation]]&lt;br /&gt;
[[HU:setPedAnimation]]&lt;/div&gt;</summary>
		<author><name>Yeleha</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=ToJSON&amp;diff=79847</id>
		<title>ToJSON</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ToJSON&amp;diff=79847"/>
		<updated>2024-07-12T09:29:07Z</updated>

		<summary type="html">&lt;p&gt;Yeleha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function converts a '''single''' value (preferably a Lua table) into a [[JSON]] encoded string. You can use this to store the data and then load it again using [[fromJSON]].&lt;br /&gt;
&lt;br /&gt;
{{Important Note|Due to technical limitations (partly of json-c) the stringified keys will be truncated to the first 255 characters}}&lt;br /&gt;
{{ Warning| When using [[toJSON]] for submitting data using [[fetchRemote]] for example, make sure to use '''string.sub(data, 2, -2)''' to remove the brackets as many APIs will not understand the request }}&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;
string toJSON ( var value [, bool compact = false ][, string prettyType = &amp;quot;none&amp;quot; ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''var:''' An argument of any type. Arguments that are elements will be stored as element IDs that are liable to change between sessions. As such, do not save elements across sessions as you will get unpredictable results.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
{{New feature/item|3.0150|1.5||&lt;br /&gt;
*'''compact:''' a [[boolean]] representing whether the string will contain whitespaces. To remove whitespaces from JSON string, use ''true''. String will contain whitespaces per default.&lt;br /&gt;
}}&lt;br /&gt;
{{New feature/item|3.0154|1.5.3|8046|&lt;br /&gt;
*'''prettyType:''' a type [[string]] from below:&lt;br /&gt;
** none&lt;br /&gt;
** spaces&lt;br /&gt;
** tabs&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a JSON formatted string.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example shows how you can encode an array. The string json should equal ''&amp;quot;[ { &amp;quot;1&amp;quot;: &amp;quot;dogs&amp;quot;, &amp;quot;mouse&amp;quot;: &amp;quot;food&amp;quot;, &amp;quot;cat&amp;quot;: &amp;quot;hungry&amp;quot;, &amp;quot;birds&amp;quot;: 4 } ]&amp;quot; after executed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local json = toJSON ( { &amp;quot;dogs&amp;quot;, cat = &amp;quot;hungry&amp;quot;, mouse = &amp;quot;food&amp;quot;, birds = 4 } )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.0|1.1.1-9.03316|}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Server_functions}}&lt;br /&gt;
&lt;br /&gt;
[[ru:toJSON]]&lt;/div&gt;</summary>
		<author><name>Yeleha</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=FetchRemote&amp;diff=79846</id>
		<title>FetchRemote</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=FetchRemote&amp;diff=79846"/>
		<updated>2024-07-12T09:28:46Z</updated>

		<summary type="html">&lt;p&gt;Yeleha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function allows you to post and receive data from HTTP servers. The calls are asynchronous so you do not get an immediate result from the call, instead a callback function you specify is called when the download completes.&lt;br /&gt;
&lt;br /&gt;
In the case when the call fails, a string containing &amp;quot;ERROR&amp;quot; followed by an integer containing the error reason will be passed to the callback function. The reason for failure will be similar to errors found with websites - file not found, server not found and timeouts.&lt;br /&gt;
&lt;br /&gt;
If you are using fetchRemote to connect to a PHP script, you can use '''file_get_contents('php://input')''' to read the '''postData''' sent from this function.&lt;br /&gt;
{{Note|Client side function only works with the server the player is connected to unless the domain has been accepted with [[requestBrowserDomains]]}}&lt;br /&gt;
{{ Warning| function won't trigger inside another fetchRemote function }}&lt;br /&gt;
{{ Warning| When using [[toJSON]] for submitting data, make sure to use '''string.sub(data, 2, -2)''' to remove the brackets as many APIs will not understand the request  }}&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool fetchRemote ( string URL, [ string queueName = &amp;quot;default&amp;quot; ], [ int connectionAttempts = 10, int connectTimeout = 10000 ], function callbackFunction, [ string postData = &amp;quot;&amp;quot;,  bool postIsBinary = false ], [ arguments... ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''URL:''' A full URL in the format ''&amp;lt;nowiki&amp;gt;http://hostname/path/file.ext&amp;lt;/nowiki&amp;gt;''. A port can be specified with a colon followed by a port number appended to the hostname.&lt;br /&gt;
*'''callbackFunction:''' This is the function that should receive the data returned from the remote server. The callback argument list should be:&lt;br /&gt;
**'''''responseData''''' - A string containing the remote response or &amp;quot;ERROR&amp;quot; if there was a problem&lt;br /&gt;
**'''''error''''' - A number containing the error number or zero if there was no error. A list of possible error values are:&lt;br /&gt;
{{Error_codes_for_callRemote_and_fetchRemote}}&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding-left:19px;&amp;quot;&amp;gt;&lt;br /&gt;
*'''''arguments...''''' - The arguments that were passed into fetchRemote&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{New items|4.0153|1.5.3-9.11270|&lt;br /&gt;
*'''queueName:''' Name of the queue to use. Any name can be used. If not set, the queue name is &amp;quot;default&amp;quot;. Requests in the same queue are processed in order, one at a time.&lt;br /&gt;
}}&lt;br /&gt;
*'''connectionAttempts:''' Number of times to retry if the remote host does not respond. ''In the case of a non-responding remote server, each connection attempt will timeout after 10 seconds. Therefore, the default setting of 10 connection attempts means it will be 100 seconds before your script gets a callback about the error. Reducing this value to 2 for example, will decrease that period to 20 seconds''&lt;br /&gt;
*'''connectTimeout:''' Number of milliseconds each connection attempt will take before timing out&lt;br /&gt;
*'''postData:''' A string specifying any data you want to send to the remote HTTP server.&lt;br /&gt;
*'''postIsBinary :''' A boolean specifying if the data is text, or binary.&lt;br /&gt;
*'''arguments:''' Any arguments you may want to pass to the callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{New items|5.0154|1.5.4-9.11342|&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool fetchRemote ( string URL[, table options ], callback callbackFunction[, table callbackArguments ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''URL:''' A full URL in the format ''&amp;lt;nowiki&amp;gt;http://hostname/path/file.ext&amp;lt;/nowiki&amp;gt;''. A port can be specified with a colon followed by a port number appended to the hostname.&lt;br /&gt;
*'''callbackFunction:''' This is the function that should receive the data returned from the remote server. The callback argument list should be:&lt;br /&gt;
**'''''responseData''''' - A string containing the remote response&lt;br /&gt;
**'''''responseInfo''''' - A table containing:&lt;br /&gt;
***'''''success''''' - A boolean indicating if the request was successful.&lt;br /&gt;
***'''''statusCode''''' - An integer status/error code&lt;br /&gt;
***'''''headers''''' - A table containing the HTTP response headers&lt;br /&gt;
**'''''arguments...''''' - The arguments that were passed into fetchRemote&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''options:''' A table containing any request options:&lt;br /&gt;
**'''queueName:''' Name of the queue to use. Any name can be used. If not set, the queue name is &amp;quot;default&amp;quot;. Requests in the same queue are processed in order, one at a time.&lt;br /&gt;
**'''connectionAttempts:''' Number of times to retry if the remote host does not respond. ''(Defaults to 10)''&lt;br /&gt;
**'''connectTimeout:''' Number of milliseconds each connection attempt will take before timing out. ''(Defaults to 10000)''&lt;br /&gt;
**'''postData:''' A string specifying any data you want to send to the remote HTTP server.&lt;br /&gt;
**'''postIsBinary :''' A boolean specifying if the data is text, or binary. ''(Defaults to false)''&lt;br /&gt;
**'''method:''' A string specifying the request method. ''(Defaults to GET or POST)''&lt;br /&gt;
**'''headers:''' A table containing HTTP request headers. ''e.g.{ Pragma&amp;amp;#61;&amp;quot;no-cache&amp;quot; }''&lt;br /&gt;
**'''maxRedirects:''' An integer limiting the number of HTTP redirections to automatically follow. ''(Defaults to 8)''&lt;br /&gt;
**'''username:''' A string specifying the username for protected pages.&lt;br /&gt;
**'''password:''' A string specifying the password for protected pages.&lt;br /&gt;
{{New items|5.0154|1.5.4-9.11413|&lt;br /&gt;
**'''formFields:''' A table containing form items to submit. (for POST method only)  ''e.g.{ name&amp;amp;#61;&amp;quot;bob&amp;quot;, email&amp;amp;#61;&amp;quot;bob@example.com&amp;quot; }''&lt;br /&gt;
}}&lt;br /&gt;
*'''arguments:''' A table containing arguments you may want to pass to the callback.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
{{New items|5.0154|1.5.7-9.20307|&lt;br /&gt;
Returns a '''''request''''' value which can be used with [[GetRemoteRequestInfo|getRemoteRequestInfo]] or [[AbortRemoteRequest|abortRemoteRequest]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example shows you how you can fetch an image from a web page, and transfer it to a particular client:&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;
&lt;br /&gt;
function startImageDownload( playerToReceive )&lt;br /&gt;
    fetchRemote ( &amp;quot;http://www.example.com/image.jpg&amp;quot;, myCallback, &amp;quot;&amp;quot;, false, playerToReceive )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function myCallback( responseData, errorCode, playerToReceive )&lt;br /&gt;
    if errorCode == 0 then&lt;br /&gt;
        triggerClientEvent( playerToReceive, &amp;quot;onClientGotImage&amp;quot;, resourceRoot, responseData )&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;
&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;
addEvent( &amp;quot;onClientGotImage&amp;quot;, true )&lt;br /&gt;
addEventHandler( &amp;quot;onClientGotImage&amp;quot;, resourceRoot,&lt;br /&gt;
    function( pixels )&lt;br /&gt;
        if myTexture then&lt;br /&gt;
            destroyElement( myTexture )&lt;br /&gt;
        end&lt;br /&gt;
        myTexture = dxCreateTexture( pixels )&lt;br /&gt;
    end&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, root,&lt;br /&gt;
    function()&lt;br /&gt;
        if myTexture then&lt;br /&gt;
            local w,h = dxGetMaterialSize( myTexture )&lt;br /&gt;
            dxDrawImage( 200, 100, w, h, myTexture )&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{{New items|5.0154|1.5.4-9.11413|&lt;br /&gt;
Example sending email via a web service (adopted from examples on https://documentation.mailgun.com/en/latest/user_manual.html)&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;
sendOptions = {&lt;br /&gt;
    queueName = &amp;quot;My Mailgun queue&amp;quot;,&lt;br /&gt;
    connectionAttempts = 3,&lt;br /&gt;
    connectTimeout = 5000,&lt;br /&gt;
    formFields = {&lt;br /&gt;
        from=&amp;quot;Excited User &amp;lt;excited@samples.mailgun.org&amp;gt;&amp;quot;,&lt;br /&gt;
        to=&amp;quot;devs@mailgun.net&amp;quot;,&lt;br /&gt;
        subject=&amp;quot;Hello&amp;quot;,&lt;br /&gt;
        text=&amp;quot;Testing some Mailgun awesomness!&amp;quot;,&lt;br /&gt;
    },&lt;br /&gt;
    username=&amp;quot;api&amp;quot;,&lt;br /&gt;
    password=&amp;quot;key-3ax6xnjp29jd6fds4gc373sgvjxteol0&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
fetchRemote( &amp;quot;https://api.mailgun.net/v3/samples.mailgun.org/messages&amp;quot;, sendOptions, mailgunCompleteCallback )&lt;br /&gt;
&lt;br /&gt;
function mailgunCompleteCallback(data, info)&lt;br /&gt;
    outputDebugString( &amp;quot;mailgunComplete&amp;quot;&lt;br /&gt;
            .. &amp;quot; success:&amp;quot; .. tostring(info.success)&lt;br /&gt;
            .. &amp;quot; statusCode:&amp;quot; .. tostring(info.statusCode)&lt;br /&gt;
            .. &amp;quot; data:&amp;quot; .. tostring(data)&lt;br /&gt;
            )&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;
Changing post content on IPS forum.&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local apiKey = &amp;quot;12345678123456781234567812345678&amp;quot; -- key from ips admin panel&lt;br /&gt;
local forumAddress = &amp;quot;https://yourForum.com&amp;quot;&lt;br /&gt;
function setPostContent(postID,content)&lt;br /&gt;
  local sendOptions = {&lt;br /&gt;
    queueName = &amp;quot;updatePost&amp;quot;,&lt;br /&gt;
    connectionAttempts = 1,&lt;br /&gt;
    connectTimeout = 50,&lt;br /&gt;
    formFields = {&lt;br /&gt;
      post = content,&lt;br /&gt;
    },&lt;br /&gt;
  }&lt;br /&gt;
  fetchRemote( forumAddress..&amp;quot;/api/forums/posts/&amp;quot;..postID..&amp;quot;?key=&amp;quot;..apiKey, sendOptions, function()end)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
setPostContent(1, &amp;quot;this is a first post on this forum&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.3.0-9.03739|1.3.2|}}&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.3.1-9.04605|Added connectionAttempts argument}}&lt;br /&gt;
{{ChangelogItem|1.3.2|Added client side}}&lt;br /&gt;
{{ChangelogItem|1.5.3-9.11270|Added queueName argument}}&lt;br /&gt;
{{ChangelogItem|1.5.4-9.11342|Added alternative syntax}}&lt;br /&gt;
{{ChangelogItem|1.5.4-9.11413|Added formFields}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Resource_functions}}&lt;/div&gt;</summary>
		<author><name>Yeleha</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=FetchRemote&amp;diff=79845</id>
		<title>FetchRemote</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=FetchRemote&amp;diff=79845"/>
		<updated>2024-07-12T09:28:18Z</updated>

		<summary type="html">&lt;p&gt;Yeleha: Warning for using toJSON in requests.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function allows you to post and receive data from HTTP servers. The calls are asynchronous so you do not get an immediate result from the call, instead a callback function you specify is called when the download completes.&lt;br /&gt;
&lt;br /&gt;
In the case when the call fails, a string containing &amp;quot;ERROR&amp;quot; followed by an integer containing the error reason will be passed to the callback function. The reason for failure will be similar to errors found with websites - file not found, server not found and timeouts.&lt;br /&gt;
&lt;br /&gt;
If you are using fetchRemote to connect to a PHP script, you can use '''file_get_contents('php://input')''' to read the '''postData''' sent from this function.&lt;br /&gt;
{{Note|Client side function only works with the server the player is connected to unless the domain has been accepted with [[requestBrowserDomains]]}}&lt;br /&gt;
{{ Warning| function won't trigger inside another fetchRemote function }}&lt;br /&gt;
{{ Warning| When using [[toJSON]] for submitting data, make sure to use string.sub(data, 2, -2) to remove the brackets as many APIs will not understand the request  }}&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool fetchRemote ( string URL, [ string queueName = &amp;quot;default&amp;quot; ], [ int connectionAttempts = 10, int connectTimeout = 10000 ], function callbackFunction, [ string postData = &amp;quot;&amp;quot;,  bool postIsBinary = false ], [ arguments... ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''URL:''' A full URL in the format ''&amp;lt;nowiki&amp;gt;http://hostname/path/file.ext&amp;lt;/nowiki&amp;gt;''. A port can be specified with a colon followed by a port number appended to the hostname.&lt;br /&gt;
*'''callbackFunction:''' This is the function that should receive the data returned from the remote server. The callback argument list should be:&lt;br /&gt;
**'''''responseData''''' - A string containing the remote response or &amp;quot;ERROR&amp;quot; if there was a problem&lt;br /&gt;
**'''''error''''' - A number containing the error number or zero if there was no error. A list of possible error values are:&lt;br /&gt;
{{Error_codes_for_callRemote_and_fetchRemote}}&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding-left:19px;&amp;quot;&amp;gt;&lt;br /&gt;
*'''''arguments...''''' - The arguments that were passed into fetchRemote&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{New items|4.0153|1.5.3-9.11270|&lt;br /&gt;
*'''queueName:''' Name of the queue to use. Any name can be used. If not set, the queue name is &amp;quot;default&amp;quot;. Requests in the same queue are processed in order, one at a time.&lt;br /&gt;
}}&lt;br /&gt;
*'''connectionAttempts:''' Number of times to retry if the remote host does not respond. ''In the case of a non-responding remote server, each connection attempt will timeout after 10 seconds. Therefore, the default setting of 10 connection attempts means it will be 100 seconds before your script gets a callback about the error. Reducing this value to 2 for example, will decrease that period to 20 seconds''&lt;br /&gt;
*'''connectTimeout:''' Number of milliseconds each connection attempt will take before timing out&lt;br /&gt;
*'''postData:''' A string specifying any data you want to send to the remote HTTP server.&lt;br /&gt;
*'''postIsBinary :''' A boolean specifying if the data is text, or binary.&lt;br /&gt;
*'''arguments:''' Any arguments you may want to pass to the callback.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{New items|5.0154|1.5.4-9.11342|&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool fetchRemote ( string URL[, table options ], callback callbackFunction[, table callbackArguments ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''URL:''' A full URL in the format ''&amp;lt;nowiki&amp;gt;http://hostname/path/file.ext&amp;lt;/nowiki&amp;gt;''. A port can be specified with a colon followed by a port number appended to the hostname.&lt;br /&gt;
*'''callbackFunction:''' This is the function that should receive the data returned from the remote server. The callback argument list should be:&lt;br /&gt;
**'''''responseData''''' - A string containing the remote response&lt;br /&gt;
**'''''responseInfo''''' - A table containing:&lt;br /&gt;
***'''''success''''' - A boolean indicating if the request was successful.&lt;br /&gt;
***'''''statusCode''''' - An integer status/error code&lt;br /&gt;
***'''''headers''''' - A table containing the HTTP response headers&lt;br /&gt;
**'''''arguments...''''' - The arguments that were passed into fetchRemote&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''options:''' A table containing any request options:&lt;br /&gt;
**'''queueName:''' Name of the queue to use. Any name can be used. If not set, the queue name is &amp;quot;default&amp;quot;. Requests in the same queue are processed in order, one at a time.&lt;br /&gt;
**'''connectionAttempts:''' Number of times to retry if the remote host does not respond. ''(Defaults to 10)''&lt;br /&gt;
**'''connectTimeout:''' Number of milliseconds each connection attempt will take before timing out. ''(Defaults to 10000)''&lt;br /&gt;
**'''postData:''' A string specifying any data you want to send to the remote HTTP server.&lt;br /&gt;
**'''postIsBinary :''' A boolean specifying if the data is text, or binary. ''(Defaults to false)''&lt;br /&gt;
**'''method:''' A string specifying the request method. ''(Defaults to GET or POST)''&lt;br /&gt;
**'''headers:''' A table containing HTTP request headers. ''e.g.{ Pragma&amp;amp;#61;&amp;quot;no-cache&amp;quot; }''&lt;br /&gt;
**'''maxRedirects:''' An integer limiting the number of HTTP redirections to automatically follow. ''(Defaults to 8)''&lt;br /&gt;
**'''username:''' A string specifying the username for protected pages.&lt;br /&gt;
**'''password:''' A string specifying the password for protected pages.&lt;br /&gt;
{{New items|5.0154|1.5.4-9.11413|&lt;br /&gt;
**'''formFields:''' A table containing form items to submit. (for POST method only)  ''e.g.{ name&amp;amp;#61;&amp;quot;bob&amp;quot;, email&amp;amp;#61;&amp;quot;bob@example.com&amp;quot; }''&lt;br /&gt;
}}&lt;br /&gt;
*'''arguments:''' A table containing arguments you may want to pass to the callback.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
{{New items|5.0154|1.5.7-9.20307|&lt;br /&gt;
Returns a '''''request''''' value which can be used with [[GetRemoteRequestInfo|getRemoteRequestInfo]] or [[AbortRemoteRequest|abortRemoteRequest]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example shows you how you can fetch an image from a web page, and transfer it to a particular client:&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;
&lt;br /&gt;
function startImageDownload( playerToReceive )&lt;br /&gt;
    fetchRemote ( &amp;quot;http://www.example.com/image.jpg&amp;quot;, myCallback, &amp;quot;&amp;quot;, false, playerToReceive )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function myCallback( responseData, errorCode, playerToReceive )&lt;br /&gt;
    if errorCode == 0 then&lt;br /&gt;
        triggerClientEvent( playerToReceive, &amp;quot;onClientGotImage&amp;quot;, resourceRoot, responseData )&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;
&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;
addEvent( &amp;quot;onClientGotImage&amp;quot;, true )&lt;br /&gt;
addEventHandler( &amp;quot;onClientGotImage&amp;quot;, resourceRoot,&lt;br /&gt;
    function( pixels )&lt;br /&gt;
        if myTexture then&lt;br /&gt;
            destroyElement( myTexture )&lt;br /&gt;
        end&lt;br /&gt;
        myTexture = dxCreateTexture( pixels )&lt;br /&gt;
    end&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, root,&lt;br /&gt;
    function()&lt;br /&gt;
        if myTexture then&lt;br /&gt;
            local w,h = dxGetMaterialSize( myTexture )&lt;br /&gt;
            dxDrawImage( 200, 100, w, h, myTexture )&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{{New items|5.0154|1.5.4-9.11413|&lt;br /&gt;
Example sending email via a web service (adopted from examples on https://documentation.mailgun.com/en/latest/user_manual.html)&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;
sendOptions = {&lt;br /&gt;
    queueName = &amp;quot;My Mailgun queue&amp;quot;,&lt;br /&gt;
    connectionAttempts = 3,&lt;br /&gt;
    connectTimeout = 5000,&lt;br /&gt;
    formFields = {&lt;br /&gt;
        from=&amp;quot;Excited User &amp;lt;excited@samples.mailgun.org&amp;gt;&amp;quot;,&lt;br /&gt;
        to=&amp;quot;devs@mailgun.net&amp;quot;,&lt;br /&gt;
        subject=&amp;quot;Hello&amp;quot;,&lt;br /&gt;
        text=&amp;quot;Testing some Mailgun awesomness!&amp;quot;,&lt;br /&gt;
    },&lt;br /&gt;
    username=&amp;quot;api&amp;quot;,&lt;br /&gt;
    password=&amp;quot;key-3ax6xnjp29jd6fds4gc373sgvjxteol0&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
fetchRemote( &amp;quot;https://api.mailgun.net/v3/samples.mailgun.org/messages&amp;quot;, sendOptions, mailgunCompleteCallback )&lt;br /&gt;
&lt;br /&gt;
function mailgunCompleteCallback(data, info)&lt;br /&gt;
    outputDebugString( &amp;quot;mailgunComplete&amp;quot;&lt;br /&gt;
            .. &amp;quot; success:&amp;quot; .. tostring(info.success)&lt;br /&gt;
            .. &amp;quot; statusCode:&amp;quot; .. tostring(info.statusCode)&lt;br /&gt;
            .. &amp;quot; data:&amp;quot; .. tostring(data)&lt;br /&gt;
            )&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;
Changing post content on IPS forum.&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local apiKey = &amp;quot;12345678123456781234567812345678&amp;quot; -- key from ips admin panel&lt;br /&gt;
local forumAddress = &amp;quot;https://yourForum.com&amp;quot;&lt;br /&gt;
function setPostContent(postID,content)&lt;br /&gt;
  local sendOptions = {&lt;br /&gt;
    queueName = &amp;quot;updatePost&amp;quot;,&lt;br /&gt;
    connectionAttempts = 1,&lt;br /&gt;
    connectTimeout = 50,&lt;br /&gt;
    formFields = {&lt;br /&gt;
      post = content,&lt;br /&gt;
    },&lt;br /&gt;
  }&lt;br /&gt;
  fetchRemote( forumAddress..&amp;quot;/api/forums/posts/&amp;quot;..postID..&amp;quot;?key=&amp;quot;..apiKey, sendOptions, function()end)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
setPostContent(1, &amp;quot;this is a first post on this forum&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.3.0-9.03739|1.3.2|}}&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.3.1-9.04605|Added connectionAttempts argument}}&lt;br /&gt;
{{ChangelogItem|1.3.2|Added client side}}&lt;br /&gt;
{{ChangelogItem|1.5.3-9.11270|Added queueName argument}}&lt;br /&gt;
{{ChangelogItem|1.5.4-9.11342|Added alternative syntax}}&lt;br /&gt;
{{ChangelogItem|1.5.4-9.11413|Added formFields}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Resource_functions}}&lt;/div&gt;</summary>
		<author><name>Yeleha</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=ToJSON&amp;diff=79844</id>
		<title>ToJSON</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ToJSON&amp;diff=79844"/>
		<updated>2024-07-12T08:45:09Z</updated>

		<summary type="html">&lt;p&gt;Yeleha: Warning for using toJSON in requests.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Server client function}}&lt;br /&gt;
This function converts a '''single''' value (preferably a Lua table) into a [[JSON]] encoded string. You can use this to store the data and then load it again using [[fromJSON]].&lt;br /&gt;
&lt;br /&gt;
{{Important Note|Due to technical limitations (partly of json-c) the stringified keys will be truncated to the first 255 characters}}&lt;br /&gt;
{{ Warning| When using [[toJSON]] for submitting data using [[fetchRemote]] for example, make sure to use string.sub(data, 2, -2) to remove the brackets as many APIs will not understand the request }}&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;
string toJSON ( var value [, bool compact = false ][, string prettyType = &amp;quot;none&amp;quot; ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''var:''' An argument of any type. Arguments that are elements will be stored as element IDs that are liable to change between sessions. As such, do not save elements across sessions as you will get unpredictable results.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
{{New feature/item|3.0150|1.5||&lt;br /&gt;
*'''compact:''' a [[boolean]] representing whether the string will contain whitespaces. To remove whitespaces from JSON string, use ''true''. String will contain whitespaces per default.&lt;br /&gt;
}}&lt;br /&gt;
{{New feature/item|3.0154|1.5.3|8046|&lt;br /&gt;
*'''prettyType:''' a type [[string]] from below:&lt;br /&gt;
** none&lt;br /&gt;
** spaces&lt;br /&gt;
** tabs&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a JSON formatted string.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example shows how you can encode an array. The string json should equal ''&amp;quot;[ { &amp;quot;1&amp;quot;: &amp;quot;dogs&amp;quot;, &amp;quot;mouse&amp;quot;: &amp;quot;food&amp;quot;, &amp;quot;cat&amp;quot;: &amp;quot;hungry&amp;quot;, &amp;quot;birds&amp;quot;: 4 } ]&amp;quot; after executed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local json = toJSON ( { &amp;quot;dogs&amp;quot;, cat = &amp;quot;hungry&amp;quot;, mouse = &amp;quot;food&amp;quot;, birds = 4 } )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.0|1.1.1-9.03316|}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Server_functions}}&lt;br /&gt;
&lt;br /&gt;
[[ru:toJSON]]&lt;/div&gt;</summary>
		<author><name>Yeleha</name></author>
	</entry>
</feed>