<?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=Uc.Setlings</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=Uc.Setlings"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Uc.Setlings"/>
	<updated>2026-05-07T03:16:07Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedStat&amp;diff=49165</id>
		<title>SetPedStat</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedStat&amp;diff=49165"/>
		<updated>2016-09-17T04:31:57Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server function}}&lt;br /&gt;
{{Needs_Checking|&lt;br /&gt;
*Things like infinite run, fire proof CJ, 150 health, 150 armor have special activation flags. They need a way to be triggered on/off.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the value of a specific statistic for a [[ped]]. '''Visual stats (FAT and BODY_MUSCLE) can only be used on the CJ skin''', they have no effect on other skins.&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 setPedStat ( ped thePed, int stat, float value )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed''': the [[ped]] whose statistic you want to modify.&lt;br /&gt;
*'''stat''': the stat ID. &lt;br /&gt;
{{Stats}}&lt;br /&gt;
&lt;br /&gt;
*'''value''': the new value of the stat. It must be between 0 and 1000.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the statistic was changed succesfully. Returns ''false'' if an invalid player is specified, if the stat-id/value is out of acceptable range or if the FAT or BODY_MUSCLE stats are used on non-CJ players.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
This example allows a player to type the command 'beefcake' to change his player's BODY_MUSCLE stat (#23) to the maximum value of 1000. This will result in him looking really muscular.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function changeBodyStrength(thePlayer, commandName)&lt;br /&gt;
    -- Output whether the setPlayerStat was successful in changing the BODY_MUSCLE STAT     &lt;br /&gt;
    if setPedStat(thePlayer, 23, 1000) then&lt;br /&gt;
    	outputChatBox(&amp;quot;Your player looks really muscular&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(&amp;quot;Failed to make your player look muscular.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;beefcake&amp;quot;, changeBodyStrength)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example adds a ''/upgradeskills'' command to give the player who types it the maximum skill with every weapon and maximum health.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
&lt;br /&gt;
Skills to upgrade:&lt;br /&gt;
&lt;br /&gt;
24 = Max Player Health&lt;br /&gt;
69 = Weapon Type Pistol Skill&lt;br /&gt;
70 = Weapon Type Pistol Silenced Skill&lt;br /&gt;
71 = Weapon Type Desert Eagle Skill&lt;br /&gt;
72 = Weapon Type Shotgun Skill&lt;br /&gt;
73 = Weapon Type Sawn off Shotgun Skill&lt;br /&gt;
74 = Weapon Type Spas 12 Shotgun Skill&lt;br /&gt;
76 = Weapon Type MP5 Skill&lt;br /&gt;
77 = Weapon Type AK47 Skill&lt;br /&gt;
78 = Weapon Type M4 Skill&lt;br /&gt;
79 = Weapon Type Sniper Rifle Skill&lt;br /&gt;
&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;upgradeskills&amp;quot;, function(thePlayer)&lt;br /&gt;
   -- Set every stat to 1000 (the maximum value)&lt;br /&gt;
   for _, stat in ipairs({ 24, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79 }) do&lt;br /&gt;
      setPedStat(thePlayer, stat, 1000)&lt;br /&gt;
      outputChatBox(&amp;quot;Your game stats upgraded to maximum!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
   end&lt;br /&gt;
      -- Set player health to the maximum, as changing the stat keeps the current one&lt;br /&gt;
      if (isPedDead (thePlayer) ~= true) then&lt;br /&gt;
      setElementHealth(thePlayer, 100 + (getPedStat(ped, 24) - 569) / 4.31 return math.max(1, maxhealth))&lt;br /&gt;
      -- Tell the player what we did&lt;br /&gt;
      outputChatBox(&amp;quot;And your health upgraded to maximum!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
      else&lt;br /&gt;
      outputChatBox(&amp;quot;Your health can't be restored because you are already dead!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Ped functions}}&lt;br /&gt;
[[ru:setPedStat]]&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedMaxHealth&amp;diff=48841</id>
		<title>SetPedMaxHealth</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedMaxHealth&amp;diff=48841"/>
		<updated>2016-08-13T08:19:54Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function sets the health for the specified [[element]]. This can be a [[ped]] or [[player]].&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 setPedMaxHealth ( ped thePed )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings.'''&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed:''' The [[ped]] or [[player]] whose health you want to set.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the new health was set successfully, or ''false'' if the ped or the player is not found or just dead&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function setPedMaxHealth(ped)&lt;br /&gt;
assert(isElement(ped) and (getElementType(ped) == &amp;quot;player&amp;quot; or getElementType(ped) == &amp;quot;ped&amp;quot;), &amp;quot;Bad argument @ 'setPedMaxHealth' [Expected ped/player at argument 1, got &amp;quot; .. tostring(ped) .. &amp;quot; (&amp;quot;.. type(ped) ..&amp;quot;)]&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      if isElement(ped) and isPedDead(ped) == false and (getElementType(ped) == &amp;quot;player&amp;quot;) or (getElementType(ped) == &amp;quot;ped&amp;quot;) then&lt;br /&gt;
      return setElementHealth(ped, 100 + (getPedStat(ped, 24) - 569) / 4.31)&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;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Serverside function&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example adds a /onduty command which gives a cop uniform and nightstick to the player who types it, if he's on a team named &amp;quot;SAPD&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerSpawn&amp;quot;, getRootElement(), function()&lt;br /&gt;
      outputChatBox(&amp;quot;Hello '&amp;quot;..getPlayerName(source)..&amp;quot;'&amp;quot;, source, 255, 100, 100, false)&lt;br /&gt;
      heal = setPedMaxHealth(source)&lt;br /&gt;
      if (heal ~= false) then&lt;br /&gt;
      outputChatBox(&amp;quot;Your health was completely restored!&amp;quot;, source, 255, 100, 100, false)&lt;br /&gt;
      outputChatBox(&amp;quot;Your health is now - '&amp;quot;..math.floor(100 + (getPedStat(source, 24) - 569) / 4.31)..&amp;quot;'&amp;quot;, source, 255, 100, 100, false)&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;
==Example2==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Serverside function&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example adds a /onduty command which gives a cop uniform and nightstick to the player who types it, if he's on a team named &amp;quot;SAPD&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function healAdmin(thePlayer)&lt;br /&gt;
         if (isPedDead(ped) ~= false) then&lt;br /&gt;
            return outputChatBox(&amp;quot;Sorry , but you're dead&amp;quot;, thePlayer, 255, 0, 0, false)&lt;br /&gt;
         end&lt;br /&gt;
      if (hasObjectPermissionTo(thePlayer, &amp;quot;command.sethealth&amp;quot;, false)) then&lt;br /&gt;
      setPedMaxHealth(thePlayer)&lt;br /&gt;
      outputChatBox(&amp;quot;You have just got healed!&amp;quot;, thePlayer, 255, 100, 100, false)&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;healme&amp;quot;, healAdmin)&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>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedMaxHealth&amp;diff=48674</id>
		<title>SetPedMaxHealth</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedMaxHealth&amp;diff=48674"/>
		<updated>2016-08-05T14:04:04Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function sets the health for the specified [[element]]. This can be a [[ped]] or [[player]].&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 setPedMaxHealth ( ped thePed )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings.'''&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed:''' The [[ped]] or [[player]] whose health you want to set.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the new health was set successfully, or ''false'' if the ped or the player is not found or just dead&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function setPedMaxHealth(ped)&lt;br /&gt;
assert(isElement(ped) and (getElementType(ped) == &amp;quot;player&amp;quot; or getElementType(ped) == &amp;quot;ped&amp;quot;), &amp;quot;Bad argument @ 'setPedMaxHealth' [Expected ped/player at argument 1, got &amp;quot; .. tostring(ped) .. &amp;quot; (&amp;quot;.. type(ped) ..&amp;quot;)]&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      if isElement(ped) and isPedDead(ped) == false and (getElementType(ped) == &amp;quot;player&amp;quot;) or (getElementType(ped) == &amp;quot;ped&amp;quot;) then&lt;br /&gt;
      return setElementHealth(ped, 100 + (getPedStat(ped, 24) - 569) / 4.31)&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;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Serverside function&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example adds a /onduty command which gives a cop uniform and nightstick to the player who types it, if he's on a team named &amp;quot;SAPD&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;cped&amp;quot;, function(thePlayer)&lt;br /&gt;
      local ped = createPed(math.random(280, 288), 0, 0, 0, 0, true)&lt;br /&gt;
      if ( isElement(ped) ) then&lt;br /&gt;
      setPedStat(ped, 24, 950)&lt;br /&gt;
      setPedMaxHealth(ped)&lt;br /&gt;
      outputChatBox(&amp;quot;Your ped has now received - '&amp;quot;..math.floor(100 + (getPedStat(ped, 24) - 569) / 4.31)..&amp;quot;'&amp;quot;, thePlayer, 255, 100, 100, false)&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;
==Example2==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Serverside function&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example adds a /onduty command which gives a cop uniform and nightstick to the player who types it, if he's on a team named &amp;quot;SAPD&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function healAdmin(thePlayer)&lt;br /&gt;
         if (isPedDead(ped) ~= false) then&lt;br /&gt;
            return outputChatBox(&amp;quot;Sorry , but you're dead&amp;quot;, thePlayer, 255, 0, 0, false)&lt;br /&gt;
         end&lt;br /&gt;
      if (hasObjectPermissionTo(thePlayer, &amp;quot;command.sethealth&amp;quot;, false)) then&lt;br /&gt;
      setPedMaxHealth(thePlayer)&lt;br /&gt;
      outputChatBox(&amp;quot;You have just got healed!&amp;quot;, thePlayer, 255, 100, 100, false)&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;healme&amp;quot;, healAdmin)&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>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedMaxHealth&amp;diff=48673</id>
		<title>SetPedMaxHealth</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedMaxHealth&amp;diff=48673"/>
		<updated>2016-08-05T13:36:30Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function sets the health for the specified [[element]]. This can be a [[ped]] or [[player]].&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 setPedMaxHealth ( ped thePed )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings(Lev Tosltoy)'''&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed:''' The [[ped]] or [[player]] whose health you want to set.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the new health was set successfully, or ''false'' if the ped or the player is not found or just dead&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function setPedMaxHealth(ped)&lt;br /&gt;
assert(isElement(ped) and (getElementType(ped) == &amp;quot;player&amp;quot; or getElementType(ped) == &amp;quot;ped&amp;quot;), &amp;quot;Bad argument @ 'setPedMaxHealth' [Expected ped/player at argument 1, got &amp;quot; .. tostring(ped) .. &amp;quot; (&amp;quot;.. type(ped) ..&amp;quot;)]&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      if isElement(ped) and isPedDead(ped) == false and (getElementType(ped) == &amp;quot;player&amp;quot;) or (getElementType(ped) == &amp;quot;ped&amp;quot;) then&lt;br /&gt;
      return setElementHealth(ped, 100 + (getPedStat(ped, 24) - 569) / 4.31)&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;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Serverside function&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example adds a /onduty command which gives a cop uniform and nightstick to the player who types it, if he's on a team named &amp;quot;SAPD&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;cped&amp;quot;, function(thePlayer)&lt;br /&gt;
      local ped = createPed(math.random(280, 288), 0, 0, 0, 0, true)&lt;br /&gt;
      if ( isElement(ped) ) then&lt;br /&gt;
      setPedStat(ped, 24, 950)&lt;br /&gt;
      setPedMaxHealth(ped)&lt;br /&gt;
      outputChatBox(&amp;quot;Your ped has now received - '&amp;quot;..math.floor(100 + (getPedStat(ped, 24) - 569) / 4.31)..&amp;quot;'&amp;quot;, thePlayer, 255, 100, 100, false)&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;
==Example2==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Serverside function&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example adds a /onduty command which gives a cop uniform and nightstick to the player who types it, if he's on a team named &amp;quot;SAPD&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function healAdmin(thePlayer)&lt;br /&gt;
         if (isPedDead(ped) ~= false) then&lt;br /&gt;
            return outputChatBox(&amp;quot;Sorry , but you're dead&amp;quot;, thePlayer, 255, 0, 0, false)&lt;br /&gt;
         end&lt;br /&gt;
      if (hasObjectPermissionTo(thePlayer, &amp;quot;command.sethealth&amp;quot;, false)) then&lt;br /&gt;
      setPedMaxHealth(thePlayer)&lt;br /&gt;
      outputChatBox(&amp;quot;You have just got healed!&amp;quot;, thePlayer, 255, 100, 100, false)&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;healme&amp;quot;, healAdmin)&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>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedMaxHealth&amp;diff=48672</id>
		<title>SetPedMaxHealth</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedMaxHealth&amp;diff=48672"/>
		<updated>2016-08-05T13:17:22Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Authors */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function sets the health for the specified [[element]]. This can be a [[ped]] or [[player]].&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 setPedMaxHealth ( ped thePed )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings(Lev Tosltoy)'''&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed:''' The [[ped]] or [[player]] whose health you want to set.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the new health was set successfully, or ''false'' if the ped or the player is not found or just dead&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function setPedMaxHealth(ped)&lt;br /&gt;
assert(isElement(ped) and (getElementType(ped) == &amp;quot;player&amp;quot; or getElementType(ped) == &amp;quot;ped&amp;quot;), &amp;quot;Bad argument @ 'setPedMaxHealth' [Expected ped/player at argument 1, got &amp;quot; .. tostring(ped) .. &amp;quot; (&amp;quot;.. type(ped) ..&amp;quot;)]&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      if isElement(ped) and isPedDead(ped) == false and (getElementType(ped) == &amp;quot;player&amp;quot;) or (getElementType(ped) == &amp;quot;ped&amp;quot;) then&lt;br /&gt;
      return setElementHealth(ped, 100 + (getPedStat(ped, 24) - 569) / 4.31)&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;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example adds a /onduty command which gives a cop uniform and nightstick to the player who types it, if he's on a team named &amp;quot;SAPD&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;cped&amp;quot;, function(thePlayer)&lt;br /&gt;
      local ped = createPed(math.random(280, 288), 0, 0, 0, 0, true)&lt;br /&gt;
      if ( isElement(ped) ) then&lt;br /&gt;
      setPedStat(ped, 24, 950)&lt;br /&gt;
      setPedMaxHealth(ped)&lt;br /&gt;
      outputChatBox(&amp;quot;Your ped has now received - '&amp;quot;..math.floor(100 + (getPedStat(ped, 24) - 569) / 4.31)..&amp;quot;'&amp;quot;, thePlayer, 255, 100, 100, false)&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;
==Example2==&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 adds a /onduty command which gives a cop uniform and nightstick to the player who types it, if he's on a team named &amp;quot;SAPD&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function healAdmin(thePlayer)&lt;br /&gt;
         if (isPedDead(ped) ~= false) then&lt;br /&gt;
            return outputChatBox(&amp;quot;Sorry , but you're dead&amp;quot;, thePlayer, 255, 0, 0, false)&lt;br /&gt;
         end&lt;br /&gt;
      if (hasObjectPermissionTo(thePlayer, &amp;quot;command.sethealth&amp;quot;, false)) then&lt;br /&gt;
      setPedMaxHealth(thePlayer)&lt;br /&gt;
      outputChatBox(&amp;quot;You have just got healed!&amp;quot;, thePlayer, 255, 100, 100, false)&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;healme&amp;quot;, healAdmin)&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>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedMaxHealth&amp;diff=48671</id>
		<title>SetPedMaxHealth</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedMaxHealth&amp;diff=48671"/>
		<updated>2016-08-05T13:10:48Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: Created page with &amp;quot;__NOTOC__ {{Useful Function}} This function sets the health for the specified element. This can be a ped or player.  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; bool setPedMaxHealth ...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function sets the health for the specified [[element]]. This can be a [[ped]] or [[player]].&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 setPedMaxHealth ( ped thePed )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings'''&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed:''' The [[ped]] or [[player]] whose health you want to set.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the new health was set successfully, or ''false'' if the ped or the player is not found or just dead&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function setPedMaxHealth(ped)&lt;br /&gt;
assert(isElement(ped) and (getElementType(ped) == &amp;quot;player&amp;quot; or getElementType(ped) == &amp;quot;ped&amp;quot;), &amp;quot;Bad argument @ 'setPedMaxHealth' [Expected ped/player at argument 1, got &amp;quot; .. tostring(ped) .. &amp;quot; (&amp;quot;.. type(ped) ..&amp;quot;)]&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      if isElement(ped) and isPedDead(ped) == false and (getElementType(ped) == &amp;quot;player&amp;quot;) or (getElementType(ped) == &amp;quot;ped&amp;quot;) then&lt;br /&gt;
      return setElementHealth(ped, 100 + (getPedStat(ped, 24) - 569) / 4.31)&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;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example adds a /onduty command which gives a cop uniform and nightstick to the player who types it, if he's on a team named &amp;quot;SAPD&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;cped&amp;quot;, function(thePlayer)&lt;br /&gt;
      local ped = createPed(math.random(280, 288), 0, 0, 0, 0, true)&lt;br /&gt;
      if ( isElement(ped) ) then&lt;br /&gt;
      setPedStat(ped, 24, 950)&lt;br /&gt;
      setPedMaxHealth(ped)&lt;br /&gt;
      outputChatBox(&amp;quot;Your ped has now received - '&amp;quot;..math.floor(100 + (getPedStat(ped, 24) - 569) / 4.31)..&amp;quot;'&amp;quot;, thePlayer, 255, 100, 100, false)&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;
==Example2==&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 adds a /onduty command which gives a cop uniform and nightstick to the player who types it, if he's on a team named &amp;quot;SAPD&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function healAdmin(thePlayer)&lt;br /&gt;
         if (isPedDead(ped) ~= false) then&lt;br /&gt;
            return outputChatBox(&amp;quot;Sorry , but you're dead&amp;quot;, thePlayer, 255, 0, 0, false)&lt;br /&gt;
         end&lt;br /&gt;
      if (hasObjectPermissionTo(thePlayer, &amp;quot;command.sethealth&amp;quot;, false)) then&lt;br /&gt;
      setPedMaxHealth(thePlayer)&lt;br /&gt;
      outputChatBox(&amp;quot;You have just got healed!&amp;quot;, thePlayer, 255, 100, 100, false)&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;healme&amp;quot;, healAdmin)&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>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Table.random&amp;diff=48670</id>
		<title>Table.random</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Table.random&amp;diff=48670"/>
		<updated>2016-08-05T11:47:13Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
&amp;lt;lowercasetitle&amp;gt;&amp;lt;/lowercasetitle&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function retrieves a random variable from a table.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;var table.random( table theTable )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': The table you want to get a random variable from.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a variable of any type from the table you specified.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server and Client Side 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 table.random ( theTable )&lt;br /&gt;
    return theTable[math.random ( #theTable )]&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 1==&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;
-- #Source Function&lt;br /&gt;
function table.random ( theTable )&lt;br /&gt;
    return theTable[math.random ( #theTable )]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local randomGeT = {&amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;5&amp;quot;, &amp;quot;6&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;9&amp;quot;, &amp;quot;10&amp;quot;, &amp;quot;11&amp;quot;, &amp;quot;12&amp;quot;, &amp;quot;13&amp;quot;, &amp;quot;14&amp;quot;, &amp;quot;15&amp;quot;, &amp;quot;16&amp;quot;, &amp;quot;17&amp;quot;, &amp;quot;18&amp;quot;, &amp;quot;19&amp;quot;, &amp;quot;20&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;random&amp;quot;, function()&lt;br /&gt;
   outputChatBox(&amp;quot;&amp;lt; &amp;quot;..table.random(randomGeT)..&amp;quot; &amp;gt;&amp;quot;)&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;
==Credits==&lt;br /&gt;
*Original function by The Kid.&lt;br /&gt;
*Modified and simplified by Talidan.&lt;br /&gt;
*Adding Example 1 by Uc.Setllings&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedStat&amp;diff=48669</id>
		<title>SetPedStat</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedStat&amp;diff=48669"/>
		<updated>2016-08-05T09:01:54Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server function}}&lt;br /&gt;
{{Needs_Checking|&lt;br /&gt;
*Things like infinite run, fire proof CJ, 150 health, 150 armor have special activation flags. They need a way to be triggered on/off.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the value of a specific statistic for a [[ped]]. '''Visual stats (FAT and BODY_MUSCLE) can only be used on the CJ skin''', they have no effect on other skins.&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 setPedStat ( ped thePed, int stat, float value )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed''': the [[ped]] whose statistic you want to modify.&lt;br /&gt;
*'''stat''': the stat ID. &lt;br /&gt;
{{Stats}}&lt;br /&gt;
&lt;br /&gt;
*'''value''': the new value of the stat. It must be between 0 and 1000.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the statistic was changed succesfully. Returns ''false'' if an invalid player is specified, if the stat-id/value is out of acceptable range or if the FAT or BODY_MUSCLE stats are used on non-CJ players.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
This example allows a player to type the command 'beefcake' to change his player's BODY_MUSCLE stat (#23) to the maximum value of 1000. This will result in him looking really muscular.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function changeBodyStrength(thePlayer, commandName)&lt;br /&gt;
    -- Output whether the setPlayerStat was successful in changing the BODY_MUSCLE STAT     &lt;br /&gt;
    if setPedStat(thePlayer, 23, 1000) then&lt;br /&gt;
    	outputChatBox(&amp;quot;Your player looks really muscular&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(&amp;quot;Failed to make your player look muscular.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;beefcake&amp;quot;, changeBodyStrength)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example adds a ''/upgradeskills'' command to give the player who types it the maximum skill with every weapon and maximum health.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
&lt;br /&gt;
Skills to upgrade:&lt;br /&gt;
&lt;br /&gt;
24 = Max Player Health&lt;br /&gt;
69 = Weapon Type Pistol Skill&lt;br /&gt;
70 = Weapon Type Pistol Silenced Skill&lt;br /&gt;
71 = Weapon Type Desert Eagle Skill&lt;br /&gt;
72 = Weapon Type Shotgun Skill&lt;br /&gt;
73 = Weapon Type Sawn off Shotgun Skill&lt;br /&gt;
74 = Weapon Type Spas 12 Shotgun Skill&lt;br /&gt;
76 = Weapon Type MP5 Skill&lt;br /&gt;
77 = Weapon Type AK47 Skill&lt;br /&gt;
78 = Weapon Type M4 Skill&lt;br /&gt;
79 = Weapon Type Sniper Rifle Skill&lt;br /&gt;
&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
local function getPedMaxHealth(ped) local maxhealth = 100 + (getPedStat(ped, 24) - 569) / 4.31 return math.max(1, maxhealth) end&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;upgradeskills&amp;quot;, function(thePlayer)&lt;br /&gt;
   -- Set every stat to 1000 (the maximum value)&lt;br /&gt;
   for _, stat in ipairs({ 24, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79 }) do&lt;br /&gt;
      setPedStat(thePlayer, stat, 1000)&lt;br /&gt;
      outputChatBox(&amp;quot;Your game stats upgraded to maximum!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
   end&lt;br /&gt;
      -- Set player health to the maximum, as changing the stat keeps the current one&lt;br /&gt;
      if (isPedDead (thePlayer) ~= true) then&lt;br /&gt;
      setElementHealth(thePlayer, getPedMaxHealth(thePlayer))&lt;br /&gt;
      -- Tell the player what we did&lt;br /&gt;
      outputChatBox(&amp;quot;And your health upgraded to maximum!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
      else&lt;br /&gt;
      outputChatBox(&amp;quot;Your health can't be restored because you are already dead!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Ped functions}}&lt;br /&gt;
[[ru:setPedStat]]&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedStat&amp;diff=48665</id>
		<title>SetPedStat</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedStat&amp;diff=48665"/>
		<updated>2016-08-04T19:59:08Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server function}}&lt;br /&gt;
{{Needs_Checking|&lt;br /&gt;
*Things like infinite run, fire proof CJ, 150 health, 150 armor have special activation flags. They need a way to be triggered on/off.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the value of a specific statistic for a [[ped]]. '''Visual stats (FAT and BODY_MUSCLE) can only be used on the CJ skin''', they have no effect on other skins.&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 setPedStat ( ped thePed, int stat, float value )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed''': the [[ped]] whose statistic you want to modify.&lt;br /&gt;
*'''stat''': the stat ID. &lt;br /&gt;
{{Stats}}&lt;br /&gt;
&lt;br /&gt;
*'''value''': the new value of the stat. It must be between 0 and 1000.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the statistic was changed succesfully. Returns ''false'' if an invalid player is specified, if the stat-id/value is out of acceptable range or if the FAT or BODY_MUSCLE stats are used on non-CJ players.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
This example allows a player to type the command 'beefcake' to change his player's BODY_MUSCLE stat (#23) to the maximum value of 1000. This will result in him looking really muscular.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function changeBodyStrength(thePlayer, commandName)&lt;br /&gt;
    -- Output whether the setPlayerStat was successful in changing the BODY_MUSCLE STAT     &lt;br /&gt;
    if setPedStat(thePlayer, 23, 1000) then&lt;br /&gt;
    	outputChatBox(&amp;quot;Your player looks really muscular&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(&amp;quot;Failed to make your player look muscular.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;beefcake&amp;quot;, changeBodyStrength)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example adds a ''/upgradeskills'' command to give the player who types it the maximum skill with every weapon and maximum health.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
&lt;br /&gt;
Skills to upgrade:&lt;br /&gt;
&lt;br /&gt;
24 = Max Player Health&lt;br /&gt;
69 = Weapon Type Pistol Skill&lt;br /&gt;
70 = Weapon Type Pistol Silenced Skill&lt;br /&gt;
71 = Weapon Type Desert Eagle Skill&lt;br /&gt;
72 = Weapon Type Shotgun Skill&lt;br /&gt;
73 = Weapon Type Sawn off Shotgun Skill&lt;br /&gt;
74 = Weapon Type Spas 12 Shotgun Skill&lt;br /&gt;
76 = Weapon Type MP5 Skill&lt;br /&gt;
77 = Weapon Type AK47 Skill&lt;br /&gt;
78 = Weapon Type M4 Skill&lt;br /&gt;
79 = Weapon Type Sniper Rifle Skill&lt;br /&gt;
&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
local function getPedMaxHealth(ped) local maxhealth = 100 + (getPedStat(ped, 24) - 569) / 4.31 return math.max(1, maxhealth) end&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;upgradeskills&amp;quot;, function(thePlayer)&lt;br /&gt;
   -- Set every stat to 1000 (the maximum value)&lt;br /&gt;
   for _, stat in ipairs({ 24, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79 }) do&lt;br /&gt;
      setPedStat(thePlayer, stat, 1000)&lt;br /&gt;
      outputChatBox(&amp;quot;Your game stats upgraded to maximum!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
   end&lt;br /&gt;
      -- Set player health to the maximum, as changing the stat keeps the current one&lt;br /&gt;
      if (isPedDead (thePlayer) == false) then&lt;br /&gt;
      setElementHealth(thePlayer, getPedMaxHealth(thePlayer))&lt;br /&gt;
      -- Tell the player what we did&lt;br /&gt;
      outputChatBox(&amp;quot;And your health upgraded to maximum!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
      else&lt;br /&gt;
      outputChatBox(&amp;quot;Your health can't be restored because you are already dead!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Ped functions}}&lt;br /&gt;
[[ru:setPedStat]]&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedStat&amp;diff=48664</id>
		<title>SetPedStat</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedStat&amp;diff=48664"/>
		<updated>2016-08-04T19:53:03Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server function}}&lt;br /&gt;
{{Needs_Checking|&lt;br /&gt;
*Things like infinite run, fire proof CJ, 150 health, 150 armor have special activation flags. They need a way to be triggered on/off.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the value of a specific statistic for a [[ped]]. '''Visual stats (FAT and BODY_MUSCLE) can only be used on the CJ skin''', they have no effect on other skins.&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 setPedStat ( ped thePed, int stat, float value )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed''': the [[ped]] whose statistic you want to modify.&lt;br /&gt;
*'''stat''': the stat ID. &lt;br /&gt;
{{Stats}}&lt;br /&gt;
&lt;br /&gt;
*'''value''': the new value of the stat. It must be between 0 and 1000.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the statistic was changed succesfully. Returns ''false'' if an invalid player is specified, if the stat-id/value is out of acceptable range or if the FAT or BODY_MUSCLE stats are used on non-CJ players.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
This example allows a player to type the command 'beefcake' to change his player's BODY_MUSCLE stat (#23) to the maximum value of 1000. This will result in him looking really muscular.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function changeBodyStrength(thePlayer, commandName)&lt;br /&gt;
    -- Output whether the setPlayerStat was successful in changing the BODY_MUSCLE STAT     &lt;br /&gt;
    if setPedStat(thePlayer, 23, 1000) then&lt;br /&gt;
    	outputChatBox(&amp;quot;Your player looks really muscular&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(&amp;quot;Failed to make your player look muscular.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;beefcake&amp;quot;, changeBodyStrength)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example adds a ''/upgradeskills'' command to give the player who types it the maximum skill with every weapon and maximum health.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
&lt;br /&gt;
Skills to upgrade:&lt;br /&gt;
&lt;br /&gt;
24 = Max Player Health&lt;br /&gt;
69 = Weapon Type Pistol Skill&lt;br /&gt;
70 = Weapon Type Pistol Silenced Skill&lt;br /&gt;
71 = Weapon Type Desert Eagle Skill&lt;br /&gt;
72 = Weapon Type Shotgun Skill&lt;br /&gt;
73 = Weapon Type Sawn off Shotgun Skill&lt;br /&gt;
74 = Weapon Type Spas 12 Shotgun Skill&lt;br /&gt;
76 = Weapon Type MP5 Skill&lt;br /&gt;
77 = Weapon Type AK47 Skill&lt;br /&gt;
78 = Weapon Type M4 Skill&lt;br /&gt;
79 = Weapon Type Sniper Rifle Skill&lt;br /&gt;
&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
function getPedMaxHealth(ped)&lt;br /&gt;
   local maxhealth = 100 + (getPedStat(ped, 24) - 569) / 4.31&lt;br /&gt;
   return math.max(1, maxhealth)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;upgradeskills&amp;quot;, function(thePlayer)&lt;br /&gt;
   -- Set every stat to 1000 (the maximum value)&lt;br /&gt;
   for _, stat in ipairs({ 24, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79 }) do&lt;br /&gt;
      setPedStat(thePlayer, stat, 1000)&lt;br /&gt;
      outputChatBox(&amp;quot;Your game stats upgraded to maximum!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
   end&lt;br /&gt;
      -- Set player health to the maximum, as changing the stat keeps the current one&lt;br /&gt;
      if (isPedDead (thePlayer) == false) then&lt;br /&gt;
      setElementHealth(thePlayer, getPedMaxHealth(thePlayer))&lt;br /&gt;
      -- Tell the player what we did&lt;br /&gt;
      outputChatBox(&amp;quot;And your health upgraded to maximum!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
      else&lt;br /&gt;
      outputChatBox(&amp;quot;Your health can't be restored because you are already dead!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Ped functions}}&lt;br /&gt;
[[ru:setPedStat]]&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedStat&amp;diff=48663</id>
		<title>SetPedStat</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedStat&amp;diff=48663"/>
		<updated>2016-08-04T18:22:53Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server function}}&lt;br /&gt;
{{Needs_Checking|&lt;br /&gt;
*Things like infinite run, fire proof CJ, 150 health, 150 armor have special activation flags. They need a way to be triggered on/off.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the value of a specific statistic for a [[ped]]. '''Visual stats (FAT and BODY_MUSCLE) can only be used on the CJ skin''', they have no effect on other skins.&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 setPedStat ( ped thePed, int stat, float value )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed''': the [[ped]] whose statistic you want to modify.&lt;br /&gt;
*'''stat''': the stat ID. &lt;br /&gt;
{{Stats}}&lt;br /&gt;
&lt;br /&gt;
*'''value''': the new value of the stat. It must be between 0 and 1000.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the statistic was changed succesfully. Returns ''false'' if an invalid player is specified, if the stat-id/value is out of acceptable range or if the FAT or BODY_MUSCLE stats are used on non-CJ players.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
This example allows a player to type the command 'beefcake' to change his player's BODY_MUSCLE stat (#23) to the maximum value of 1000. This will result in him looking really muscular.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function changeBodyStrength(thePlayer, commandName)&lt;br /&gt;
    -- Output whether the setPlayerStat was successful in changing the BODY_MUSCLE STAT     &lt;br /&gt;
    if setPedStat(thePlayer, 23, 1000) then&lt;br /&gt;
    	outputChatBox(&amp;quot;Your player looks really muscular&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(&amp;quot;Failed to make your player look muscular.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;beefcake&amp;quot;, changeBodyStrength)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example adds a ''/upgradeskills'' command to give the player who types it the maximum skill with every weapon and maximum health.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
&lt;br /&gt;
Skills to upgrade:&lt;br /&gt;
&lt;br /&gt;
24 = Max Player Health&lt;br /&gt;
69 = Weapon Type Pistol Skill&lt;br /&gt;
70 = Weapon Type Pistol Silenced Skill&lt;br /&gt;
71 = Weapon Type Desert Eagle Skill&lt;br /&gt;
72 = Weapon Type Shotgun Skill&lt;br /&gt;
73 = Weapon Type Sawn off Shotgun Skill&lt;br /&gt;
74 = Weapon Type Spas 12 Shotgun Skill&lt;br /&gt;
76 = Weapon Type MP5 Skill&lt;br /&gt;
77 = Weapon Type AK47 Skill&lt;br /&gt;
78 = Weapon Type M4 Skill&lt;br /&gt;
79 = Weapon Type Sniper Rifle Skill&lt;br /&gt;
&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
function getPedMaxHealth(ped)&lt;br /&gt;
    -- Output an error and stop executing the function if the argument is not valid&lt;br /&gt;
    assert(isElement(ped) and (getElementType(ped) == &amp;quot;ped&amp;quot; or getElementType(ped) == &amp;quot;player&amp;quot;), &amp;quot;Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got &amp;quot; .. tostring(ped) .. &amp;quot;]&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
    -- Grab his player health stat.&lt;br /&gt;
    local stat = getPedStat(ped, 24)&lt;br /&gt;
 &lt;br /&gt;
    -- Do a linear interpolation to get how many health a ped can have.&lt;br /&gt;
    -- Assumes: 100 health = 569 stat, 200 health = 1000 stat.&lt;br /&gt;
    local maxhealth = 100 + (stat - 569) / 4.31&lt;br /&gt;
 &lt;br /&gt;
    -- Return the max health. Make sure it can't be below 1&lt;br /&gt;
    return math.max(1, maxhealth)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;upgradeskills&amp;quot;, function(thePlayer)&lt;br /&gt;
   -- Set every stat to 1000 (the maximum value)&lt;br /&gt;
   for _, stat in ipairs({ 24, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79 }) do&lt;br /&gt;
      setPedStat(thePlayer, stat, 1000)&lt;br /&gt;
      outputChatBox(&amp;quot;Your game stats upgraded to maximum!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
   end&lt;br /&gt;
      -- Set player health to the maximum, as changing the stat keeps the current one&lt;br /&gt;
      if (isPedDead (thePlayer) == false) then&lt;br /&gt;
      setElementHealth(thePlayer, getPedMaxHealth(thePlayer))&lt;br /&gt;
      -- Tell the player what we did&lt;br /&gt;
      outputChatBox(&amp;quot;And your health upgraded to maximum!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
      else&lt;br /&gt;
      outputChatBox(&amp;quot;Your health can't be restored because you are already dead!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Ped functions}}&lt;br /&gt;
[[ru:setPedStat]]&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SetPedStat&amp;diff=48662</id>
		<title>SetPedStat</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SetPedStat&amp;diff=48662"/>
		<updated>2016-08-04T18:01:49Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server function}}&lt;br /&gt;
{{Needs_Checking|&lt;br /&gt;
*Things like infinite run, fire proof CJ, 150 health, 150 armor have special activation flags. They need a way to be triggered on/off.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function allows you to set the value of a specific statistic for a [[ped]]. '''Visual stats (FAT and BODY_MUSCLE) can only be used on the CJ skin''', they have no effect on other skins.&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 setPedStat ( ped thePed, int stat, float value )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''thePed''': the [[ped]] whose statistic you want to modify.&lt;br /&gt;
*'''stat''': the stat ID. &lt;br /&gt;
{{Stats}}&lt;br /&gt;
&lt;br /&gt;
*'''value''': the new value of the stat. It must be between 0 and 1000.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the statistic was changed succesfully. Returns ''false'' if an invalid player is specified, if the stat-id/value is out of acceptable range or if the FAT or BODY_MUSCLE stats are used on non-CJ players.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
This example allows a player to type the command 'beefcake' to change his player's BODY_MUSCLE stat (#23) to the maximum value of 1000. This will result in him looking really muscular.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function changeBodyStrength(thePlayer, commandName)&lt;br /&gt;
    -- Output whether the setPlayerStat was successful in changing the BODY_MUSCLE STAT     &lt;br /&gt;
    if setPedStat(thePlayer, 23, 1000) then&lt;br /&gt;
    	outputChatBox(&amp;quot;Your player looks really muscular&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(&amp;quot;Failed to make your player look muscular.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;beefcake&amp;quot;, changeBodyStrength)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example adds a ''/upgradeskills'' command to give the player who types it the maximum skill with every weapon and maximum health.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
&lt;br /&gt;
Skills to upgrade:&lt;br /&gt;
&lt;br /&gt;
24 = Max Player Health&lt;br /&gt;
69 = Weapon Type Pistol Skill&lt;br /&gt;
70 = Weapon Type Pistol Silenced Skill&lt;br /&gt;
71 = Weapon Type Desert Eagle Skill&lt;br /&gt;
72 = Weapon Type Shotgun Skill&lt;br /&gt;
73 = Weapon Type Sawn off Shotgun Skill&lt;br /&gt;
74 = Weapon Type Spas 12 Shotgun Skill&lt;br /&gt;
76 = Weapon Type MP5 Skill&lt;br /&gt;
77 = Weapon Type AK47 Skill&lt;br /&gt;
78 = Weapon Type M4 Skill&lt;br /&gt;
79 = Weapon Type Sniper Rifle Skill&lt;br /&gt;
&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
function getPedMaxHealth(ped)&lt;br /&gt;
    -- Output an error and stop executing the function if the argument is not valid&lt;br /&gt;
    assert(isElement(ped) and (getElementType(ped) == &amp;quot;ped&amp;quot; or getElementType(ped) == &amp;quot;player&amp;quot;), &amp;quot;Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got &amp;quot; .. tostring(ped) .. &amp;quot;]&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
    -- Grab his player health stat.&lt;br /&gt;
    local stat = getPedStat(ped, 24)&lt;br /&gt;
 &lt;br /&gt;
    -- Do a linear interpolation to get how many health a ped can have.&lt;br /&gt;
    -- Assumes: 100 health = 569 stat, 200 health = 1000 stat.&lt;br /&gt;
    local maxhealth = 100 + (stat - 569) / 4.31&lt;br /&gt;
 &lt;br /&gt;
    -- Return the max health. Make sure it can't be below 1&lt;br /&gt;
    return math.max(1, maxhealth)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;upgradeskills&amp;quot;, function(thePlayer)&lt;br /&gt;
   -- Set every stat to 1000 (the maximum value)&lt;br /&gt;
   for _, stat in ipairs({ 24, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79 }) do&lt;br /&gt;
      setPedStat(thePlayer, stat, 1000)&lt;br /&gt;
   end&lt;br /&gt;
   -- Set player health to the maximum, as changing the stat keeps the current one&lt;br /&gt;
   setElementHealth(thePlayer, getPedMaxHealth(thePlayer))&lt;br /&gt;
   -- Tell the player what we did&lt;br /&gt;
   outputChatBox(&amp;quot;Weapon skills and health upgraded to maximum!&amp;quot;, thePlayer, 0, 255, 0, false)&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Ped functions}}&lt;br /&gt;
[[ru:setPedStat]]&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47444</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47444"/>
		<updated>2016-04-29T19:18:33Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function IfElse(condition, resultTrue, resultFalse)&lt;br /&gt;
      if (not condition) then&lt;br /&gt;
      return resultFalse&lt;br /&gt;
else&lt;br /&gt;
      return resultTrue&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local stringType = { [&amp;quot;Automobile&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Plane&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Bike&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Helicopter&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Boat&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Train&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Trailer&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;BMX&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Monster Truck&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Quad&amp;quot;] = true&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
                   if (type(typevehicle) ~= &amp;quot;string&amp;quot;) or (tostring(typevehicle) == nil) or (tostring(typevehicle) == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle &amp;lt;Type Vehicle&amp;gt;&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if stringType[tostring(typevehicle)] then&lt;br /&gt;
         outputServerLog((&amp;quot;[Vehicles By Type - '%s'] - &amp;quot;..IfElse(getVehiclesCountByType(typevehicle) &amp;lt; 1, &amp;quot; Not found!&amp;quot;, &amp;quot;Found '%s'&amp;quot;)):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47443</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47443"/>
		<updated>2016-04-29T19:17:33Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function IfElse(condition, resultTrue, resultFalse)&lt;br /&gt;
     if (not condition) then&lt;br /&gt;
     return resultFalse&lt;br /&gt;
else&lt;br /&gt;
     return resultTrue&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local stringType = { [&amp;quot;Automobile&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Plane&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Bike&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Helicopter&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Boat&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Train&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Trailer&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;BMX&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Monster Truck&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Quad&amp;quot;] = true&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
                   if (type(typevehicle) ~= &amp;quot;string&amp;quot;) or (tostring(typevehicle) == nil) or (tostring(typevehicle) == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle &amp;lt;Type Vehicle&amp;gt;&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if stringType[tostring(typevehicle)] then&lt;br /&gt;
         outputServerLog((&amp;quot;[Vehicles By Type - '%s'] - &amp;quot;..IfElse(getVehiclesCountByType(typevehicle) &amp;lt; 1, &amp;quot; Not found!&amp;quot;, &amp;quot;Found '%s'&amp;quot;)):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47442</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47442"/>
		<updated>2016-04-29T19:15:54Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function IfElse(condition, resultTrue, resultFalse)&lt;br /&gt;
    if (condition) then return resultTrue&lt;br /&gt;
    else return resultFalse end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local stringType = { [&amp;quot;Automobile&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Plane&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Bike&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Helicopter&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Boat&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Train&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Trailer&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;BMX&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Monster Truck&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Quad&amp;quot;] = true&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
                   if (type(typevehicle) ~= &amp;quot;string&amp;quot;) or (tostring(typevehicle) == nil) or (tostring(typevehicle) == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle &amp;lt;Type Vehicle&amp;gt;&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if stringType[tostring(typevehicle)] then&lt;br /&gt;
         outputServerLog((&amp;quot;[Vehicles By Type - '%s'] - &amp;quot;..IfElse(getVehiclesCountByType(typevehicle) &amp;lt; 1, &amp;quot; Not found!&amp;quot;, &amp;quot;Found '%s'&amp;quot;)):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47441</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47441"/>
		<updated>2016-04-29T19:13:00Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function IfElse(condition, resultTrue, resultFalse)&lt;br /&gt;
    if (condition) then return resultTrue&lt;br /&gt;
    else return resultFalse end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local stringType = { [&amp;quot;Automobile&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Plane&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Bike&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Helicopter&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Boat&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Train&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Trailer&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;BMX&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Monster Truck&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Quad&amp;quot;] = true&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
                   if (type(typevehicle) ~= &amp;quot;string&amp;quot;) or (tostring(typevehicle) == nil) or (tostring(typevehicle) == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle &amp;lt;Type Vehicle&amp;gt;&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if stringType[tostring(typevehicle)] then&lt;br /&gt;
         outputServerLog((&amp;quot;[Vehicles By Type - '%s'] - &amp;quot;..IfElse(getVehiclesCountByType(typevehicle) == 0, &amp;quot; Not found!&amp;quot;, &amp;quot;Found '%s'&amp;quot;)):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47429</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47429"/>
		<updated>2016-04-25T15:32:43Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local stringType = { [&amp;quot;Automobile&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Plane&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Bike&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Helicopter&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Boat&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Train&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Trailer&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;BMX&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Monster Truck&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Quad&amp;quot;] = true&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
                   if (type(typevehicle) ~= &amp;quot;string&amp;quot;) or (tostring(typevehicle) == nil) or (tostring(typevehicle) == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle &amp;lt;Type Vehicle&amp;gt;&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if stringType[tostring(typevehicle)] then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47428</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47428"/>
		<updated>2016-04-25T15:31:44Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local stringType = { [&amp;quot;Automobile&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Plane&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Bike&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Helicopter&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Boat&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Train&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Trailer&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;BMX&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Monster Truck&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Quad&amp;quot;] = true&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
                   if (type(typevehicle) ~= &amp;quot;string&amp;quot;) or (tostring(typevehicle) == nil) or (tostring(typevehicle) == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle &amp;lt;Type Vehicle&amp;gt;&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if (type(typevehicle) == &amp;quot;string&amp;quot;) and stringType[tostring(typevehicle)] then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47418</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47418"/>
		<updated>2016-04-20T11:52:42Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local stringType = { [&amp;quot;Automobile&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Plane&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Bike&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Helicopter&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Boat&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Train&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Trailer&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;BMX&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Monster Truck&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Quad&amp;quot;] = true&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
                   if (type(typevehicle) ~= &amp;quot;string&amp;quot;) or (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if (type(typevehicle) == &amp;quot;string&amp;quot;) and stringType[tostring(typevehicle)] then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47417</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47417"/>
		<updated>2016-04-20T05:07:02Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local stringType = { [&amp;quot;Automobile&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Plane&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Bike&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Helicopter&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Boat&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Train&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Trailer&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;BMX&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Monster Truck&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Quad&amp;quot;] = true&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
                   if (type(typevehicle) ~= &amp;quot;string&amp;quot;) and (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if (type(typevehicle) == &amp;quot;string&amp;quot;) and stringType[tostring(typevehicle)] then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47416</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47416"/>
		<updated>2016-04-20T05:06:32Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local stringType = { [&amp;quot;Automobile&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Plane&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Bike&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Helicopter&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Boat&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Train&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Trailer&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;BMX&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Monster Truck&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Quad&amp;quot;] = true&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
                   if (type(typevehicle) ~= &amp;quot;string&amp;quot;) and (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if (type(typevehicle) == &amp;quot;string&amp;quot;) and stringType[tostring(typevehicle)] then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47415</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47415"/>
		<updated>2016-04-20T04:59:13Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local stringType = { [&amp;quot;Automobile&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Plane&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Bike&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Helicopter&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Boat&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Train&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Trailer&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;BMX&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Monster Truck&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Quad&amp;quot;] = true&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
                   if (type(typevehicle) ~= &amp;quot;string&amp;quot;) and (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if (type(typevehicle) == &amp;quot;string&amp;quot;) and stringType[tostring(typevehicle)] then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47414</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47414"/>
		<updated>2016-04-20T04:55:58Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local stringType = { [&amp;quot;Automobile&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Plane&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Bike&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Helicopter&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Boat&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Train&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Trailer&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;BMX&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Monster Truck&amp;quot;] = true,&lt;br /&gt;
                     [&amp;quot;Quad&amp;quot;] = true&lt;br /&gt;
                   }&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
                   if (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if stringType[tostring(typevehicle)] then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47399</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47399"/>
		<updated>2016-04-17T20:20:58Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Vehicle type list */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
&amp;lt;table border=&amp;quot;3.5&amp;quot; class=&amp;quot;unnamed1&amp;quot;&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Automobile&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Plane&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Helicopter&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Boat&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Train&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Trailer&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;BMX&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Monster Truck&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Quad&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
&lt;br /&gt;
                   if (type(typevehicle) == &amp;quot;string&amp;quot;) and (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (type(typevehicle) == &amp;quot;string&amp;quot;) and&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47377</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47377"/>
		<updated>2016-04-16T12:07:17Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
&lt;br /&gt;
                   if (type(typevehicle) == &amp;quot;string&amp;quot;) and (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (type(typevehicle) == &amp;quot;string&amp;quot;) and&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47376</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47376"/>
		<updated>2016-04-16T11:22:51Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (ifElementIsConsole(aElement) ~= false) then&lt;br /&gt;
&lt;br /&gt;
                   if (type(typevehicle) == &amp;quot;string&amp;quot;) and (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (type(typevehicle) == &amp;quot;string&amp;quot;) and&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
function ifElementIsConsole(playerName)&lt;br /&gt;
    assert(isElement(playerName), &amp;quot;Bad argument 1 @ ifElementIsConsole (Expected element at argument 1, got &amp;quot; .. type(playerName) .. &amp;quot;)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    if  (getElementType(playerName) == &amp;quot;console&amp;quot;) and&lt;br /&gt;
        (getPlayerName(playerName) == &amp;quot;Console&amp;quot;) and&lt;br /&gt;
        (hasObjectPermissionTo(playerName, &amp;quot;function.shutdown&amp;quot;, false))&lt;br /&gt;
    then&lt;br /&gt;
    return true&lt;br /&gt;
    end&lt;br /&gt;
       return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47375</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47375"/>
		<updated>2016-04-16T11:22:22Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (ifElementIsConsole(aElement) ~= false) then&lt;br /&gt;
&lt;br /&gt;
                   if (type(typevehicle) == &amp;quot;string&amp;quot;) and (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (type(typevehicle) == &amp;quot;string&amp;quot;) and&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
function ifElementIsConsole(playerName)&lt;br /&gt;
    assert(isElement(playerName), &amp;quot;Bad argument 1 @ ifElementIsConsole (Expected element at argument 1, got &amp;quot; .. type(playerName) .. &amp;quot;)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    if  (getElementType(playerName) == &amp;quot;1console&amp;quot;) and&lt;br /&gt;
        (getPlayerName(playerName) == &amp;quot;Console&amp;quot;) and&lt;br /&gt;
        (hasObjectPermissionTo(playerName, &amp;quot;function.shutdown&amp;quot;, false))&lt;br /&gt;
    then&lt;br /&gt;
    return true&lt;br /&gt;
    end&lt;br /&gt;
       return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47374</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47374"/>
		<updated>2016-04-16T11:21:43Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (ifElementIsConsole(aElement) ~= false) then&lt;br /&gt;
&lt;br /&gt;
                   if (type(typevehicle) == &amp;quot;string&amp;quot;) and (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (type(typevehicle) == &amp;quot;string&amp;quot;) and&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
 &lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
 &lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function ifElementIsConsole(playerName)&lt;br /&gt;
    assert(isElement(playerName), &amp;quot;Bad argument 1 @ ifElementIsConsole (Expected element at argument 1, got &amp;quot; .. type(playerName) .. &amp;quot;)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    if  (getElementType(playerName) == &amp;quot;1console&amp;quot;) and&lt;br /&gt;
        (getPlayerName(playerName) == &amp;quot;Console&amp;quot;) and&lt;br /&gt;
        (hasObjectPermissionTo(playerName, &amp;quot;function.shutdown&amp;quot;, false))&lt;br /&gt;
    then&lt;br /&gt;
    return true&lt;br /&gt;
    end&lt;br /&gt;
       return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47369</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47369"/>
		<updated>2016-04-13T22:47:17Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) and (getPlayerName(aElement) == &amp;quot;Console&amp;quot;) then&lt;br /&gt;
&lt;br /&gt;
                   if (type(typevehicle) == &amp;quot;string&amp;quot;) and (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (type(typevehicle) == &amp;quot;string&amp;quot;) and&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47368</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47368"/>
		<updated>2016-04-13T22:47:08Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) and (getPlayerName(aElement) == &amp;quot;Console&amp;quot;) then&lt;br /&gt;
&lt;br /&gt;
                   if (type(typevehicle) == &amp;quot;string&amp;quot;) and (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
                      outputServerLog(&amp;quot;Correct syntax: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (type(typevehicle) == &amp;quot;string&amp;quot;) and&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47367</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47367"/>
		<updated>2016-04-12T20:09:42Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) and (getPlayerName(aElement) == &amp;quot;Console&amp;quot;) then&lt;br /&gt;
&lt;br /&gt;
                   if (type(typevehicle) == &amp;quot;string&amp;quot;) and (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
                      outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (type(typevehicle) == &amp;quot;string&amp;quot;) and&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47366</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47366"/>
		<updated>2016-04-12T20:08:04Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) and (getPlayerName(aElement) == &amp;quot;Console&amp;quot;) then&lt;br /&gt;
&lt;br /&gt;
                   if type(typevehicle) == &amp;quot;string&amp;quot; and (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
                      outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         type(typevehicle) == &amp;quot;string&amp;quot; and&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Table.random&amp;diff=47365</id>
		<title>Table.random</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Table.random&amp;diff=47365"/>
		<updated>2016-04-12T17:53:31Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
&amp;lt;lowercasetitle&amp;gt;&amp;lt;/lowercasetitle&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function retrieves a random variable from a table.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;var table.random( table theTable )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': The table you want to get a random variable from.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a variable of any type from the table you specified.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server and Client Side 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 table.random ( theTable )&lt;br /&gt;
    return theTable[math.random ( #theTable )]&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 1==&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;
-- #Source Function&lt;br /&gt;
function table.random ( theTable )&lt;br /&gt;
    return theTable[math.random ( #theTable )]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local randomGeT = {&amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;5&amp;quot;, &amp;quot;6&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;9&amp;quot;, &amp;quot;10&amp;quot;, &amp;quot;11&amp;quot;, &amp;quot;12&amp;quot;, &amp;quot;13&amp;quot;, &amp;quot;14&amp;quot;, &amp;quot;15&amp;quot;, &amp;quot;16&amp;quot;, &amp;quot;17&amp;quot;, &amp;quot;18&amp;quot;, &amp;quot;19&amp;quot;, &amp;quot;20&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;random&amp;quot;, function()&lt;br /&gt;
   local tRandom = table.random(randomGeT) -- randomGeT - The name of the table&lt;br /&gt;
   outputChatBox(&amp;quot;&amp;lt; &amp;quot;..tRandom..&amp;quot; &amp;gt;&amp;quot;)&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;
==Credits==&lt;br /&gt;
*Original function by The Kid.&lt;br /&gt;
*Modified and simplified by Talidan.&lt;br /&gt;
*Adding Example 1 by Uc.Setllings&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Table.random&amp;diff=47364</id>
		<title>Table.random</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Table.random&amp;diff=47364"/>
		<updated>2016-04-12T17:46:46Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
&amp;lt;lowercasetitle&amp;gt;&amp;lt;/lowercasetitle&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function retrieves a random variable from a table.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;var table.random( table theTable )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': The table you want to get a random variable from.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a variable of any type from the table you specified.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server and Client Side 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 table.random ( theTable )&lt;br /&gt;
    return theTable[math.random ( #theTable )]&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 1==&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;
-- #Source Function&lt;br /&gt;
function table.random ( theTable )&lt;br /&gt;
    return theTable[math.random ( #theTable )]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local randomGeT = {&amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;5&amp;quot;, &amp;quot;6&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;9&amp;quot;, &amp;quot;10&amp;quot;, &amp;quot;11&amp;quot;, &amp;quot;12&amp;quot;, &amp;quot;13&amp;quot;, &amp;quot;14&amp;quot;, &amp;quot;15&amp;quot;, &amp;quot;16&amp;quot;, &amp;quot;17&amp;quot;, &amp;quot;18&amp;quot;, &amp;quot;19&amp;quot;, &amp;quot;20&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;getrandom&amp;quot;, function()&lt;br /&gt;
   local tRandom = table.random(randomGeT) -- randomGeT - The name of the table&lt;br /&gt;
   outputChatBox(&amp;quot;&amp;lt; &amp;quot;..tRandom..&amp;quot; &amp;gt;&amp;quot;)&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
==Credits==&lt;br /&gt;
*Original function by The Kid.&lt;br /&gt;
*Modified and simplified by Talidan.&lt;br /&gt;
*Adding Example 1 by Uc.Setllings&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47363</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47363"/>
		<updated>2016-04-12T16:55:36Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) and (getPlayerName(aElement) == &amp;quot;Console&amp;quot;) then&lt;br /&gt;
&lt;br /&gt;
                   if (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) or (string.len(typevehicle) &amp;lt; 3) then&lt;br /&gt;
                      outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
                      outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetPlayerAcls&amp;diff=47361</id>
		<title>GetPlayerAcls</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetPlayerAcls&amp;diff=47361"/>
		<updated>2016-04-10T22:14:25Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
&amp;lt;lowercasetitle&amp;gt;&amp;lt;/lowercasetitle&amp;gt;&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This function returns a table over all the ACL's Player.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table getPlayerAcls ( player thePlayer )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''thePlayer:''' The Player to get the ACL's elements from&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a ''table'' over the ''string''. This table might be empty if player invalid or player account is guest.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getPlayerAcls(thePlayer)&lt;br /&gt;
    local acls = {}&lt;br /&gt;
    local account = getPlayerAccount(thePlayer)&lt;br /&gt;
    if (account) and not (isGuestAccount(account)) then&lt;br /&gt;
        local accountName = getAccountName(account)&lt;br /&gt;
        for i,group in ipairs(aclGroupList()) do&lt;br /&gt;
            if (isObjectInACLGroup( &amp;quot;user.&amp;quot; ..accountName, group)) then&lt;br /&gt;
                local groupName = aclGroupGetName(group)&lt;br /&gt;
                table.insert(acls, groupName)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return acls&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Serverside script&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example outputs the list of ACL's player&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;addCommandHandler(&amp;quot;getacls&amp;quot;,&lt;br /&gt;
function (thePlayer)&lt;br /&gt;
    local acl = getPlayerAcls(thePlayer)&lt;br /&gt;
    outputChatBox(&amp;quot;You're in the following ACL groups: &amp;quot;..tostring(table.concat(acl, &amp;quot;, &amp;quot;), thePlayer, 255, 0, 0))&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;
==Credits==&lt;br /&gt;
*'''Author:''': WASSIm.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47354</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47354"/>
		<updated>2016-04-05T12:19:40Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) and (getPlayerName(aElement) == &amp;quot;Console&amp;quot;) then&lt;br /&gt;
&lt;br /&gt;
                   if (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) then&lt;br /&gt;
                      outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
                      outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47353</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47353"/>
		<updated>2016-04-05T12:18:24Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) and (getPlayerName(aElement) == &amp;quot;Console&amp;quot;)then&lt;br /&gt;
&lt;br /&gt;
                   if (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) then&lt;br /&gt;
                      outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
                      outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' isn't correct&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47352</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47352"/>
		<updated>2016-04-04T22:40:44Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) and (getPlayerName(aElement) == &amp;quot;Console&amp;quot;)then&lt;br /&gt;
&lt;br /&gt;
                   if (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) then&lt;br /&gt;
                      outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
                      outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' is incorrect&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47351</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47351"/>
		<updated>2016-04-04T22:39:44Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(aElement, commandName, typevehicle)&lt;br /&gt;
                   if (getElementType(aElement) == &amp;quot;console&amp;quot;) then&lt;br /&gt;
&lt;br /&gt;
                   if (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) then&lt;br /&gt;
                      outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
                      outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
                   end&lt;br /&gt;
         if&lt;br /&gt;
         (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
         (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
         then&lt;br /&gt;
         outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
         outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' is incorrect&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47350</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47350"/>
		<updated>2016-04-04T22:32:49Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(player, commandName, typevehicle)&lt;br /&gt;
                if (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) then&lt;br /&gt;
                   outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
                   outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
             return&lt;br /&gt;
                end&lt;br /&gt;
      if&lt;br /&gt;
      (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
      then&lt;br /&gt;
      outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
      outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' is incorrect&amp;quot;)&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;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47349</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47349"/>
		<updated>2016-04-04T22:31:36Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
!#Please do not edit this example!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(player, commandName, typevehicle)&lt;br /&gt;
                if (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) then&lt;br /&gt;
                   outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
                   outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
             return&lt;br /&gt;
                end&lt;br /&gt;
      if&lt;br /&gt;
      (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
      then&lt;br /&gt;
      outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
      outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' is incorrect&amp;quot;)&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;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47348</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47348"/>
		<updated>2016-04-04T22:31:20Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The efficiency of this example - 100%&lt;br /&gt;
!#Please do not edit this example!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(player, commandName, typevehicle)&lt;br /&gt;
                if (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) then&lt;br /&gt;
                   outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
                   outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
             return&lt;br /&gt;
                end&lt;br /&gt;
      if&lt;br /&gt;
      (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
      then&lt;br /&gt;
      outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
      outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' is incorrect&amp;quot;)&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;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47347</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47347"/>
		<updated>2016-04-04T22:30:47Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example added by Uc.Setllings. The efficiency of this example - 100%&lt;br /&gt;
&lt;br /&gt;
!#Please do not edit this example!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(player, commandName, typevehicle)&lt;br /&gt;
                if (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) then&lt;br /&gt;
                   outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
                   outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
             return&lt;br /&gt;
                end&lt;br /&gt;
      if&lt;br /&gt;
      (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
      (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
      then&lt;br /&gt;
      outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
      outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' is incorrect&amp;quot;)&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;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47346</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47346"/>
		<updated>2016-04-04T22:28:42Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example added by Uc.Setllings. The efficiency of this example - 100%&lt;br /&gt;
&lt;br /&gt;
!#Please do not edit this example!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(player, commandName, typevehicle)&lt;br /&gt;
            if (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) then&lt;br /&gt;
               outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
         return&lt;br /&gt;
            end&lt;br /&gt;
    if&lt;br /&gt;
    (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
    then&lt;br /&gt;
    outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
    outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' is incorrect&amp;quot;)&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;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47345</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47345"/>
		<updated>2016-04-04T22:28:00Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
This function returns the amount of vehicles by the given type (see [[GetVehicleType]]) as an integer value.&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* '''Uc.Setlings''': Original code and idea&lt;br /&gt;
* '''Necktrox''': Code quality and performance edits&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 getVehiclesCountByType ( string vehicleType )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''vehicleType''': The vehicle type string (see list below).&lt;br /&gt;
&lt;br /&gt;
===Vehicle type list===&lt;br /&gt;
{{VehicleTypes}}&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns an ''integer'' with the count of the vehicles with the type (returns ''0'' if the type is not supported), otherwise returns ''nil''.&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(vehicleType)&lt;br /&gt;
    assert(type(vehicleType) == &amp;quot;string&amp;quot;, &amp;quot;expected string at argument 1, got &amp;quot;.. type(vehicleType))&lt;br /&gt;
&lt;br /&gt;
    local getVehicleType = getVehicleType -- Localize&lt;br /&gt;
    local vehicleList = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
    local vehicleCount = #vehicleList&lt;br /&gt;
    local typeCount = 0&lt;br /&gt;
&lt;br /&gt;
    for index = 1, vehicleCount do&lt;br /&gt;
        if getVehicleType(vehicleList[index]) == vehicleType then&lt;br /&gt;
            typeCount = typeCount + 1&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return typeCount&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example writes the amount of each vehicle type into the server log every minute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local types = {&lt;br /&gt;
    &amp;quot;Automobile&amp;quot;,&lt;br /&gt;
    &amp;quot;Plane&amp;quot;,&lt;br /&gt;
    &amp;quot;Bike&amp;quot;,&lt;br /&gt;
    &amp;quot;Helicopter&amp;quot;,&lt;br /&gt;
    &amp;quot;Boat&amp;quot;,&lt;br /&gt;
    &amp;quot;Train&amp;quot;,&lt;br /&gt;
    &amp;quot;Trailer&amp;quot;,&lt;br /&gt;
    &amp;quot;BMX&amp;quot;,&lt;br /&gt;
    &amp;quot;Monster Truck&amp;quot;,&lt;br /&gt;
    &amp;quot;Quad&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function outputVehicleCountToServerLog()&lt;br /&gt;
    for index, typeName in ipairs(types) do&lt;br /&gt;
        local count = getVehiclesCountByType(typeName)&lt;br /&gt;
        outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typeName, count))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
    function ()&lt;br /&gt;
        outputVehicleCountToServerLog()&lt;br /&gt;
        setTimer(outputVehicleCountToServerLog, 60e3, 0)&lt;br /&gt;
    end,&lt;br /&gt;
false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example 2==&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 writes the amount of vehicles on the specified type, and sends the results to the server console.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example added by Uc.Setllings. The efficiency of this example - 100%&lt;br /&gt;
&lt;br /&gt;
!#Please do not edit this example!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addCommandHandler(&amp;quot;amountvehicle&amp;quot;, function(player, commandName, typevehicle)&lt;br /&gt;
            if (typevehicle == nil) or (typevehicle == &amp;quot;&amp;quot;) then&lt;br /&gt;
               outputServerLog(&amp;quot;#ERROR! Type of vehicle was not entered!&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;Use the correct syntax in the console: amountvehicle [type vehicle]&amp;quot;)&lt;br /&gt;
         return&lt;br /&gt;
            end&lt;br /&gt;
    if&lt;br /&gt;
    (typevehicle == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
    (typevehicle == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
    then&lt;br /&gt;
    outputServerLog((&amp;quot;Amount of '%s' vehicles: %d&amp;quot;):format(typevehicle, getVehiclesCountByType(typevehicle)))&lt;br /&gt;
else&lt;br /&gt;
    outputServerLog(&amp;quot;#ERROR! The entered this syntax - '&amp;quot;..tostring(typevehicle)..&amp;quot;' is incorrect&amp;quot;)&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;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47336</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47336"/>
		<updated>2016-04-04T14:06:18Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
# This function is used to find out the number of vehicles by type.&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 getVehiclesCountByType(Type Vehicle)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
:  ''&lt;br /&gt;
  &lt;br /&gt;
  1. getVehiclesCountByType(&amp;quot;Automobile&amp;quot;) - The number of automobiles:&lt;br /&gt;
  2. getVehiclesCountByType(&amp;quot;Plane&amp;quot;) - The Number of aircraft:&lt;br /&gt;
  3. getVehiclesCountByType(&amp;quot;Bike&amp;quot;) - The Number of Bikes:&lt;br /&gt;
  4. getVehiclesCountByType(&amp;quot;Helicopter&amp;quot;) - The Number of Helicopters:&lt;br /&gt;
  5. getVehiclesCountByType(&amp;quot;Boat&amp;quot;) - The Number of Boats:&lt;br /&gt;
  6. getVehiclesCountByType(&amp;quot;Train&amp;quot;) - The Number of Trains:&lt;br /&gt;
  7. getVehiclesCountByType(&amp;quot;Trailer&amp;quot;) - The Number of Trailers:&lt;br /&gt;
  8. getVehiclesCountByType(&amp;quot;BMX&amp;quot;) - The Number of BMX:&lt;br /&gt;
  9. getVehiclesCountByType(&amp;quot;Monster Truck&amp;quot;) - The Number of Monster Trucks:&lt;br /&gt;
  10. getVehiclesCountByType(&amp;quot;Quad&amp;quot;) - The Number of Quad Bikes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== The correct types of vehicles: ==&lt;br /&gt;
&lt;br /&gt;
* '''Automobile''':&lt;br /&gt;
* '''Plane''':&lt;br /&gt;
* '''Bike''': Motorbikes:&lt;br /&gt;
* '''Helicopter''':&lt;br /&gt;
* '''Boat''':&lt;br /&gt;
* '''Train''':&lt;br /&gt;
* '''Trailer''': A trailer for a truck&lt;br /&gt;
* '''BMX''':&lt;br /&gt;
* '''Monster Truck''':&lt;br /&gt;
* '''Quad''': Quadbikes.&lt;br /&gt;
===Arguments===&lt;br /&gt;
* '''Type Vehicle''': Enter the desired type of vehicle to find out the total number of its.&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;&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(calltype)&lt;br /&gt;
               if&lt;br /&gt;
               (calltype == nil) or&lt;br /&gt;
               (calltype == &amp;quot;&amp;quot;)&lt;br /&gt;
               then&lt;br /&gt;
               outputServerLog(&amp;quot;ERROR in resource - '&amp;quot;..getResourceName(getThisResource())..&amp;quot;'&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;# Bad argument! [ function 'getVehiclesCountByType' cannot be performed! Reason: Attempting to call null string 'nil' ]&amp;quot;)&lt;br /&gt;
               end&lt;br /&gt;
               if&lt;br /&gt;
               (calltype == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
               then&lt;br /&gt;
           else&lt;br /&gt;
               outputServerLog(&amp;quot;ERROR in resource - '&amp;quot;..getResourceName(getThisResource())..&amp;quot;'&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;# Bad Argument! [ function 'getVehiclesCountByType' cannot execute! Reason: incorrectly entered string - '&amp;quot;..tostring(calltype)..&amp;quot;' ]&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;The correct values: 'Automobile', 'Plane', 'Bike', 'Helicopter', 'Boat', 'Train', 'Trailer', 'BMX', 'Monster Truck', 'Quad'&amp;quot;)&lt;br /&gt;
               end&lt;br /&gt;
&lt;br /&gt;
   if (calltype == &amp;quot;Automobile&amp;quot;) then&lt;br /&gt;
   CommandAutomobileAbuse = &amp;quot;true&amp;quot;&lt;br /&gt;
   countAutomobile = 0&lt;br /&gt;
   for i, allAutomobiles in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allAutomobiles) == &amp;quot;Automobile&amp;quot;) then&lt;br /&gt;
   countAutomobile = countAutomobile+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Automobiles - '&amp;quot;..countAutomobile..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countAutomobile = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Plane&amp;quot;) then&lt;br /&gt;
   countPlane = 0&lt;br /&gt;
   for i, allplanes in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allplanes) == &amp;quot;Plane&amp;quot;) then&lt;br /&gt;
   countPlane = countPlane+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Aircraft - '&amp;quot;..countPlane..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countPlane = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Bike&amp;quot;) then&lt;br /&gt;
   countBike = 0&lt;br /&gt;
   for i, allbikes in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allbikes) == &amp;quot;Bike&amp;quot;) then&lt;br /&gt;
   countBike = countBike+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Motorcycles - '&amp;quot;..countBike..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countBike = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Helicopter&amp;quot;) then&lt;br /&gt;
   countHelicopter = 0&lt;br /&gt;
   for i, allhelicopters in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allhelicopters) == &amp;quot;Helicopter&amp;quot;) then&lt;br /&gt;
   countHelicopter = countHelicopter+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Helicopters - '&amp;quot;..countHelicopter..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countHelicopter = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Boat&amp;quot;) then&lt;br /&gt;
   countBoat = 0&lt;br /&gt;
   for i, allboats in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allboats) == &amp;quot;Boat&amp;quot;) then&lt;br /&gt;
   countBoat = countBoat+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Boats - '&amp;quot;..countBoat..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countBoat = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Train&amp;quot;) then&lt;br /&gt;
   countTrain = 0&lt;br /&gt;
   for i, alltrains in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(alltrains) == &amp;quot;Train&amp;quot;) then&lt;br /&gt;
   countTrain = countTrain+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Trains - '&amp;quot;..countTrain..&amp;quot;'&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Trailer&amp;quot;) then&lt;br /&gt;
   countTrailer = 0&lt;br /&gt;
   for i, alltrailers in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(alltrailers) == &amp;quot;Trailer&amp;quot;) then&lt;br /&gt;
   countTrailer = countTrailer+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Trailers - '&amp;quot;..countTrailer..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countTrailer = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;BMX&amp;quot;) then&lt;br /&gt;
   countBMX = 0&lt;br /&gt;
   for i, allbmx in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allbmx) == &amp;quot;BMX&amp;quot;) then&lt;br /&gt;
   countBMX = countBMX+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of BMX - '&amp;quot;..countBMX..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countBMX = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Monster Truck&amp;quot;) then&lt;br /&gt;
   countMonsterTruck = 0&lt;br /&gt;
   for i, allmonstertrucks in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allmonstertrucks) == &amp;quot;Monster Truck&amp;quot;) then&lt;br /&gt;
   countMonsterTruck = countMonsterTruck+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Monster Trucks - '&amp;quot;..countMonsterTruck..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countMonsterTruck = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Quad&amp;quot;) then&lt;br /&gt;
   countQuad = 0&lt;br /&gt;
   for i, allquadbikes in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allquadbikes) == &amp;quot;Quad&amp;quot;) then&lt;br /&gt;
   countQuad = countQuad+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Quad Bikes - '&amp;quot;..countQuad..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countQuad = 0&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==1 Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example is when a resource is started learns the number of cars and the number of helicopters on the server.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler ( &amp;quot;onResourceStart&amp;quot;, getResourceRootElement(getThisResource()), function()&lt;br /&gt;
   getVehiclesCountByType(&amp;quot;Automobile&amp;quot;)&lt;br /&gt;
   getVehiclesCountByType(&amp;quot;Helicopter&amp;quot;)&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;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47335</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47335"/>
		<updated>2016-04-04T12:42:42Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
# This function is used to find out the number of vehicles by type.&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 getVehiclesCountByType(Type Vehicle)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
:  ''&lt;br /&gt;
  &lt;br /&gt;
  1. getVehiclesCountByType(&amp;quot;Automobile&amp;quot;) - The number of automobiles:&lt;br /&gt;
  2. getVehiclesCountByType(&amp;quot;Plane&amp;quot;) - The Number of aircraft:&lt;br /&gt;
  3. getVehiclesCountByType(&amp;quot;Bike&amp;quot;) - The Number of Bikes:&lt;br /&gt;
  4. getVehiclesCountByType(&amp;quot;Helicopter&amp;quot;) - The Number of Helicopters:&lt;br /&gt;
  5. getVehiclesCountByType(&amp;quot;Boat&amp;quot;) - The Number of Boats:&lt;br /&gt;
  6. getVehiclesCountByType(&amp;quot;Train&amp;quot;) - The Number of Trains:&lt;br /&gt;
  7. getVehiclesCountByType(&amp;quot;Trailer&amp;quot;) - The Number of Trailers:&lt;br /&gt;
  8. getVehiclesCountByType(&amp;quot;BMX&amp;quot;) - The Number of BMX:&lt;br /&gt;
  9. getVehiclesCountByType(&amp;quot;Monster Truck&amp;quot;) - The Number of Monster Trucks:&lt;br /&gt;
  10. getVehiclesCountByType(&amp;quot;Quad&amp;quot;) - The Number of Quad Bikes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== The correct types of vehicles: ==&lt;br /&gt;
&lt;br /&gt;
* '''Automobile''':&lt;br /&gt;
* '''Plane''':&lt;br /&gt;
* '''Bike''': Motorbikes:&lt;br /&gt;
* '''Helicopter''':&lt;br /&gt;
* '''Boat''':&lt;br /&gt;
* '''Train''':&lt;br /&gt;
* '''Trailer''': A trailer for a truck&lt;br /&gt;
* '''BMX''':&lt;br /&gt;
* '''Monster Truck''':&lt;br /&gt;
* '''Quad''': Quadbikes.&lt;br /&gt;
===Arguments===&lt;br /&gt;
* '''Type Vehicle''': Enter the desired type of vehicle to find out the total number of its.&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;&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(calltype)&lt;br /&gt;
               if&lt;br /&gt;
               (calltype ~= nil) or&lt;br /&gt;
               (calltype ~= &amp;quot;&amp;quot;)&lt;br /&gt;
               then&lt;br /&gt;
&lt;br /&gt;
               if&lt;br /&gt;
               (calltype == &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Train&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
               (calltype == &amp;quot;Quad&amp;quot;)&lt;br /&gt;
               then&lt;br /&gt;
&lt;br /&gt;
   if (calltype == &amp;quot;Automobile&amp;quot;) then&lt;br /&gt;
   CommandAutomobileAbuse = &amp;quot;true&amp;quot;&lt;br /&gt;
   countAutomobile = 0&lt;br /&gt;
   for i, allAutomobiles in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allAutomobiles) == &amp;quot;Automobile&amp;quot;) then&lt;br /&gt;
   countAutomobile = countAutomobile+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Automobiles - '&amp;quot;..countAutomobile..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countAutomobile = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Plane&amp;quot;) then&lt;br /&gt;
   countPlane = 0&lt;br /&gt;
   for i, allplanes in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allplanes) == &amp;quot;Plane&amp;quot;) then&lt;br /&gt;
   countPlane = countPlane+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Aircraft - '&amp;quot;..countPlane..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countPlane = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Bike&amp;quot;) then&lt;br /&gt;
   countBike = 0&lt;br /&gt;
   for i, allbikes in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allbikes) == &amp;quot;Bike&amp;quot;) then&lt;br /&gt;
   countBike = countBike+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Motorcycles - '&amp;quot;..countBike..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countBike = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Helicopter&amp;quot;) then&lt;br /&gt;
   countHelicopter = 0&lt;br /&gt;
   for i, allhelicopters in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allhelicopters) == &amp;quot;Helicopter&amp;quot;) then&lt;br /&gt;
   countHelicopter = countHelicopter+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Helicopters - '&amp;quot;..countHelicopter..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countHelicopter = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Boat&amp;quot;) then&lt;br /&gt;
   countBoat = 0&lt;br /&gt;
   for i, allboats in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allboats) == &amp;quot;Boat&amp;quot;) then&lt;br /&gt;
   countBoat = countBoat+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Boats - '&amp;quot;..countBoat..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countBoat = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Train&amp;quot;) then&lt;br /&gt;
   countTrain = 0&lt;br /&gt;
   for i, alltrains in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(alltrains) == &amp;quot;Train&amp;quot;) then&lt;br /&gt;
   countTrain = countTrain+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Trains - '&amp;quot;..countTrain..&amp;quot;'&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Trailer&amp;quot;) then&lt;br /&gt;
   countTrailer = 0&lt;br /&gt;
   for i, alltrailers in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(alltrailers) == &amp;quot;Trailer&amp;quot;) then&lt;br /&gt;
   countTrailer = countTrailer+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Trailers - '&amp;quot;..countTrailer..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countTrailer = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;BMX&amp;quot;) then&lt;br /&gt;
   countBMX = 0&lt;br /&gt;
   for i, allbmx in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allbmx) == &amp;quot;BMX&amp;quot;) then&lt;br /&gt;
   countBMX = countBMX+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of BMX - '&amp;quot;..countBMX..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countBMX = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Monster Truck&amp;quot;) then&lt;br /&gt;
   countMonsterTruck = 0&lt;br /&gt;
   for i, allmonstertrucks in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allmonstertrucks) == &amp;quot;Monster Truck&amp;quot;) then&lt;br /&gt;
   countMonsterTruck = countMonsterTruck+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Monster Trucks - '&amp;quot;..countMonsterTruck..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countMonsterTruck = 0&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Quad&amp;quot;) then&lt;br /&gt;
   countQuad = 0&lt;br /&gt;
   for i, allquadbikes in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allquadbikes) == &amp;quot;Quad&amp;quot;) then&lt;br /&gt;
   countQuad = countQuad+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Quad Bikes - '&amp;quot;..countQuad..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countQuad = 0&lt;br /&gt;
else&lt;br /&gt;
               outputServerLog(&amp;quot;ERROR in resource - '&amp;quot;..getResourceName(getThisResource())..&amp;quot;'&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;# Bad argument! [ function 'getVehiclesCountByType' cannot be performed! Reason: Attempting to call null string 'nil' ]&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
else&lt;br /&gt;
               outputServerLog(&amp;quot;ERROR in resource - '&amp;quot;..getResourceName(getThisResource())..&amp;quot;'&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;# Bad Argument! [ function 'getVehiclesCountByType' cannot execute! Reason: incorrectly entered string - '&amp;quot;..tostring(calltype)..&amp;quot;' ]&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;The correct values: 'Automobile', 'Plane', 'Bike', 'Helicopter', 'Boat', 'Train', 'Trailer', 'BMX', 'Monster Truck', 'Quad'&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==1 Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example is when a resource is started learns the number of cars and the number of helicopters on the server.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler ( &amp;quot;onResourceStart&amp;quot;, getResourceRootElement(getThisResource()), function()&lt;br /&gt;
   getVehiclesCountByType(&amp;quot;Automobile&amp;quot;)&lt;br /&gt;
   getVehiclesCountByType(&amp;quot;Helicopter&amp;quot;)&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;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47333</id>
		<title>GetVehiclesCountByType</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetVehiclesCountByType&amp;diff=47333"/>
		<updated>2016-04-03T23:28:54Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: Created page with &amp;quot;__NOTOC__ {{Useful Function}} # This function is used to find out the number of vehicles by type.  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; bool getVehiclesCountByType(Type Vehicle) &amp;lt;/syntaxhighlight&amp;gt;  ...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Useful Function}}&lt;br /&gt;
# This function is used to find out the number of vehicles by type.&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 getVehiclesCountByType(Type Vehicle)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
:  ''&lt;br /&gt;
  &lt;br /&gt;
  1. getVehiclesCountByType(&amp;quot;Automobile&amp;quot;) - The number of automobiles:&lt;br /&gt;
  2. getVehiclesCountByType(&amp;quot;Plane&amp;quot;) - The Number of aircraft:&lt;br /&gt;
  3. getVehiclesCountByType(&amp;quot;Bike&amp;quot;) - The Number of Bikes:&lt;br /&gt;
  4. getVehiclesCountByType(&amp;quot;Helicopter&amp;quot;) - The Number of Helicopters:&lt;br /&gt;
  5. getVehiclesCountByType(&amp;quot;Boat&amp;quot;) - The Number of Boats:&lt;br /&gt;
  6. getVehiclesCountByType(&amp;quot;Train&amp;quot;) - The Number of Trains:&lt;br /&gt;
  7. getVehiclesCountByType(&amp;quot;Trailer&amp;quot;) - The Number of Trailers:&lt;br /&gt;
  8. getVehiclesCountByType(&amp;quot;BMX&amp;quot;) - The Number of BMX:&lt;br /&gt;
  9. getVehiclesCountByType(&amp;quot;Monster Truck&amp;quot;) - The Number of Monster Trucks:&lt;br /&gt;
  10. getVehiclesCountByType(&amp;quot;Quad&amp;quot;) - The Number of Quad Bikes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== The correct types of vehicles: ==&lt;br /&gt;
&lt;br /&gt;
* '''Automobile''':&lt;br /&gt;
* '''Plane''':&lt;br /&gt;
* '''Bike''': Motorbikes:&lt;br /&gt;
* '''Helicopter''':&lt;br /&gt;
* '''Boat''':&lt;br /&gt;
* '''Train''':&lt;br /&gt;
* '''Trailer''': A trailer for a truck&lt;br /&gt;
* '''BMX''':&lt;br /&gt;
* '''Monster Truck''':&lt;br /&gt;
* '''Quad''': Quadbikes.&lt;br /&gt;
===Arguments===&lt;br /&gt;
* '''Type Vehicle''': Enter the desired type of vehicle to find out the total number of its.&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;&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getVehiclesCountByType(calltype)&lt;br /&gt;
               if&lt;br /&gt;
               (calltype == nil) or&lt;br /&gt;
               (calltype == &amp;quot;&amp;quot;)&lt;br /&gt;
               then&lt;br /&gt;
               outputServerLog(&amp;quot;ERROR in resource - '&amp;quot;..getResourceName(getThisResource())..&amp;quot;'&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;# Bad argument! [ function 'getVehiclesCountByType' cannot be performed! Reason: Attempting to call null string 'nil' ]&amp;quot;)&lt;br /&gt;
               end&lt;br /&gt;
               if&lt;br /&gt;
               (calltype ~= &amp;quot;Automobile&amp;quot;) or&lt;br /&gt;
               (calltype ~= &amp;quot;Plane&amp;quot;) or&lt;br /&gt;
               (calltype ~= &amp;quot;Bike&amp;quot;) or&lt;br /&gt;
               (calltype ~= &amp;quot;Helicopter&amp;quot;) or&lt;br /&gt;
               (calltype ~= &amp;quot;Boat&amp;quot;) or&lt;br /&gt;
               (calltype ~= &amp;quot;Train&amp;quot;) or&lt;br /&gt;
               (calltype ~= &amp;quot;Trailer&amp;quot;) or&lt;br /&gt;
               (calltype ~= &amp;quot;BMX&amp;quot;) or&lt;br /&gt;
               (calltype ~= &amp;quot;Monster Truck&amp;quot;) or&lt;br /&gt;
               (calltype ~= &amp;quot;Quad&amp;quot;)&lt;br /&gt;
               then&lt;br /&gt;
               outputServerLog(&amp;quot;ERROR in resource - '&amp;quot;..getResourceName(getThisResource())..&amp;quot;'&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;# Bad Argument! [ function 'getVehiclesCountByType' cannot execute! Reason: incorrectly entered string - '&amp;quot;..tostring(calltype)..&amp;quot;' ]&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;&amp;quot;)&lt;br /&gt;
               outputServerLog(&amp;quot;The correct values: 'Automobile', 'Plane', 'Bike', 'Helicopter', 'Boat', 'Train', 'Trailer', 'BMX', 'Monster Truck', 'Quad'&amp;quot;)&lt;br /&gt;
               end&lt;br /&gt;
&lt;br /&gt;
   if (calltype == &amp;quot;Automobile&amp;quot;) then&lt;br /&gt;
   CommandAutomobileAbuse = &amp;quot;true&amp;quot;&lt;br /&gt;
   countAutomobile = 0&lt;br /&gt;
   for i, allAutomobiles in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allAutomobiles) == &amp;quot;Automobile&amp;quot;) then&lt;br /&gt;
   countAutomobile = countAutomobile+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
   setTimer(&lt;br /&gt;
      function()&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Automobiles - '&amp;quot;..countAutomobile..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countAutomobile = 0&lt;br /&gt;
   end, 8250, 1)&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Plane&amp;quot;) then&lt;br /&gt;
   countPlane = 0&lt;br /&gt;
   for i, allplanes in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allplanes) == &amp;quot;Plane&amp;quot;) then&lt;br /&gt;
   countPlane = countPlane+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
   setTimer(&lt;br /&gt;
      function()&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Aircraft - '&amp;quot;..countPlane..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countPlane = 0&lt;br /&gt;
   end, 8250, 1)&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Bike&amp;quot;) then&lt;br /&gt;
   countBike = 0&lt;br /&gt;
   for i, allbikes in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allbikes) == &amp;quot;Bike&amp;quot;) then&lt;br /&gt;
   countBike = countBike+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
   setTimer(&lt;br /&gt;
      function()&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Motorcycles - '&amp;quot;..countBike..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countBike = 0&lt;br /&gt;
   end, 8250, 1)&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Helicopter&amp;quot;) then&lt;br /&gt;
   countHelicopter = 0&lt;br /&gt;
   for i, allhelicopters in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allhelicopters) == &amp;quot;Helicopter&amp;quot;) then&lt;br /&gt;
   countHelicopter = countHelicopter+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
   setTimer(&lt;br /&gt;
      function()&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Helicopters - '&amp;quot;..countHelicopter..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countHelicopter = 0&lt;br /&gt;
   end, 8250, 1)&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Boat&amp;quot;) then&lt;br /&gt;
   countBoat = 0&lt;br /&gt;
   for i, allboats in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allboats) == &amp;quot;Boat&amp;quot;) then&lt;br /&gt;
   countBoat = countBoat+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
   setTimer(&lt;br /&gt;
      function()&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Boats - '&amp;quot;..countBoat..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countBoat = 0&lt;br /&gt;
   end, 8250, 1)&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Train&amp;quot;) then&lt;br /&gt;
   countTrain = 0&lt;br /&gt;
   for i, alltrains in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(alltrains) == &amp;quot;Train&amp;quot;) then&lt;br /&gt;
   countTrain = countTrain+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
   setTimer(&lt;br /&gt;
      function()&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Trains - '&amp;quot;..countTrain..&amp;quot;'&amp;quot;)&lt;br /&gt;
   end, 8250, 1)&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Trailer&amp;quot;) then&lt;br /&gt;
   countTrailer = 0&lt;br /&gt;
   for i, alltrailers in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(alltrailers) == &amp;quot;Trailer&amp;quot;) then&lt;br /&gt;
   countTrailer = countTrailer+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
   setTimer(&lt;br /&gt;
      function()&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Trailers - '&amp;quot;..countTrailer..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countTrailer = 0&lt;br /&gt;
   end, 8250, 1)&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;BMX&amp;quot;) then&lt;br /&gt;
   countBMX = 0&lt;br /&gt;
   for i, allbmx in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allbmx) == &amp;quot;BMX&amp;quot;) then&lt;br /&gt;
   countBMX = countBMX+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
   setTimer(&lt;br /&gt;
      function()&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of BMX - '&amp;quot;..countBMX..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countBMX = 0&lt;br /&gt;
   end, 8250, 1)&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Monster Truck&amp;quot;) then&lt;br /&gt;
   countMonsterTruck = 0&lt;br /&gt;
   for i, allmonstertrucks in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allmonstertrucks) == &amp;quot;Monster Truck&amp;quot;) then&lt;br /&gt;
   countMonsterTruck = countMonsterTruck+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
   setTimer(&lt;br /&gt;
      function()&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Monster Trucks - '&amp;quot;..countMonsterTruck..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countMonsterTruck = 0&lt;br /&gt;
   end, 8250, 1)&lt;br /&gt;
&lt;br /&gt;
   elseif (calltype == &amp;quot;Quad&amp;quot;) then&lt;br /&gt;
   countQuad = 0&lt;br /&gt;
   for i, allquadbikes in ipairs(getElementsByType(&amp;quot;vehicle&amp;quot;)) do&lt;br /&gt;
   if (getVehicleType(allquadbikes) == &amp;quot;Quad&amp;quot;) then&lt;br /&gt;
   countQuad = countQuad+1&lt;br /&gt;
   end&lt;br /&gt;
   end&lt;br /&gt;
   setTimer(&lt;br /&gt;
      function()&lt;br /&gt;
      outputServerLog(&amp;quot;# The total number of Quad Bikes - '&amp;quot;..countQuad..&amp;quot;'&amp;quot;)&lt;br /&gt;
      countQuad = 0&lt;br /&gt;
   end, 8250, 1)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==1 Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example is when a resource is started learns the number of cars and the number of helicopters on the server.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler ( &amp;quot;onResourceStart&amp;quot;, getResourceRootElement(getThisResource()), function()&lt;br /&gt;
   getVehiclesCountByType(&amp;quot;Automobile&amp;quot;)&lt;br /&gt;
   getVehiclesCountByType(&amp;quot;Helicopter&amp;quot;)&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;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Template:Server_client_function&amp;diff=47332</id>
		<title>Template:Server client function</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Template:Server_client_function&amp;diff=47332"/>
		<updated>2016-04-03T21:55:38Z</updated>

		<summary type="html">&lt;p&gt;Uc.Setlings: Replaced content with &amp;quot;1&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;1&lt;/div&gt;</summary>
		<author><name>Uc.Setlings</name></author>
	</entry>
</feed>