SA-MP Forums Archive
[SOLVED]for loop statement - unknown command [zcmd] - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED]for loop statement - unknown command [zcmd] (/showthread.php?tid=152365)



[SOLVED]for loop statement - unknown command [zcmd] - king s dm - 03.06.2010

Hello!
I got a problem. I'm trying to do an /admins command using zcmd. It always prints online admins and then "Unknown command".
I'm not sure why there is "Unknown command." message, but when I used strcmp that command worked fine.

pawn Код:
command(admins, playerid, params[])
{
    new adminName[MAX_PLAYER_NAME], string[128];
    SendClientMessage(playerid, COLOR_WHITE, "Administrators Online:");
   
    for(new i = 0; i <= MAX_PLAYERS; i ++)
    {
        if(IsPlayerConnected(i) && pInfo[i][pAdmin] > 0)
        {
            GetPlayerName(i, adminName, sizeof(adminName));
            format(string, sizeof(string), "%s", adminName);

            SendClientMessage(playerid, COLOR_WHITE, string);
        }
    }
    return 1;
}



Re: for loop statement - unknown command [zcmd] - coole210 - 03.06.2010

Код:
	if (strcmp(cmd, "/admins", true) == 0))
	{
	    new count = 0;
		SendClientMessage(playerid, COLOR_YELLOW, "[ ! ] List of online adminstrators");
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
		  if (IsPlayerConnected(i))
	 	  {
 				if(pInfo[i][pAdmin] > 0)
	  		    {
					GetPlayerName(i, sendername, sizeof(sendername));
					format(string, 128, "<%i> %s", i,sendername,Admin[i]);
					SendClientMessage(playerid, COLOR_WHITE, string);
					count++;
				}
			}
		}
        SendClientMessage(playerid, COLOR_YELLOW, "[ ! ] End of the list");
		return 1;
	}



Re: for loop statement - unknown command [zcmd] - Antonio [G-RP] - 03.06.2010

Hes asking for zCMD, so don't post else.


Re: for loop statement - unknown command [zcmd] - coole210 - 04.06.2010

Quote:
Originally Posted by Antonio (eternalrp.webatu.com)
Hes asking for zCMD, so don't post else.
He's asking for help. That's what i gave.


Re: for loop statement - unknown command [zcmd] - zSuYaNw - 04.06.2010

Boot:
pawn Код:
return 1;
{



Re: for loop statement - unknown command [zcmd] - Zeex - 04.06.2010

It says Unknown command because you're trying to access pInfo element out of its bounds. Change <= in the loop condition to < so it will be like:

pawn Код:
for (new i = 0; i < MAX_PLAYERS; i ++)




Re: for loop statement - unknown command [zcmd] - king s dm - 04.06.2010

Thanks Zeex, it works.