Is it the same ? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Is it the same ? (
/showthread.php?tid=494644)
Is it the same ? -
anou1 - 14.02.2014
Hi,
I have an cmd to see how many admins are online:
Код:
CMD:adminco(playerid, params[])
{
if(pInfo[playerid][Admin] > 1)
{
SendClientMessage(playerid, -1, "Les membres du staff en ligne sont:");
foreach(new i : Player)
{
if(pInfo[i][Admin] >= 1)
{
new string[50];
GetPlayerName(i, joueurdestinataire, sizeof(joueurdestinataire));
format(string, sizeof(string), "%s | Niveau Admin: %d", joueurdestinataire, pInfo[i][Admin]);
SendClientMessage(playerid, -1, string);
}
}
return 1;
}
return SendClientMessage(playerid, Rouge,"La commande entrйe est inconnue !");
}
And I have a question about my string, is it better(for optimization or something) to put it in the foreach loop or to put it before the loop ?
Thank you.
Re: Is it the same ? -
Konstantinos - 14.02.2014
It's recommended to declare variables outside of the loop. It's better to declare an array 1 time rather than as many times as the connected players, isn't it?!
Re: Is it the same ? -
anou1 - 14.02.2014
Yeah you're right, thank you I will change it for this loop and others.