Admin List Fails
#1

Hello,

I tryed to make a command for IRC to view a list of all current ingame admins. It works fine so far, the only problem is that it echoes every admin twice.

Код:
IRCCMD:admins(botid, channel[], user[], host[], params[])
{
    #pragma unused params
        new count = 0;
        new string[128];
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
				if(IsPlayerConnected(i) && AccInfo[i][Level] >= 3 && AccInfo[i][Hide] == 0)
 				{
					format(string, sizeof(string), "Level: %d - %s (Id:%i)",AccInfo[i][Level], PlayerName2(i),i);
					IRC_GroupSay(gGroupID, channel, string);
					count++;
				}
		}
		if (count == 0)
		format(string, sizeof(string), "There are currently no admins online.");
		IRC_GroupSay(gGroupID, channel, string);
		return 1;
}
When I type the command on IRC this line is getting echoed twice:

Код:
					format(string, sizeof(string), "Level: %d - %s (Id:%i)",AccInfo[i][Level], PlayerName2(i),i);
					IRC_GroupSay(gGroupID, channel, string);
Any idea how to fix that ?
Reply
#2

Show the echo outside the loop.
Reply
#3

pawn Код:
IRCCMD:admins(botid, channel[], user[], host[], params[])
{
    #pragma unused params
    new count = 0;
    new string[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && AccInfo[i][Level] >= 3 && AccInfo[i][Hide] == 0)
        {
            count++;
            break;
        }
    }
    if (count == 0) {
        IRC_GroupSay(gGroupID, channel, "There are currently no admins online.");
    }
    else
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && AccInfo[i][Level] >= 3 && AccInfo[i][Hide] == 0)
            {
                format(string, sizeof(string), "Level: %d - %s (Id:%i)",AccInfo[i][Level], PlayerName2(i),i);
                IRC_GroupSay(gGroupID, channel, string);
            }
        }
    }

    return 1;
}
Echo it for each string.
Reply
#4

Cool, works. Thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)