Is it the same ?
#1

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.
Reply
#2

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?!
Reply
#3

Yeah you're right, thank you I will change it for this loop and others.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)