https://wiki.multitheftauto.com/api.php?action=feedcontributions&user=Booo&feedformat=atomMulti Theft Auto: Wiki - User contributions [en]2024-03-28T20:27:46ZUser contributionsMediaWiki 1.39.3https://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40049GetTeamWithFewestPlayers2014-06-21T23:27:07Z<p>Booo: Undo revision 40048 by Booo (talk)</p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
{{Needs_Checking|This page needs to be locked or lxjf needs to be banned }}<br />
__NOTOC__<br />
This function compares number of players in two teams specifed and returns the team with less players.<br />
'''Note:''' If both teams have the same amount of players, then the first one will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] team with less players, ''false'' if invalid arguments were specified.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40048GetTeamWithFewestPlayers2014-06-21T23:26:50Z<p>Booo: Undo revision 40047 by Booo (talk)</p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
{{Needs_Checking|This page needs to be locked or lxjf needs to be banned. }}<br />
__NOTOC__<br />
This function compares number of players in two teams specifed and returns the team with less players.<br />
'''Note:''' If both teams have the same amount of players, then the first one will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] team with less players, ''false'' if invalid arguments were specified.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40047GetTeamWithFewestPlayers2014-06-21T23:26:37Z<p>Booo: Undo revision 40046 by Booo (talk)</p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
{{Needs_Checking|This page needs to be locked or lxjf needs to be banned }}<br />
__NOTOC__<br />
This function compares number of players in two teams specifed and returns the team with less players.<br />
'''Note:''' If both teams have the same amount of players, then the first one will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] team with less players, ''false'' if invalid arguments were specified.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40046GetTeamWithFewestPlayers2014-06-21T23:26:26Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
{{Needs_Checking|This page needs to be locked or lxjf needs to be banned. }}<br />
__NOTOC__<br />
This function compares number of players in two teams specifed and returns the team with less players.<br />
'''Note:''' If both teams have the same amount of players, then the first one will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] team with less players, ''false'' if invalid arguments were specified.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40045GetTeamWithFewestPlayers2014-06-21T23:26:15Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
{{Needs_Checking|This page needs to be locked or lxjf needs to be banned }}<br />
__NOTOC__<br />
This function compares number of players in two teams specifed and returns the team with less players.<br />
'''Note:''' If both teams have the same amount of players, then the first one will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] team with less players, ''false'' if invalid arguments were specified.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40044GetTeamWithFewestPlayers2014-06-21T23:25:58Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
{{Needs_Checking|This page needs to be locked or xjf needs to be banned }}<br />
__NOTOC__<br />
This function compares number of players in two teams specifed and returns the team with less players.<br />
'''Note:''' If both teams have the same amount of players, then the first one will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] team with less players, ''false'' if invalid arguments were specified.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40043GetTeamWithFewestPlayers2014-06-21T23:25:12Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
{{Needs_Checking|This page needs to be locked or lxjf needs to be banned}}<br />
__NOTOC__<br />
This function compares number of players in two teams specifed and returns the team with less players.<br />
'''Note:''' If both teams have the same amount of players, then the first one will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] team with less players, ''false'' if invalid arguments were specified.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40042GetTeamWithFewestPlayers2014-06-21T23:24:07Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
<br />
__NOTOC__<br />
This function compares number of players in two teams specifed and returns the team with less players.<br />
'''Note:''' If both teams have the same amount of players, then the first one will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] team with less players, ''false'' if invalid arguments were specified.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40036GetTeamWithFewestPlayers2014-06-21T21:49:56Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
<br />
__NOTOC__<br />
This function compares number of players in two teams specifed and returns the team with less players.<br />
'''Note:''' If both teams have the same amount of players, then the first one will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] team with less players, ''false'' if invalid arguments were specified.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40035GetTeamWithFewestPlayers2014-06-21T21:48:55Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
<br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40028GetTeamWithFewestPlayers2014-06-21T18:07:36Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
<br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
[lua]<br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40027GetTeamWithFewestPlayers2014-06-21T18:07:16Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
<br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
[lua]<br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40026GetTeamWithFewestPlayers2014-06-21T18:06:55Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
<br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40001GetTeamWithFewestPlayers2014-06-21T10:31:06Z<p>Booo: Go Create your New page with your new functions ></p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
<br />
__NOTOC__<br />
This function compares number of players in two teams specifed and returns the team with less players.<br />
'''Note:''' If both teams have the same amount of players, then the first one will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] team with less players, ''false'' if invalid arguments were specified.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=40000GetTeamWithFewestPlayers2014-06-21T10:25:52Z<p>Booo: Go Create your New page with your new functions ></p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
<br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=39997GetTeamWithFewestPlayers2014-06-21T10:03:53Z<p>Booo: Undo revision 39996 by AlexTMjugador (talk)</p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
<br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=39995GetTeamWithFewestPlayers2014-06-21T09:43:42Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
<br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=39987GetTeamWithFewestPlayers2014-06-20T14:14:10Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
<br />
<div style="background: #FFCFCF; padding: 5px; font-weight:bold; border: 1px dotted #AAAAAA;padding:10px;margin:10px;"><center><br />
<font color="#0066cc" size="5">Ixjf > stop edit my code nob , and go create your page !</font><br />
</center></div><br />
<br />
<br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=39986GetTeamWithFewestPlayers2014-06-20T14:13:35Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
<br />
<div style="background: #FFCFCF; padding: 5px; font-weight:bold; border: 1px dotted #AAAAAA;padding:10px;margin:10px;"><center><br />
<font color="#0066cc" size="5">stop edit my Code Nob , and go create your page !</font><br />
</center></div><br />
<br />
<br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=39985GetTeamWithFewestPlayers2014-06-20T14:11:12Z<p>Booo: Undo revision 39984 by Booo (talk)</p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=39984GetTeamWithFewestPlayers2014-06-20T14:10:56Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count , then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=39983GetTeamWithFewestPlayers2014-06-20T14:10:29Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=39982GetTeamWithFewestPlayers2014-06-20T14:09:54Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getFewPlayersOnTeams ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getFewPlayersOnTeams(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getfewPlayersOnTeams(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=39956GetTeamWithFewestPlayers2014-06-18T16:40:43Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getTeamWithFewestPlayers ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getTeamWithFewestPlayers(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getTeamWithFewestPlayers(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=39955GetTeamWithFewestPlayers2014-06-18T16:37:44Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getFewPlayersOnTeams ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getFewPlayersOnTeams(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getfewPlayersOnTeams(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&diff=39583Template:Useful Functions2014-05-23T19:25:17Z<p>Booo: </p>
<hr />
<div>*[[callClientFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any clientside function from the server's side.</span><br />
*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span><br />
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span><br />
*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span><br />
*[[convertNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts large numbers and adds commas to it. (Example: 100000 -> 100,000)</span><br />
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span><br />
*[[dxDrawAnimWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Create Animated Dx Window</span><br />
*[[dxDrawCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a circle shape on the screen.</span><br />
*[[dxDrawColorText]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a dx text with #RRGGBB color codes support.</span><br />
*[[dxDrawGifImage]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function simulates the effect of a GIF image by using image sprites.</span><br />
*[[dxDrawImage3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D image.</span><br />
*[[dxDrawPartialCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a partial circle shape on the screen.</span><br />
*[[dxDrawRectangle3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D rectangle.</span><br />
*[[dxDrawEmptyRec]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This funcions draws an empty rectangle.</span><br />
*[[dxGetFontSizeFromHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculate a font size from given height for dxDraw.</span><br />
*[[dxGetRealFontHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Accurately measures the pixel height of a font.</span><br />
*[[findRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes two points and returns the direction from point A to point B.</span><br />
*[[FormatDate]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Formats a date on the basis of a format string and returns it.</span><br />
*[[GenerateString]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can generate a random string with any characters.</span><br />
*[[getFewPlayersOnTeams]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's few Players.!</span><br />
*[[getAge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span><br />
*[[getAlivePlayers (Client)|getAlivePlayers]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns all the alive players by a client side, so you can store them into a Gridlist or something like that, faster.</span><br />
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span><br />
*[[getBoundControls]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a list of control names that are bound to the specified key.</span><br />
*[[getCursorMoveOn]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks in which way the cursor is currently moving.</span><br />
*[[getDistanceBetweenPointAndSegment2D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes point coordinates and line (a segment) starting and ending coordinates. It returns the shortest distance between the point and the line.</span><br />
*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span><br />
*[[getElementsInDimension]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in the specified dimension.</span><br />
*[[getElementsWithinMarker]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in a markers colshape.</span><br />
*[[getJetpackWeaponsEnabled]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of enabled weapons usable on a jetpack.</span><br />
*[[getKeyFromValueInTable]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns the key of the specified value in a table.</span><br />
*[[getOffsetFromXYZ]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations.</span><br />
*[[getOnlineAdmins]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will give the online admins.</span><br />
*[[getOnlineStaff]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all online staff, names separated by two spaces.</span><br />
*[[getPlayersByData]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets players who have data name you passed to it.</span><br />
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span><br />
*[[getPlayersInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets all the players in a photograph.</span><br />
*[[getPlayerFromSerial]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets an online player from their serial.</span><br />
*[[getPlayerAcls]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets all ACL's group on player.</span><br />
*[[getPlayerAllGroups]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets groups from Player.</span><br />
*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span><br />
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
*[[getResourceScripts]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource scripts.</span><br />
*[[getRGColorFromPercentage]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">»This function returns two integers representing Red and Green colors according to the percentage requested.</span><br />
*[[getScreenRotationFromWorldPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a screen relative rotation to a world position. The returned rotation can be used in dxDrawImage</span><br />
*[[getTeamFromColor]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's color. (Related to: [[getTeamFromName]])</span><br />
*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the UNIX timestamp.</span><br />
*[[getValidVehicleModels]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table containing valid MTA Vehicle models.</span><br />
*[[getXMLNodes]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all children of a node</span><br />
*[[getVehicleRespawnPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get the spawn position of a vehicle.</span><br />
*[[guiComboBoxAdjustHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Adjusts the combobox to have a correct height.</span><br />
*[[GuiMoveRightToCenter]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function move it Gui right to center.!</span><br />
*[[IfElse]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns one of two values based on a boolean expression.</span><br />
*[[isElementInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element was in the player's camera picture.</span><br />
*[[isElementInRange]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to check is the element's range to the main point is smaller than (or as big as) the maximum range.</span><br />
*[[isElementMoving]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element is moving.</span><br />
*[[isElementTeam]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if element is team.</span><br />
*[[isElementWithinAColShape]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if the [[element]] is in a [[colshape]].</span><br />
*[[isPedAiming]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if a ped is aiming.</span><br />
*[[isPlayerInACL]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will check to see if a player element is in an ACL group.</span><br />
*[[isPlayerInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if the player in the team.</span><br />
*[[isPlayersInVehicle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if there any players in a Vehicle.</span><br />
*[[isLeapYear]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Checks if the given year is a leap year.</span><br />
*[[isVehicleOnRoof]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether vehicle is on roof.</span><br />
*[[isVehicleEmpty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether a vehicle is empty.</span><br />
*[[isSoundFinished]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks sound finished or not.</span><br />
*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span><br />
*[[mathNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function is a workaround for the clientside floating-point precision of 24-bits</span><br />
*[[math.percent]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Return the porcent from one number.</span><br />
*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span><br />
*[[multi_check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks one element to many, handy and clean.</span><br />
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span><br />
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span><br />
*[[secondsToTimeDesc]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a plain seconds-integer into a user-friendly time description.</span><br />
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span><br />
*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span><br />
*[[setVehicleGravityPoint]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.</span><br />
*[[setAccountName]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function is used to change existing accounts name.</span><br />
*[[smoothMoveCamera]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function allows you to create a cinematic camera flight.<br />
*[[string.count]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function counts a text from a text.</span><br />
*[[string.explode]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function splits a string at a given separator pattern and returns a table with the pieces.</span><br />
*[[switch]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allow the value of a variable or expression to control the flow of program execution via a multiway branch.</span><br />
*[[table.copy]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function copies a whole table and all the tables in that table.</span><br />
*[[table.compare]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if both tables is equal. </span><br />
*[[table.empty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check is empty table or not.</span><br />
*[[table.map]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.</span><br />
*[[table.merge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Merges two or more tables in the first.</span><br />
*[[table.random]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function retrieves a random variable from a table.</span><br />
*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span><br />
*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span><br />
*[[var dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function outputs information about one or more variables using outputConsole()</span><br />
*[[wavelengthToRGBA]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a phisical wavelength of light to a RGBA color.</span><br />
[[Category:Useful Functions]]</div>Booohttps://wiki.multitheftauto.com/index.php?title=IsVehicleOccupied&diff=39582IsVehicleOccupied2014-05-23T19:23:11Z<p>Booo: Created page with "{{Useful Function}} <lowercasetitle></lowercasetitle> __NOTOC__ This function check if any players in the vehicle. ==Syntax== <syntaxhighlight lang="lua">bool isPlayersInVehicle( element ve..."</p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle></lowercasetitle><br />
__NOTOC__<br />
This function check if any players in the vehicle.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool isPlayersInVehicle( element vehicle)</syntaxhighlight><br />
<br />
===Required Arguments===<br />
* '''vehicle''': The vehicle you want check if players in it.<br />
<br />
===Returns===<br />
Return true if there any players in vehicle, false otherwise.<br />
<br />
==Code==<br />
<section name="Serverside Script" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
function isPlayersInVehicle(Vehicle)<br />
if isElement(Vehicle) and getElementType(Vehicle) == "vehicle" then<br />
local occupants = getVehicleOccupants(Vehicle)<br />
<br />
if occupants then<br />
for seat, occupant in pairs(occupants) do<br />
if occupant then<br />
return true<br />
break<br />
end<br />
end<br />
end<br />
<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This example checks if there any players in Vehicle.<br />
<syntaxhighlight lang="lua"><br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=Useful_Functions&diff=39282Useful Functions2014-04-08T14:55:26Z<p>Booo: </p>
<hr />
<div><pageclass class="#228B22"></pageclass><br />
{{Adding_Pages_to_Categories_and_Templates}}<br />
<br />
This page list's functions that are not included in the server or the client, but are still useful.<br />
<br/><br />
{{Useful_Functions}}<br />
[[ES:Funciones Útiles]]<br />
[[ru:Useful Functions]]<br />
[[de:Nützliche_Funktionen]]<br />
[[Ar:وظائف مفيدة]]</div>Booohttps://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&diff=39281Template:Useful Functions2014-04-08T14:50:04Z<p>Booo: </p>
<hr />
<div>*[[callClientFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any clientside function from the server's side.</span><br />
*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span><br />
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span><br />
*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span><br />
*[[convertNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts large numbers and adds commas to it. (Example: 100000 -> 100,000)</span><br />
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span><br />
*[[dxDrawAnimWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Create Animated Dx Window</span><br />
*[[dxDrawCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a circle shape on the screen.</span><br />
*[[dxDrawColorText]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a dx text with #RRGGBB color codes support.</span><br />
*[[dxDrawGifImage]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function simulates the effect of a GIF image by using image sprites.</span><br />
*[[dxDrawImage3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D image.</span><br />
*[[dxDrawPartialCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a partial circle shape on the screen.</span><br />
*[[dxDrawRectangle3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D rectangle.</span><br />
*[[dxDrawEmptyRec]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This funcions draws an empty rectangle.</span><br />
*[[dxGetFontSizeFromHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculate a font size from given height for dxDraw.</span><br />
*[[dxGetRealFontHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Accurately measures the pixel height of a font.</span><br />
*[[findRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes two points and returns the direction from point A to point B.</span><br />
*[[FormatDate]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Formats a date on the basis of a format string and returns it.</span><br />
*[[GenerateString]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can generate a random string with any characters.</span><br />
*[[getFewPlayersOnTeams]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's few Players.!</span><br />
*[[getPlayerAllGroups]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a groups from Player.</span><br />
*[[getAge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span><br />
*[[getAlivePlayers (Client)|getAlivePlayers]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns all the alive players by a client side, so you can store them into a Gridlist or something like that, faster.</span><br />
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span><br />
*[[getBoundControls]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a list of control names that are bound to the specified key.</span><br />
*[[getCursorMoveOn]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks in which way the cursor is currently moving.</span><br />
*[[getDistanceBetweenPointAndSegment2D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes point coordinates and line (a segment) starting and ending coordinates. It returns the shortest distance between the point and the line.</span><br />
*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span><br />
*[[getElementsInDimension]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in the specified dimension.</span><br />
*[[getElementsWithinMarker]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in a markers colshape.</span><br />
*[[getJetpackWeaponsEnabled]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of enabled weapons usable on a jetpack.</span><br />
*[[getKeyFromValueInTable]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns the key of the specified value in a table.</span><br />
*[[getOffsetFromXYZ]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations.</span><br />
*[[getOnlineAdmins]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will give the online admins.</span><br />
*[[getOnlineStaff]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all online staff, names separated by two spaces.</span><br />
*[[getPlayersByData]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets players who have data name you passed to it.</span><br />
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span><br />
*[[getPlayersInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets all the players in a photograph.</span><br />
*[[getPlayerFromSerial]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets an online player from their serial.</span><br />
*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span><br />
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
*[[getResourceScripts]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource scripts.</span><br />
*[[getRGColorFromPercentage]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">»This function returns two integers representing Red and Green colors according to the percentage requested.</span><br />
*[[getScreenRotationFromWorldPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a screen relative rotation to a world position. The returned rotation can be used in dxDrawImage</span><br />
*[[getTeamFromColor]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's color. (Related to: [[getTeamFromName]])</span><br />
*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the UNIX timestamp.</span><br />
*[[getValidVehicleModels]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table containing valid MTA Vehicle models.</span><br />
*[[getXMLNodes]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all children of a node</span><br />
*[[getVehicleRespawnPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get the spawn position of a vehicle.</span><br />
*[[guiComboBoxAdjustHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Adjusts the combobox to have a correct height.</span><br />
*[[GuiMoveRightToCenter]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function move it Gui right to center.!</span><br />
*[[IfElse]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns one of two values based on a boolean expression.</span><br />
*[[isElementInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element was in the player's camera picture.</span><br />
*[[isElementInRange]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to check is the element's range to the main point is smaller than (or as big as) the maximum range.</span><br />
*[[isElementMoving]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element is moving.</span><br />
*[[isElementTeam]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if element is team.</span><br />
*[[isElementWithinAColShape]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if the [[element]] is in a [[colshape]].</span><br />
*[[isPedAiming]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if a ped is aiming.</span><br />
*[[isPlayerInACL]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will check to see if a player element is in an ACL group.</span><br />
*[[isPlayerInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if the player in the team.</span><br />
*[[isLeapYear]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Checks if the given year is a leap year.</span><br />
*[[isVehicleOnRoof]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether vehicle is on roof.</span><br />
*[[isVehicleEmpty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether a vehicle is empty.</span><br />
*[[isSoundFinished]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks sound finished or not.</span><br />
*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span><br />
*[[mathNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function is a workaround for the clientside floating-point precision of 24-bits</span><br />
*[[math.percent]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Return the porcent from one number.</span><br />
*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span><br />
*[[multi_check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks one element to many, handy and clean.</span><br />
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span><br />
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span><br />
*[[secondsToTimeDesc]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a plain seconds-integer into a user-friendly time description.</span><br />
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span><br />
*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span><br />
*[[setVehicleGravityPoint]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.</span><br />
*[[smoothMoveCamera]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function allows you to create a cinematic camera flight.<br />
*[[string.count]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function counts a text from a text.</span><br />
*[[string.explode]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function splits a string at a given separator pattern and returns a table with the pieces.</span><br />
*[[switch]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allow the value of a variable or expression to control the flow of program execution via a multiway branch.</span><br />
*[[table.copy]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function copies a whole table and all the tables in that table.</span><br />
*[[table.compare]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if both tables is equal. </span><br />
*[[table.empty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check is empty table or not.</span><br />
*[[table.map]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.</span><br />
*[[table.merge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Merges two or more tables in the first.</span><br />
*[[table.random]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function retrieves a random variable from a table.</span><br />
*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span><br />
*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span><br />
*[[var dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function outputs information about one or more variables using outputConsole()</span><br />
*[[wavelengthToRGBA]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a phisical wavelength of light to a RGBA color.</span><br />
[[Category:Useful Functions]]</div>Booohttps://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&diff=39279Template:Useful Functions2014-04-08T14:36:44Z<p>Booo: </p>
<hr />
<div>*[[callClientFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any clientside function from the server's side.</span><br />
*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span><br />
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span><br />
*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span><br />
*[[convertNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts large numbers and adds commas to it. (Example: 100000 -> 100,000)</span><br />
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span><br />
*[[dxDrawAnimWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Create Animated Dx Window</span><br />
*[[dxDrawCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a circle shape on the screen.</span><br />
*[[dxDrawColorText]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a dx text with #RRGGBB color codes support.</span><br />
*[[dxDrawGifImage]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function simulates the effect of a GIF image by using image sprites.</span><br />
*[[dxDrawImage3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D image.</span><br />
*[[dxDrawPartialCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a partial circle shape on the screen.</span><br />
*[[dxDrawRectangle3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D rectangle.</span><br />
*[[dxDrawEmptyRec]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This funcions draws an empty rectangle.</span><br />
*[[dxGetFontSizeFromHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculate a font size from given height for dxDraw.</span><br />
*[[dxGetRealFontHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Accurately measures the pixel height of a font.</span><br />
*[[findRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes two points and returns the direction from point A to point B.</span><br />
*[[FormatDate]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Formats a date on the basis of a format string and returns it.</span><br />
*[[GenerateString]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can generate a random string with any characters.</span><br />
*[[getFewPlayersOnTeams]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's few Players.!</span><br />
*[[getPlayerAllGroups]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a groups from Player.</span><br />
*[[getAge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span><br />
*[[getAlivePlayers (Client)|getAlivePlayers]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns all the alive players by a client side, so you can store them into a Gridlist or something like that, faster.</span><br />
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span><br />
*[[getBoundControls]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a list of control names that are bound to the specified key.</span><br />
*[[getCursorMoveOn]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks in which way the cursor is currently moving.</span><br />
*[[getDistanceBetweenPointAndSegment2D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes point coordinates and line (a segment) starting and ending coordinates. It returns the shortest distance between the point and the line.</span><br />
*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span><br />
*[[getElementsInDimension]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in the specified dimension.</span><br />
*[[getElementsWithinMarker]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in a markers colshape.</span><br />
*[[getJetpackWeaponsEnabled]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of enabled weapons usable on a jetpack.</span><br />
*[[getKeyFromValueInTable]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns the key of the specified value in a table.</span><br />
*[[getOffsetFromXYZ]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations.</span><br />
*[[getOnlineAdmins]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will give the online admins.</span><br />
*[[getOnlineStaff]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all online staff, names separated by two spaces.</span><br />
*[[getPlayersByData]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets players who have data name you passed to it.</span><br />
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span><br />
*[[getPlayersInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets all the players in a photograph.</span><br />
*[[getPlayerFromSerial]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets an online player from their serial.</span><br />
*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span><br />
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
*[[getResourceScripts]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource scripts.</span><br />
*[[getRGColorFromPercentage]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">»This function returns two integers representing Red and Green colors according to the percentage requested.</span><br />
*[[getScreenRotationFromWorldPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a screen relative rotation to a world position. The returned rotation can be used in dxDrawImage</span><br />
*[[getTeamFromColor]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's color. (Related to: [[getTeamFromName]])</span><br />
*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the UNIX timestamp.</span><br />
*[[getValidVehicleModels]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table containing valid MTA Vehicle models.</span><br />
*[[getXMLNodes]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all children of a node</span><br />
*[[getVehicleRespawnPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get the spawn position of a vehicle.</span><br />
*[[guiComboBoxAdjustHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Adjusts the combobox to have a correct height.</span><br />
*[[IfElse]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns one of two values based on a boolean expression.</span><br />
*[[isElementInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element was in the player's camera picture.</span><br />
*[[isElementInRange]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to check is the element's range to the main point is smaller than (or as big as) the maximum range.</span><br />
*[[isElementMoving]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element is moving.</span><br />
*[[isElementTeam]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if element is team.</span><br />
*[[isElementWithinAColShape]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if the [[element]] is in a [[colshape]].</span><br />
*[[isPedAiming]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if a ped is aiming.</span><br />
*[[isPlayerInACL]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will check to see if a player element is in an ACL group.</span><br />
*[[isPlayerInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if the player in the team.</span><br />
*[[isLeapYear]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Checks if the given year is a leap year.</span><br />
*[[isVehicleOnRoof]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether vehicle is on roof.</span><br />
*[[isVehicleEmpty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether a vehicle is empty.</span><br />
*[[isSoundFinished]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks sound finished or not.</span><br />
*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span><br />
*[[mathNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function is a workaround for the clientside floating-point precision of 24-bits</span><br />
*[[math.percent]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Return the porcent from one number.</span><br />
*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span><br />
*[[multi_check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks one element to many, handy and clean.</span><br />
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span><br />
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span><br />
*[[secondsToTimeDesc]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a plain seconds-integer into a user-friendly time description.</span><br />
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span><br />
*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span><br />
*[[setVehicleGravityPoint]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.</span><br />
*[[smoothMoveCamera]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function allows you to create a cinematic camera flight.<br />
*[[string.count]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function counts a text from a text.</span><br />
*[[string.explode]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function splits a string at a given separator pattern and returns a table with the pieces.</span><br />
*[[switch]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allow the value of a variable or expression to control the flow of program execution via a multiway branch.</span><br />
*[[table.copy]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function copies a whole table and all the tables in that table.</span><br />
*[[table.compare]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if both tables is equal. </span><br />
*[[table.empty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check is empty table or not.</span><br />
*[[table.map]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.</span><br />
*[[table.merge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Merges two or more tables in the first.</span><br />
*[[table.random]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function retrieves a random variable from a table.</span><br />
*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span><br />
*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span><br />
*[[var dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function outputs information about one or more variables using outputConsole()</span><br />
*[[wavelengthToRGBA]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a phisical wavelength of light to a RGBA color.</span><br />
[[Category:Useful Functions]]</div>Booohttps://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&diff=39278Template:Useful Functions2014-04-08T14:35:57Z<p>Booo: </p>
<hr />
<div>*[[callClientFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any clientside function from the server's side.</span><br />
*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span><br />
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span><br />
*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span><br />
*[[convertNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts large numbers and adds commas to it. (Example: 100000 -> 100,000)</span><br />
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span><br />
*[[dxDrawAnimWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Create Animated Dx Window</span><br />
*[[dxDrawCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a circle shape on the screen.</span><br />
*[[dxDrawColorText]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a dx text with #RRGGBB color codes support.</span><br />
*[[dxDrawGifImage]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function simulates the effect of a GIF image by using image sprites.</span><br />
*[[dxDrawImage3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D image.</span><br />
*[[dxDrawPartialCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a partial circle shape on the screen.</span><br />
*[[dxDrawRectangle3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D rectangle.</span><br />
*[[dxDrawEmptyRec]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This funcions draws an empty rectangle.</span><br />
*[[dxGetFontSizeFromHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculate a font size from given height for dxDraw.</span><br />
*[[dxGetRealFontHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Accurately measures the pixel height of a font.</span><br />
*[[FewPlayersOnTeams]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's few Players.!</span><br />
*[[findRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes two points and returns the direction from point A to point B.</span><br />
*[[FormatDate]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Formats a date on the basis of a format string and returns it.</span><br />
*[[GenerateString]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can generate a random string with any characters.</span><br />
*[[getPlayerAllGroups]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a groups from Player.</span><br />
*[[getAge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span><br />
*[[getAlivePlayers (Client)|getAlivePlayers]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns all the alive players by a client side, so you can store them into a Gridlist or something like that, faster.</span><br />
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span><br />
*[[getBoundControls]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a list of control names that are bound to the specified key.</span><br />
*[[getCursorMoveOn]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks in which way the cursor is currently moving.</span><br />
*[[getDistanceBetweenPointAndSegment2D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes point coordinates and line (a segment) starting and ending coordinates. It returns the shortest distance between the point and the line.</span><br />
*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span><br />
*[[getElementsInDimension]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in the specified dimension.</span><br />
*[[getElementsWithinMarker]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in a markers colshape.</span><br />
*[[getJetpackWeaponsEnabled]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of enabled weapons usable on a jetpack.</span><br />
*[[getKeyFromValueInTable]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns the key of the specified value in a table.</span><br />
*[[getOffsetFromXYZ]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations.</span><br />
*[[getOnlineAdmins]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will give the online admins.</span><br />
*[[getOnlineStaff]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all online staff, names separated by two spaces.</span><br />
*[[getPlayersByData]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets players who have data name you passed to it.</span><br />
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span><br />
*[[getPlayersInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets all the players in a photograph.</span><br />
*[[getPlayerFromSerial]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets an online player from their serial.</span><br />
*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span><br />
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
*[[getResourceScripts]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource scripts.</span><br />
*[[getRGColorFromPercentage]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">»This function returns two integers representing Red and Green colors according to the percentage requested.</span><br />
*[[getScreenRotationFromWorldPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a screen relative rotation to a world position. The returned rotation can be used in dxDrawImage</span><br />
*[[getTeamFromColor]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's color. (Related to: [[getTeamFromName]])</span><br />
*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the UNIX timestamp.</span><br />
*[[getValidVehicleModels]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table containing valid MTA Vehicle models.</span><br />
*[[getXMLNodes]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all children of a node</span><br />
*[[getVehicleRespawnPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get the spawn position of a vehicle.</span><br />
*[[guiComboBoxAdjustHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Adjusts the combobox to have a correct height.</span><br />
*[[IfElse]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns one of two values based on a boolean expression.</span><br />
*[[isElementInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element was in the player's camera picture.</span><br />
*[[isElementInRange]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to check is the element's range to the main point is smaller than (or as big as) the maximum range.</span><br />
*[[isElementMoving]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element is moving.</span><br />
*[[isElementTeam]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if element is team.</span><br />
*[[isElementWithinAColShape]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if the [[element]] is in a [[colshape]].</span><br />
*[[isPedAiming]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if a ped is aiming.</span><br />
*[[isPlayerInACL]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will check to see if a player element is in an ACL group.</span><br />
*[[isPlayerInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if the player in the team.</span><br />
*[[isLeapYear]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Checks if the given year is a leap year.</span><br />
*[[isVehicleOnRoof]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether vehicle is on roof.</span><br />
*[[isVehicleEmpty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether a vehicle is empty.</span><br />
*[[isSoundFinished]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks sound finished or not.</span><br />
*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span><br />
*[[mathNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function is a workaround for the clientside floating-point precision of 24-bits</span><br />
*[[math.percent]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Return the porcent from one number.</span><br />
*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span><br />
*[[multi_check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks one element to many, handy and clean.</span><br />
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span><br />
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span><br />
*[[secondsToTimeDesc]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a plain seconds-integer into a user-friendly time description.</span><br />
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span><br />
*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span><br />
*[[setVehicleGravityPoint]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.</span><br />
*[[smoothMoveCamera]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function allows you to create a cinematic camera flight.<br />
*[[string.count]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function counts a text from a text.</span><br />
*[[string.explode]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function splits a string at a given separator pattern and returns a table with the pieces.</span><br />
*[[switch]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allow the value of a variable or expression to control the flow of program execution via a multiway branch.</span><br />
*[[table.copy]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function copies a whole table and all the tables in that table.</span><br />
*[[table.compare]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if both tables is equal. </span><br />
*[[table.empty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check is empty table or not.</span><br />
*[[table.map]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.</span><br />
*[[table.merge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Merges two or more tables in the first.</span><br />
*[[table.random]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function retrieves a random variable from a table.</span><br />
*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span><br />
*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span><br />
*[[var dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function outputs information about one or more variables using outputConsole()</span><br />
*[[wavelengthToRGBA]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a phisical wavelength of light to a RGBA color.</span><br />
[[Category:Useful Functions]]</div>Booohttps://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&diff=39277Template:Useful Functions2014-04-08T14:32:50Z<p>Booo: </p>
<hr />
<div>*[[callClientFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any clientside function from the server's side.</span><br />
*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span><br />
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span><br />
*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span><br />
*[[convertNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts large numbers and adds commas to it. (Example: 100000 -> 100,000)</span><br />
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span><br />
*[[dxDrawAnimWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Create Animated Dx Window</span><br />
*[[dxDrawCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a circle shape on the screen.</span><br />
*[[dxDrawColorText]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a dx text with #RRGGBB color codes support.</span><br />
*[[dxDrawGifImage]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function simulates the effect of a GIF image by using image sprites.</span><br />
*[[dxDrawImage3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D image.</span><br />
*[[dxDrawPartialCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a partial circle shape on the screen.</span><br />
*[[dxDrawRectangle3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D rectangle.</span><br />
*[[dxDrawEmptyRec]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This funcions draws an empty rectangle.</span><br />
*[[dxGetFontSizeFromHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculate a font size from given height for dxDraw.</span><br />
*[[dxGetRealFontHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Accurately measures the pixel height of a font.</span><br />
*[[FewPlayersOnTeams]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's few Players.!</span><br />
*[[findRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes two points and returns the direction from point A to point B.</span><br />
*[[FormatDate]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Formats a date on the basis of a format string and returns it.</span><br />
*[[GenerateString]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can generate a random string with any characters.</span><br />
*[[getAge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span><br />
*[[getAlivePlayers (Client)|getAlivePlayers]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns all the alive players by a client side, so you can store them into a Gridlist or something like that, faster.</span><br />
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span><br />
*[[getBoundControls]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a list of control names that are bound to the specified key.</span><br />
*[[getCursorMoveOn]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks in which way the cursor is currently moving.</span><br />
*[[getDistanceBetweenPointAndSegment2D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes point coordinates and line (a segment) starting and ending coordinates. It returns the shortest distance between the point and the line.</span><br />
*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span><br />
*[[getElementsInDimension]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in the specified dimension.</span><br />
*[[getElementsWithinMarker]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in a markers colshape.</span><br />
*[[getJetpackWeaponsEnabled]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of enabled weapons usable on a jetpack.</span><br />
*[[getKeyFromValueInTable]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns the key of the specified value in a table.</span><br />
*[[getOffsetFromXYZ]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations.</span><br />
*[[getOnlineAdmins]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will give the online admins.</span><br />
*[[getOnlineStaff]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all online staff, names separated by two spaces.</span><br />
*[[getPlayersByData]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets players who have data name you passed to it.</span><br />
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span><br />
*[[getPlayersInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets all the players in a photograph.</span><br />
*[[getPlayerFromSerial]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets an online player from their serial.</span><br />
*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span><br />
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
*[[getResourceScripts]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource scripts.</span><br />
*[[getRGColorFromPercentage]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">»This function returns two integers representing Red and Green colors according to the percentage requested.</span><br />
*[[getScreenRotationFromWorldPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a screen relative rotation to a world position. The returned rotation can be used in dxDrawImage</span><br />
*[[getTeamFromColor]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's color. (Related to: [[getTeamFromName]])</span><br />
*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the UNIX timestamp.</span><br />
*[[getValidVehicleModels]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table containing valid MTA Vehicle models.</span><br />
*[[getXMLNodes]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all children of a node</span><br />
*[[getVehicleRespawnPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get the spawn position of a vehicle.</span><br />
*[[guiComboBoxAdjustHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Adjusts the combobox to have a correct height.</span><br />
*[[IfElse]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns one of two values based on a boolean expression.</span><br />
*[[isElementInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element was in the player's camera picture.</span><br />
*[[isElementInRange]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to check is the element's range to the main point is smaller than (or as big as) the maximum range.</span><br />
*[[isElementMoving]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element is moving.</span><br />
*[[isElementTeam]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if element is team.</span><br />
*[[isElementWithinAColShape]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if the [[element]] is in a [[colshape]].</span><br />
*[[isPedAiming]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if a ped is aiming.</span><br />
*[[isPlayerInACL]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will check to see if a player element is in an ACL group.</span><br />
*[[isPlayerInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if the player in the team.</span><br />
*[[isLeapYear]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Checks if the given year is a leap year.</span><br />
*[[isVehicleOnRoof]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether vehicle is on roof.</span><br />
*[[isVehicleEmpty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether a vehicle is empty.</span><br />
*[[isSoundFinished]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks sound finished or not.</span><br />
*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span><br />
*[[mathNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function is a workaround for the clientside floating-point precision of 24-bits</span><br />
*[[math.percent]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Return the porcent from one number.</span><br />
*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span><br />
*[[multi_check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks one element to many, handy and clean.</span><br />
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span><br />
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span><br />
*[[secondsToTimeDesc]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a plain seconds-integer into a user-friendly time description.</span><br />
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span><br />
*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span><br />
*[[setVehicleGravityPoint]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.</span><br />
*[[smoothMoveCamera]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function allows you to create a cinematic camera flight.<br />
*[[string.count]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function counts a text from a text.</span><br />
*[[string.explode]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function splits a string at a given separator pattern and returns a table with the pieces.</span><br />
*[[switch]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allow the value of a variable or expression to control the flow of program execution via a multiway branch.</span><br />
*[[table.copy]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function copies a whole table and all the tables in that table.</span><br />
*[[table.compare]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if both tables is equal. </span><br />
*[[table.empty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check is empty table or not.</span><br />
*[[table.map]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.</span><br />
*[[table.merge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Merges two or more tables in the first.</span><br />
*[[table.random]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function retrieves a random variable from a table.</span><br />
*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span><br />
*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span><br />
*[[var dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function outputs information about one or more variables using outputConsole()</span><br />
*[[wavelengthToRGBA]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a phisical wavelength of light to a RGBA color.</span><br />
[[Category:Useful Functions]]</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=39214GetTeamWithFewestPlayers2014-04-02T06:19:29Z<p>Booo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team getFewPlayersOnTeams ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getFewPlayersOnTeams(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getfewPlayersOnTeams(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=GetTeamWithFewestPlayers&diff=39213GetTeamWithFewestPlayers2014-04-02T06:18:55Z<p>Booo: Created page with "{{Useful Function}} <lowercasetitle/> __NOTOC__ This function gets a team from it's few players. '''Note:''' If 2 teams has the same count, then the first one found will be retur..."</p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function gets a team from it's few players.<br />
'''Note:''' If 2 teams has the same count, then the first one found will be returned!<br />
==Syntax==<br />
<syntaxhighlight lang="lua">team fewPlayersOnTeams ( element team1,element team2)</syntaxhighlight><br />
<br />
<br />
===Return===<br />
Returns a [[team]] else false.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function getFewPlayersOnTeams(team1,team2)<br />
if (isElement(team1) and getElementType(team1) == "team") and (isElement(team2) and getElementType(team2) == "team") then<br />
local team1C = countPlayersInTeam (team1)<br />
local team2C = countPlayersInTeam (team2)<br />
if team1C == team2C then return team1<br />
else<br />
if team1C == math.min(team1C,team2C) then<br />
return team1<br />
else<br />
return team2<br />
end<br />
end<br />
end<br />
return false<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
<section name="Example" class="server" show="true"><br />
<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
<br />
function setPlayerToTeam(source)<br />
local redteam = getTeamFromName ( "Red" )<br />
local blueteam = getTeamFromName ( "Blue" )<br />
if redteam and blueteam then<br />
local theteam = getfewPlayersOnTeams(redteam,blueteam)<br />
if theteam then<br />
setPlayerTeam(source,theteam)<br />
local PlayerName = getPlayerName ( source )<br />
outputChatBox ( " " .. joinedPlayerName .. " Joined "..getTeamName(theteam).." team !" , root, 255, 255, 255 )<br />
end<br />
else<br />
createTeam ("Red",255,0,0)<br />
createTeam ("Blue",0,0,255)<br />
setPlayerToTeam(source)<br />
end<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), setPlayerToTeam )<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<br />
Author: Booo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Booohttps://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&diff=38470Template:Useful Functions2014-01-17T16:02:52Z<p>Booo: </p>
<hr />
<div>*[[callClientFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any clientside function from the server's side.</span><br />
*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span><br />
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span><br />
*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span><br />
*[[convertNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts large numbers and adds commas to it. (Example: 100000 -> 100,000)</span><br />
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span><br />
*[[dxDrawAnimWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Create Animated Dx Window</span><br />
*[[dxDrawCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a circle shape on the screen.</span><br />
*[[dxDrawColorText]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a dx text with #RRGGBB color codes support.</span><br />
*[[dxDrawGifImage]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function simulates the effect of a GIF image by using image sprites.</span><br />
*[[dxDrawImage3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D image.</span><br />
*[[dxDrawPartialCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a partial circle shape on the screen.</span><br />
*[[dxDrawRectangle3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D rectangle.</span><br />
*[[dxGetFontSizeFromHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculate a font size from given height for dxDraw.</span><br />
*[[dxGetRealFontHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Accurately measures the pixel height of a font.</span><br />
*[[FewPlayersOnTeams]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's few Players.</span><br />
*[[findRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes two points and returns the direction from point A to point B.</span><br />
*[[FormatDate]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Formats a date on the basis of a format string and returns it.</span><br />
*[[GenerateString]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can generate a random string with any characters.</span><br />
*[[getAge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span><br />
*[[getAlivePlayers (Client)|getAlivePlayers]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns all the alive players by a client side, so you can store them into a Gridlist or something like that, faster.</span><br />
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span><br />
*[[getBoundControls]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a list of control names that are bound to the specified key.</span><br />
*[[getCursorMoveOn]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks in which way the cursor is currently moving.</span><br />
*[[getDistanceBetweenPointAndSegment2D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes point coordinates and line (a segment) starting and ending coordinates. It returns the shortest distance between the point and the line.</span><br />
*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span><br />
*[[getElementsInDimension]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in the specified dimension.</span><br />
*[[getElementsWithinMarker]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in a markers colshape.</span><br />
*[[getJetpackWeaponsEnabled]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of enabled weapons usable on a jetpack.</span><br />
*[[getOffsetFromXYZ]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations.</span><br />
*[[getOnlineAdmins]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will give the online admins.</span><br />
*[[getOnlineStaff]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all online staff, names separated by two spaces.</span><br />
*[[getPlayersByData]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets players who have data name you passed to it.</span><br />
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span><br />
*[[getPlayersInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets all the players in a photograph.</span><br />
*[[getPlayerFromSerial]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets an online player from their serial.</span><br />
*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span><br />
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
*[[getResourceScripts]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource scripts.</span><br />
*[[getRGColorFromPercentage]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">»This function returns two integers representing Red and Green colors according to the percentage requested.</span><br />
*[[getTeamFromColor]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's color. (Related to: [[getTeamFromName]])</span><br />
*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the UNIX timestamp.</span><br />
*[[getValidVehicleModels]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table containing valid MTA Vehicle models.</span><br />
*[[getXMLNodes]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all children of a node</span><br />
*[[getVehicleRespawnPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get the spawn position of a vehicle.</span><br />
*[[guiComboBoxAdjustHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Adjusts the combobox to have a correct height.</span><br />
*[[IfElse]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns one of two values based on a boolean expression.</span><br />
*[[isElementInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element was in the player's camera picture.</span><br />
*[[isElementInRange]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to check is the element's range to the main point is smaller than (or as big as) the maximum range.</span><br />
*[[isElementMoving]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element is moving.</span><br />
*[[isElementTeam]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if element is team.</span><br />
*[[isElementWithinAColShape]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if the [[element]] is in a [[colshape]].</span><br />
*[[isPedAiming]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if a ped is aiming.</span><br />
*[[isPlayerInACL]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will check to see if a player element is in an ACL group.</span><br />
*[[isPlayerInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if the player in the team.</span><br />
*[[isLeapYear]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Checks if the given year is a leap year.</span><br />
*[[isVehicleOnRoof]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether vehicle is on roof.</span><br />
*[[isVehicleEmpty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether a vehicle is empty.</span><br />
*[[isSoundFinished]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks sound finished or not.</span><br />
*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span><br />
*[[mathNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function is a workaround for the clientside floating-point precision of 24-bits</span><br />
*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span><br />
*[[multi_check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks one element to many, handy and clean.</span><br />
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span><br />
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span><br />
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span><br />
*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span><br />
*[[setVehicleGravityPoint]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.</span><br />
*[[smoothMoveCamera]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function allows you to create a cinematic camera flight.<br />
*[[string.count]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function counts a text from a text.</span><br />
*[[string.explode]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function splits a string at a given separator pattern and returns a table with the pieces.</span><br />
*[[switch]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allow the value of a variable or expression to control the flow of program execution via a multiway branch.</span><br />
*[[table.copy]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function copies a whole table and all the tables in that table.</span><br />
*[[table.compare]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if both tables is equal. </span><br />
*[[table.empty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check is empty table or not.</span><br />
*[[table.map]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.</span><br />
*[[table.merge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Merges two or more tables in the first.</span><br />
*[[table.random]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function retrieves a random variable from a table.</span><br />
*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span><br />
*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span><br />
*[[var dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function outputs information about one or more variables using outputConsole()</span><br />
*[[wavelengthToRGBA]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a phisical wavelength of light to a RGBA color.</span><br />
[[Category:Useful Functions]]</div>Booohttps://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&diff=38468Template:Useful Functions2014-01-17T15:52:31Z<p>Booo: </p>
<hr />
<div>*[[callClientFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any clientside function from the server's side.</span><br />
*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span><br />
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span><br />
*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span><br />
*[[convertNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts large numbers and adds commas to it. (Example: 100000 -> 100,000)</span><br />
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span><br />
*[[dxDrawAnimWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Create Animated Dx Window</span><br />
*[[dxDrawCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a circle shape on the screen.</span><br />
*[[dxDrawColorText]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a dx text with #RRGGBB color codes support.</span><br />
*[[dxDrawGifImage]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function simulates the effect of a GIF image by using image sprites.</span><br />
*[[dxDrawImage3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D image.</span><br />
*[[dxDrawPartialCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a partial circle shape on the screen.</span><br />
*[[dxDrawRectangle3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D rectangle.</span><br />
*[[dxGetFontSizeFromHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculate a font size from given height for dxDraw.</span><br />
*[[dxGetRealFontHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Accurately measures the pixel height of a font.</span><br />
*[[FewPlayersOnTeams]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's few Players.</span><br />
*[[findRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes two points and returns the direction from point A to point B.</span><br />
*[[FormatDate]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Formats a date on the basis of a format string and returns it.</span><br />
*[[GenerateString]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can generate a random string with any characters.</span><br />
*[[getAge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span><br />
*[[getAlivePlayers (Client)|getAlivePlayers]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns all the alive players by a client side, so you can store them into a Gridlist or something like that, faster.</span><br />
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span><br />
*[[getBoundControls]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a list of control names that are bound to the specified key.</span><br />
*[[getCursorMoveOn]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks in which way the cursor is currently moving.</span><br />
*[[getDistanceBetweenPointAndSegment2D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes point coordinates and line (a segment) starting and ending coordinates. It returns the shortest distance between the point and the line.</span><br />
*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span><br />
*[[getElementsInDimension]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in the specified dimension.</span><br />
*[[getElementsWithinMarker]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in a markers colshape.</span><br />
*[[getJetpackWeaponsEnabled]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of enabled weapons usable on a jetpack.</span><br />
*[[getOffsetFromXYZ]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations.</span><br />
*[[getOnlineAdmins]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will give the online admins.</span><br />
*[[getOnlineStaff]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all online staff, names separated by two spaces.</span><br />
*[[getPlayersByData]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets players who have data name you passed to it.</span><br />
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span><br />
*[[getPlayersInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets all the players in a photograph.</span><br />
*[[getPlayerFromSerial]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets an online player from their serial.</span><br />
*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span><br />
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
*[[getResourceScripts]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource scripts.</span><br />
*[[getRGColorFromPercentage]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">»This function returns two integers representing Red and Green colors according to the percentage requested.</span><br />
*[[getTeamFromColor]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's color. (Related to: [[getTeamFromName]])</span><br />
*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the UNIX timestamp.</span><br />
*[[getValidVehicleModels]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table containing valid MTA Vehicle models.</span><br />
*[[getXMLNodes]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all children of a node</span><br />
*[[getVehicleRespawnPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get the spawn position of a vehicle.</span><br />
*[[guiComboBoxAdjustHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Adjusts the combobox to have a correct height.</span><br />
*[[IfElse]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns one of two values based on a boolean expression.</span><br />
*[[isElementInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element was in the player's camera picture.</span><br />
*[[isElementInRange]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to check is the element's range to the main point is smaller than (or as big as) the maximum range.</span><br />
*[[isElementMoving]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element is moving.</span><br />
*[[isElementWithinAColShape]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if the [[element]] is in a [[colshape]].</span><br />
*[[isPedAiming]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if a ped is aiming.</span><br />
*[[isPlayerInACL]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will check to see if a player element is in an ACL group.</span><br />
*[[isPlayerInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if the player in the team.</span><br />
*[[isLeapYear]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Checks if the given year is a leap year.</span><br />
*[[isVehicleOnRoof]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether vehicle is on roof.</span><br />
*[[isVehicleEmpty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether a vehicle is empty.</span><br />
*[[isSoundFinished]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks sound finished or not.</span><br />
*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span><br />
*[[mathNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function is a workaround for the clientside floating-point precision of 24-bits</span><br />
*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span><br />
*[[multi_check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks one element to many, handy and clean.</span><br />
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span><br />
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span><br />
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span><br />
*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span><br />
*[[setVehicleGravityPoint]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.</span><br />
*[[smoothMoveCamera]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function allows you to create a cinematic camera flight.<br />
*[[string.count]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function counts a text from a text.</span><br />
*[[string.explode]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function splits a string at a given separator pattern and returns a table with the pieces.</span><br />
*[[switch]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allow the value of a variable or expression to control the flow of program execution via a multiway branch.</span><br />
*[[table.copy]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function copies a whole table and all the tables in that table.</span><br />
*[[table.compare]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if both tables is equal. </span><br />
*[[table.empty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check is empty table or not.</span><br />
*[[table.map]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.</span><br />
*[[table.merge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Merges two or more tables in the first.</span><br />
*[[table.random]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function retrieves a random variable from a table.</span><br />
*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span><br />
*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span><br />
*[[var dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function outputs information about one or more variables using outputConsole()</span><br />
*[[wavelengthToRGBA]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a phisical wavelength of light to a RGBA color.</span><br />
[[Category:Useful Functions]]</div>Booohttps://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&diff=38467Template:Useful Functions2014-01-17T15:51:57Z<p>Booo: </p>
<hr />
<div>*[[callClientFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any clientside function from the server's side.</span><br />
*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span><br />
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span><br />
*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span><br />
*[[convertNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts large numbers and adds commas to it. (Example: 100000 -> 100,000)</span><br />
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span><br />
*[[dxDrawAnimWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Create Animated Dx Window</span><br />
*[[dxDrawCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a circle shape on the screen.</span><br />
*[[dxDrawColorText]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a dx text with #RRGGBB color codes support.</span><br />
*[[dxDrawGifImage]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function simulates the effect of a GIF image by using image sprites.</span><br />
*[[dxDrawImage3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D image.</span><br />
*[[dxDrawPartialCircle]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 2D line in a partial circle shape on the screen.</span><br />
*[[dxDrawRectangle3D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a 3D rectangle.</span><br />
*[[dxGetFontSizeFromHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculate a font size from given height for dxDraw.</span><br />
*[[dxGetRealFontHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Accurately measures the pixel height of a font.</span><br />
*[[FewPlayersOnTeams]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» TThis function gets a team from it's few Players.</span><br />
*[[findRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes two points and returns the direction from point A to point B.</span><br />
*[[FormatDate]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Formats a date on the basis of a format string and returns it.</span><br />
*[[GenerateString]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can generate a random string with any characters.</span><br />
*[[getAge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span><br />
*[[getAlivePlayers (Client)|getAlivePlayers]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns all the alive players by a client side, so you can store them into a Gridlist or something like that, faster.</span><br />
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span><br />
*[[getBoundControls]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a list of control names that are bound to the specified key.</span><br />
*[[getCursorMoveOn]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks in which way the cursor is currently moving.</span><br />
*[[getDistanceBetweenPointAndSegment2D]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes point coordinates and line (a segment) starting and ending coordinates. It returns the shortest distance between the point and the line.</span><br />
*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span><br />
*[[getElementsInDimension]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in the specified dimension.</span><br />
*[[getElementsWithinMarker]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets the elements that are in a markers colshape.</span><br />
*[[getJetpackWeaponsEnabled]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of enabled weapons usable on a jetpack.</span><br />
*[[getOffsetFromXYZ]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations.</span><br />
*[[getOnlineAdmins]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will give the online admins.</span><br />
*[[getOnlineStaff]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all online staff, names separated by two spaces.</span><br />
*[[getPlayersByData]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets players who have data name you passed to it.</span><br />
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span><br />
*[[getPlayersInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets all the players in a photograph.</span><br />
*[[getPlayerFromSerial]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets an online player from their serial.</span><br />
*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span><br />
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
*[[getResourceScripts]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource scripts.</span><br />
*[[getRGColorFromPercentage]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">»This function returns two integers representing Red and Green colors according to the percentage requested.</span><br />
*[[getTeamFromColor]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function gets a team from it's color. (Related to: [[getTeamFromName]])</span><br />
*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the UNIX timestamp.</span><br />
*[[getValidVehicleModels]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table containing valid MTA Vehicle models.</span><br />
*[[getXMLNodes]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns all children of a node</span><br />
*[[getVehicleRespawnPosition]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get the spawn position of a vehicle.</span><br />
*[[guiComboBoxAdjustHeight]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Adjusts the combobox to have a correct height.</span><br />
*[[IfElse]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns one of two values based on a boolean expression.</span><br />
*[[isElementInPhotograph]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element was in the player's camera picture.</span><br />
*[[isElementInRange]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to check is the element's range to the main point is smaller than (or as big as) the maximum range.</span><br />
*[[isElementMoving]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element is moving.</span><br />
*[[isElementWithinAColShape]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if the [[element]] is in a [[colshape]].</span><br />
*[[isPedAiming]]<span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if a ped is aiming.</span><br />
*[[isPlayerInACL]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function will check to see if a player element is in an ACL group.</span><br />
*[[isPlayerInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if the player in the team.</span><br />
*[[isLeapYear]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Checks if the given year is a leap year.</span><br />
*[[isVehicleOnRoof]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether vehicle is on roof.</span><br />
*[[isVehicleEmpty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks whether a vehicle is empty.</span><br />
*[[isSoundFinished]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks sound finished or not.</span><br />
*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span><br />
*[[mathNumber]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function is a workaround for the clientside floating-point precision of 24-bits</span><br />
*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span><br />
*[[multi_check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks one element to many, handy and clean.</span><br />
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span><br />
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span><br />
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span><br />
*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span><br />
*[[setVehicleGravityPoint]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.</span><br />
*[[smoothMoveCamera]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function allows you to create a cinematic camera flight.<br />
*[[string.count]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function counts a text from a text.</span><br />
*[[string.explode]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function splits a string at a given separator pattern and returns a table with the pieces.</span><br />
*[[switch]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allow the value of a variable or expression to control the flow of program execution via a multiway branch.</span><br />
*[[table.copy]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function copies a whole table and all the tables in that table.</span><br />
*[[table.compare]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check if both tables is equal. </span><br />
*[[table.empty]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function check is empty table or not.</span><br />
*[[table.map]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.</span><br />
*[[table.merge]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Merges two or more tables in the first.</span><br />
*[[table.random]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function retrieves a random variable from a table.</span><br />
*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span><br />
*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span><br />
*[[var dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function outputs information about one or more variables using outputConsole()</span><br />
*[[wavelengthToRGBA]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a phisical wavelength of light to a RGBA color.</span><br />
[[Category:Useful Functions]]</div>Booo