<?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=Ares+Mta</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=Ares+Mta"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Ares_Mta"/>
	<updated>2026-05-02T10:50:02Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CountPlayersInRange&amp;diff=43253</id>
		<title>CountPlayersInRange</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CountPlayersInRange&amp;diff=43253"/>
		<updated>2014-12-11T04:05:00Z</updated>

		<summary type="html">&lt;p&gt;Ares Mta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function allows you to set '''moving''' element speed in kph or mph units.&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setElementSpeed (element theElement, [ int/string unit=&amp;quot;kph&amp;quot;, int speed=0 ])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theElement''': Element you want to set speed of&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
* '''unit''': Units in which speed should be set. This can be 1 or &amp;quot;mph&amp;quot; for mph, any other value for kph.&lt;br /&gt;
* '''speed''': Speed in selected unit&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
{{RequiredFunctions|getElementSpeed}}&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function setElementSpeed(element, unit, speed)&lt;br /&gt;
	if (unit == nil) then unit = 0 end&lt;br /&gt;
	if (speed == nil) then speed = 0 end&lt;br /&gt;
	speed = tonumber(speed)&lt;br /&gt;
	local acSpeed = getElementSpeed(element, unit)&lt;br /&gt;
	if (acSpeed~=false) then -- if true - element is valid, no need to check again&lt;br /&gt;
		local diff = speed/acSpeed&lt;br /&gt;
		if diff ~= diff then return end -- if the number is a 'NaN' return end.&lt;br /&gt;
		local x,y,z = getElementVelocity(element)&lt;br /&gt;
		setElementVelocity(element,x*diff,y*diff,z*diff)&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server-side example&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example adds command that set player vehicle speed to provided one (in predefined unit kph). Note: It doesn't care if player is driver or passenger.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;setmyspeed&amp;quot;,&lt;br /&gt;
function (player, cmd, arg1)&lt;br /&gt;
  local veh = getPedOccupiedVehicle(player)&lt;br /&gt;
  if (veh) then&lt;br /&gt;
    setElementSpeed(veh, &amp;quot;kph&amp;quot;, tonumber(arg1))&lt;br /&gt;
  else&lt;br /&gt;
    outputChatBox(&amp;quot;You have to sit in vehicle&amp;quot;, player)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By '''varez'''.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Ares Mta</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=CountPlayersInRange&amp;diff=43252</id>
		<title>CountPlayersInRange</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=CountPlayersInRange&amp;diff=43252"/>
		<updated>2014-12-11T04:04:15Z</updated>

		<summary type="html">&lt;p&gt;Ares Mta: Fixed the &amp;quot;NaN&amp;quot; debug&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function allows you to set '''moving''' element speed in kph or mph units.&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool setElementSpeed (element theElement, [ int/string unit=&amp;quot;kph&amp;quot;, int speed=0 ])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theElement''': Element you want to set speed of&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
* '''unit''': Units in which speed should be set. This can be 1 or &amp;quot;mph&amp;quot; for mph, any other value for kph.&lt;br /&gt;
* '''speed''': Speed in selected unit&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
{{RequiredFunctions|getElementSpeed}}&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function setElementSpeed(element, unit, speed) -- only work if element is moving!&lt;br /&gt;
	if (unit == nil) then unit = 0 end&lt;br /&gt;
	if (speed == nil) then speed = 0 end&lt;br /&gt;
	speed = tonumber(speed)&lt;br /&gt;
	local acSpeed = getElementSpeed(element, unit)&lt;br /&gt;
	if (acSpeed~=false) then -- if true - element is valid, no need to check again&lt;br /&gt;
		local diff = speed/acSpeed&lt;br /&gt;
		if diff ~= diff then return end -- if the number is a 'NaN' return end.&lt;br /&gt;
		local x,y,z = getElementVelocity(element)&lt;br /&gt;
		setElementVelocity(element,x*diff,y*diff,z*diff)&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server-side example&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example adds command that set player vehicle speed to provided one (in predefined unit kph). Note: It doesn't care if player is driver or passenger.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;setmyspeed&amp;quot;,&lt;br /&gt;
