cmd:admins
#1

Well when I type /admins in game it also shows the players that have level 0 admin, any fix? heres the code;

pawn Code:
CMD:admins(playerid, params[])
{
    new admins, szString[128], id;
    SendClientMessage(playerid, 0x99FF00AA, ""NAME" online administrators.");

    loop(i, MAX_PLAYERS) {
        if (IsPlayerConnected(i)) {
            if (GetAdminLevel(id) >= 1) {
                new PlayerName[MAX_PLAYER_NAME];
                GetPlayerName(i, PlayerName, sizeof(PlayerName));
                admins++;
                format(szString, sizeof(szString), "{EA8015}Admin %s(%d) (Level: %d) (%s)", PlayerName, id, GetAdminLevel(i), staffrank(i));
                SendClientMessage(playerid, 0x99FF00AA, szString);
            }
        }
    }
    if (admins == 0) {
        SendClientMessage(playerid, 0x99FF00AA, "{EA8015}[{C0C0C0}ERROR{EA8015}] No admins connected.");
    }
    else {
        format(szString, sizeof(szString), "{EA8015}[{C0C0C0}INFO{EA8015}] There are currently %d Admins online.", admins);
        SendClientMessage(playerid, 0x99FF00AA, szString);
    }
    return 1;
}
Heres the ranks also;

pawn Code:
stock staffrank(i)
{
    new szString[128];
    switch(GetAdminLevel(i))
    {
        case 0: szString = "Player";
        case 1: szString = "Trial Admin";
        case 2: szString = "Moderator";
        case 3: szString = "Senior Moderator";
        case 4: szString = "Lead Admin";
        case 5: szString = "Head Admin";
        case 6: szString = "Owner";
    }
    return szString;
}
Reply
#2

Do > 0
Reply
#3

Quote:
Originally Posted by tyler12
View Post
Do > 0
It's the same thing.

But have you done any debugging see what ids the loop returns, what admin levels and why.
Also show your GetAdminLevel
Reply
#4

Code:
GetAdminLevel(playerid)
{
        new file[128]; format(file, 128, USER_FILE, GetPName(playerid));
        return dini_Int(file, "AdminLevel");
}
Reply
#5

Why do you use id
pawn Code:
if (GetAdminLevel(i) >= 1) {
Your want to check the players from the loop right ?
Reply
#6

The problem is here.
pawn Code:
(GetAdminLevel(id) >= 1)
Instead of id, use i.
pawn Code:
CMD:admins(playerid, params[])
{
    new admins, szString[128], id;
    SendClientMessage(playerid, 0x99FF00AA, ""NAME" online administrators.");

    loop(i, MAX_PLAYERS) {
        if (IsPlayerConnected(i)) {
            if (GetAdminLevel(i) >= 1) {
                new PlayerName[MAX_PLAYER_NAME];
                GetPlayerName(i, PlayerName, sizeof(PlayerName));
                admins++;
                format(szString, sizeof(szString), "{EA8015}Admin %s(%d) (Level: %d) (%s)", PlayerName, id, GetAdminLevel(i), staffrank(i));
                SendClientMessage(playerid, 0x99FF00AA, szString);
            }
        }
    }
    if (admins == 0) {
        SendClientMessage(playerid, 0x99FF00AA, "{EA8015}[{C0C0C0}ERROR{EA8015}] No admins connected.");
    }
    else {
        format(szString, sizeof(szString), "{EA8015}[{C0C0C0}INFO{EA8015}] There are currently %d Admins online.", admins);
        SendClientMessage(playerid, 0x99FF00AA, szString);
    }
    return 1;
}
Reply
#7

That made it work, thanks for that but theres one problem. It only shows ONE admin not the rest ?
Reply
#8

I thinks it's becouse the GetAdminLevel returns a value and it breaks the loop.
Again I'm saying do some debuging
Reply
#9

Hmm, I've never acctually debugged anything...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)