[SOLVED]for loop statement - unknown command [zcmd]
#1

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;
}
Reply
#2

Код:
	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;
	}
Reply
#3

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

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

Boot:
pawn Код:
return 1;
{
Reply
#6

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 ++)

Reply
#7

Thanks Zeex, it works.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)