/Admins
#1

Command spam and not showing names?
pawn Код:
stock LevelName(playerid)
{
    new Regular[128];
    new Admin[128];
    switch(PlayerInfo[playerid][pAdmin])
    {
        case 0: Regular = "Regular player";
        case 1: Admin = "Moderator";
        case 2: Admin = "Administrator";
    }
    return Admin;
}
CMD:admins(playerid)
{
    new Count;
    new str[45], Admin[MAX_PLAYER_NAME];
    SendClientMessage(playerid, -1, "Online Staff Members:");
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        if(PlayerInfo[i][pAdmin] < 2)
        {
            Count ++;
            GetPlayerName(i, Admin, MAX_PLAYER_NAME);
            format(str, sizeof str, "%s ({FFFF00}%s{FFFFFF})",Admin, LevelName(i));
            SendClientMessage(playerid, -1, str);
        }
    }
    if(Count < 1) SendClientMessage(playerid, -1, "No Admins Online");
    return 1;
}
[14:45:26] Test({FFFF00}{FFFFFF})

[14:45:26] Test({FFFF00}{FFFFFF})

[14:45:26] Test({FFFF00}{FFFFFF})

[14:45:26] Test({FFFF00}{FFFFFF})

[14:45:26] Test({FFFF00}{FFFFFF})
Reply
#2

pawn Код:
stock LevelName(playerid)
{
    new Admin[32];
    switch (PlayerInfo[playerid][pAdmin])
    {
        case 0: Admin = "Regular player";
        case 1: Admin = "Moderator";
        case 2: Admin = "Administrator";
    }
    return Admin;
}
pawn Код:
CMD:admins(playerid)
{
    new Count, str[64], Admin[MAX_PLAYER_NAME];
    SendClientMessage(playerid, -1, "Online Staff Members:");
    for (new i = 0; i < MAX_PLAYERS; i ++)
    {
        if (PlayerInfo[i][pAdmin] >= 2) // change "2" to the min admin level
        {
            Count ++;
            GetPlayerName(i, Admin, MAX_PLAYER_NAME);
            format(str, sizeof (str), "%s ({FFFF00}%s{FFFFFF})", Admin, LevelName(i));
            SendClientMessage(playerid, -1, str);
        }
    }
    if (!Count) SendClientMessage(playerid, -1, "No Admins Online");
    return 1;
}
@AhmedMohamed: The problem was in the stock that if the pAdmin was 0, you set the admin name to the variable "Regular" but you returned "Admin" so in other words it's empty. Also the operator in the admin level in the command (in the loop) was incorrect.
Reply
#3

what was the problem Konstantinos?
Reply
#4

Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)