SA-MP Forums Archive
Admin List Fails - 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: Admin List Fails (/showthread.php?tid=295100)



Admin List Fails - Terrenio - 04.11.2011

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 ?


Re: Admin List Fails - [MWR]Blood - 04.11.2011

Show the echo outside the loop.


Re: Admin List Fails - Snipa - 04.11.2011

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.


AW: Admin List Fails - Terrenio - 05.11.2011

Cool, works. Thank you!