Get online admins number
#1

How to get the online admins number to make something like "There are 2 admins online." ?
Reply
#2

Count them in a stock.
Reply
#3

A short example please?
Reply
#4

Quote:
Originally Posted by Blackazur
Посмотреть сообщение
A short example please?

pawn Код:
stock CountAdmins()
{
    new count = 0;
    foreach(new i:Player)
    {
        if(IsPlayerAdmin(i)) count ++;
    }
    return count;
}
Reply
#5

Here is an example.
pawn Код:
new str[32], online;
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(PlayerInfo[i][pAdmin]) // just change the variable name to your admin system variable name.
            {
                online ++;
            }
        }
pawn Код:
format(str, sizeof(str), "Administrators online: %d", online);
        SendClientMessage(playerid, -1, str);
Reply
#6

Quote:
Originally Posted by tyler12
Посмотреть сообщение
pawn Код:
stock CountAdmins()
{
    new count = 0;
    foreach(new i:Player)
    {
        if(IsPlayerAdmin(i)) count ++;
    }
    return count;
}
And how to use it in a SendClientMessage? Just "CountAdmins" or "count"?
Reply
#7

Quote:
Originally Posted by Blackazur
Посмотреть сообщение
And how to use it in a SendClientMessage? Just "CountAdmins" or "count"?
format(string,sizeof(string),"%d admins",CountAdmins());
Reply
#8

pawn Код:
CMD:admins(playerid, params[]) {
    new count = 0;
    new string[128];
    for(new i = 0; i < MAX_PLAYERS; i ++)
       {
          if(IsPlayerConnected(i))
          {
              if(PlayerInfo[i][pAdmin] > 0)
              {
                    new name[MAX_PLAYER_NAME];
                    GetPlayerName(i, name, sizeof(name));
                    count++;
                    format(string, sizeof(string), "* There are currently %d admins online.", count);
                    SendClientMessage(playerid, COLOR_GREEN, string);
                }
            }
        }
    if(count == 0)
        {
            SendClientMessage(playerid, COLOR_RED,"* There are currently 0 admins online.");
        }
    return 1;
}
Reply
#9

You want to COUNT your administrators online or you want to show them up in a command like /admins?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)