function (player, cmd, arg1)&lt;br /&gt;
  local veh = getPedOccupiedVehicle(player)&lt;br /&gt;
  if (veh) then&lt;br /&gt;
    setElementSpeed(veh, &amp;quot;kph&amp;quot;, tonumber(arg1))&lt;br /&gt;
  else&lt;br /&gt;
    outputChatBox(&amp;quot;You have to sit in vehicle&amp;quot;, player)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By '''varez'''.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Ares Mta</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=FetchRemote&amp;diff=42749</id>
		<title>FetchRemote</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=FetchRemote&amp;diff=42749"/>
		<updated>2014-10-30T00:23:53Z</updated>

		<summary type="html">&lt;p&gt;Ares Mta: &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(&amp;quot;php://input&amp;quot;)'' 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 or it will return the error #1006}}&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[, int connectionAttempts = 10 ], callback 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;
**'''''errno''''' - 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;
*'''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 6 seconds. Therefore, the default setting of 10 connection attempts means it will be 60 seconds before your script gets a callback about the error. Reducing this value to 2 for example, will decrease that period to 12 seconds''&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;
===Returns===&lt;br /&gt;
Returns ''true'' if the arguments are correct, ''false'' otherwise.&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, errno, playerToReceive )&lt;br /&gt;
    if errno == 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;
&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;
&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;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Resource_functions}}&lt;/div&gt;</summary>
		<author><name>Ares Mta</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=EngineSetModelLODDistance&amp;diff=42163</id>
		<title>EngineSetModelLODDistance</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=EngineSetModelLODDistance&amp;diff=42163"/>
		<updated>2014-09-25T19:24:12Z</updated>

		<summary type="html">&lt;p&gt;Ares Mta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sets a custom LOD distance for any object / model ID. This is the distance at which objects of that model ID are switched to their LOD model, or (if there is no LOD model) become invisible.&lt;br /&gt;
&lt;br /&gt;
'''Notes:'''&lt;br /&gt;
The actual draw distance used is modified by the draw distance slider in the settings 'Video' tab of the MTA client.&lt;br /&gt;
&lt;br /&gt;
*When the 'Video' tab draw distance slider is 0%, the engineSetModelLODDistance setting approximately matches the draw distance used.&lt;br /&gt;
:''e.g. engineSetModelLODDistance(1337,100) will mean model 1337 will be visible up to a distance of '''100''' units.''&lt;br /&gt;
&lt;br /&gt;
*When the 'Video' tab draw distance slider is 100%, the engineSetModelLODDistance setting is approximately doubled before use.&lt;br /&gt;
:''e.g. engineSetModelLODDistance(1337,100) will mean model 1337 will be visible up to a distance of '''200''' units.''&lt;br /&gt;
&lt;br /&gt;
However, there is a general draw distance limit of 300 units. So engineSetModelLODDistance(1337,400) will mean model 1337 will be visible up to a distance of 300 units no matter what the 'Video' tab says.&lt;br /&gt;
&lt;br /&gt;
Therefore, unless it's really important, engineSetModelLODDistance should not be set to anything greater than 170.&amp;lt;br&amp;gt;&lt;br /&gt;
170 will still give the maximum draw distance (of 300 units) on clients that have a 'Video' tab draw distance setting of 100%, and it will help reduce lag for players who chose a lower draw distance in their settings.&lt;br /&gt;
&lt;br /&gt;
{{New feature/item|3.0120|1.2||&lt;br /&gt;
For low LOD elements, engineSetModelLODDistance still has a limit of 300 units, but the actual draw distance used is 5 times the setting value. Also, low LOD elements ignore the 'Video' tab draw distance slider. So a setting of 200 will mean a low LOD element will always have a draw distance of '''1000''' units.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool engineSetModelLODDistance ( int model, float distance ) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''model:''' The model / object ID number you want to change the LOD distance of.&lt;br /&gt;
*'''distance:''' New LOD distance value in San Andreas units.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the function executed succesfully, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
for i, v in ipairs(getElementsByType(&amp;quot;object&amp;quot;))do&lt;br /&gt;
    local model = getElementModel(v)&lt;br /&gt;
    engineSetModelLODDistance(model, 1000)&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;
{{Engine_functions}}&lt;/div&gt;</summary>
		<author><name>Ares Mta</name></author>
	</entry>
</feed>