This function fails to show an a Message when playercount hits 0.
#1

pawn Код:
IRCCMD:admins(botid, channel[], user[], host[], params[])
{
    new msg[128], msg1[50], AdmRank[128], playeramount; //Increase str to a suitable number
    foreach(Player, i)
    {
        if(PlayerInfo[i][pAdmin] == 0) { AdmRank = "Regular Player"; }
        else if(PlayerInfo[i][pAdmin] == 1) { AdmRank = "Moderator"; }
        else if(PlayerInfo[i][pAdmin] == 2) { AdmRank = "Professional Moderator"; }
        else if(PlayerInfo[i][pAdmin] == 3) { AdmRank = "Administrator"; }
        else if(PlayerInfo[i][pAdmin] == 4) { AdmRank = "Head Administrator"; }
        else if(PlayerInfo[i][pAdmin] >= 5) { AdmRank = "Owner"; }
        if(PlayerInfo[i][pAdmin] > 0 && IsPlayerConnected(i))
        {
            new name[90];
            GetPlayerName(i,name,sizeof(name));
            format(msg,sizeof(msg),"8,1***%s %s (%d)",AdmRank, name, i);
            GetPlayerName(i,name,sizeof(name));
            playeramount ++;
        }
        if(playeramount == 0) return format(msg1,sizeof(msg1), "No admins are online"); IRC_GroupSay(groupID, channel, msg1);
        IRC_GroupSay(groupID, channel, msg); //Shows dialog with admins, one button "Close"
    }
    return 1;
}
The function, if playeramount = 0, should return a message saying No admins are online, but fails to show when I type !admins, however when someone is online, it shows the admins online.
Reply
#2

Your playeramount check is inside the foreach loop. Put it outside the foreach
Reply
#3

Quote:
Originally Posted by mamorunl
Посмотреть сообщение
Your playeramount check is inside the foreach loop. Put it outside the foreach
Are you sure? Isn't the playeramount++ count how many admins are online when it loops through players, with a level 1 or higher?
Reply
#4

Yea, I meant this one:

pawn Код:
if(playeramount == 0) return format(msg1,sizeof(msg1), "No admins are online");
Also, if you return a formatted text it will still not show up!

So I take it that it has to be like this:

pawn Код:
if(playeramount == 0) { format(msg1,sizeof(msg1), "No admins are online");
return IRC_GroupSay(groupID, channel, msg1);
}
Reply
#5

Why thank you ! :P
Reply
#6

Not a problem. We had a similar problem once in the dutch section
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)