/admins isn't working right
#1

Hello, i have been having to problem, when i use /admins it shows the user who typed the command as the admin, but no other admin shows on there, don't get where it's gone wrong.
Код:
CMD:admins(playerid, params[])
{
    foreach(Player, i)
    {
        new string[256], name[MAX_PLAYER_NAME];
        GetPlayerName(i, name, sizeof(name));

        if(pInfo[i][Adminlevel ] > 0)
        {
            format(string, sizeof(string), "%s %s\n", AdminLevelName(playerid), name);
            ShowPlayerDialog(playerid, DIALOG_ONLINE_ADMINS, DIALOG_STYLE_MSGBOX, "Admins online", string, "Close", "");
        }
    }
    return 1;
}
Reply
#2

Quote:
Originally Posted by LeXuZ
Посмотреть сообщение
Hello, i have been having to problem, when i use /admins it shows the user who typed the command as the admin, but no other admin shows on there, don't get where it's gone wrong.
Код:
CMD:admins(playerid, params[])
{
    foreach(Player, i)
    {
        new string[256], name[MAX_PLAYER_NAME];
        GetPlayerName(i, name, sizeof(name));

        if(pInfo[i][Adminlevel ] > 0)
        {
            format(string, sizeof(string), "%s %s\n", AdminLevelName(playerid), name);
            ShowPlayerDialog(playerid, DIALOG_ONLINE_ADMINS, DIALOG_STYLE_MSGBOX, "Admins online", string, "Close", "");
        }
    }
    return 1;
}
pawn Код:
CMD:admins(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 2)
    {
        new AdminString[1500];
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if (IsPlayerConnected(i))
            {
                if(PlayerInfo[i][AdminLevel] >= 1)
                {
                    if(IsPlayerAdmin(i))
                    {
                        AdmRank = "{FF0000}RCON {FFFFFF}Administrator";
                    }
                    else
                    {
                        switch(PlayerInfo[i][AdminLevel])
                        {
                            case 1:
                            {
                                AdmRank = "{00FF00}Trial {FFFFFF}Admin";
                            }
                            case 2:
                            {
                                AdmRank = "{FFFFFF}Basic {FF0000}Moderator";
                            }
                            case 3:
                            {
                                AdmRank = "{FF0000}Moderator";
                            }
                            case 4:
                            {
                                AdmRank = "Master {FF0000}Moderator";
                            }
                            case 5:
                            {
                                AdmRank = "{FFFFFF}Administrator";
                            }
                            case 6:
                            {
                                AdmRank = "{FF0000}Master {FFFFFF}Administrator";
                            }
                            case 7:
                            {
                                AdmRank = "{00FF00}Professional {FFFFFF}Administrator";
                            }
                            case 8:
                            {
                                AdmRank = "{0000FF}Server {FFFFFF}Mapper";
                            }
                            case 9:
                            {
                                AdmRank = "{0000FF}Server {FF00FF}Beta Tester";
                            }
                            case 10:
                            {
                                AdmRank = "{0000FF}Server {00FF00}Owner";
                            }
                        }
                    }
                    new file[300];
                    new name[MAX_PLAYER_NAME];
                    GetPlayerName(i, name, sizeof(name));
                    format(file,sizeof(file),"nAdmin/Users/%s.ini",name);
                    PlayerInfo[i][AdminLevel] = dini_Int(file, "AdminLevel");
                    format(AdminString, sizeof(AdminString), "%s{FF00FF}Level: {FF0000}%d {FF00FF}- {00FF00}%s (Id:{FF0000}%i{00FF00}) {FF00FF}| %s \n",AdminString, PlayerInfo[i][AdminLevel], PlayerName2(i),i,AdmRank);
                    ShowPlayerDialog(playerid, DIALOG_ADMINS, DIALOG_STYLE_MSGBOX, "[!] Online Admins", AdminString, "OK", "");
                    count++;
                }
            }
        }
        if (count == 0)
        {
            ShowPlayerDialog(playerid, DIALOG_ADMINS, DIALOG_STYLE_MSGBOX, "[!] Online Admins", "No online admins", "OK", "");
        }
    }
    else return SendClientMessage(playerid, COLOR_RED, "ERROR: you need to be atleast Admin Level 2 to view the Admins List");
    return 1;
}
Try Like this
Reply
#3

Why are you writing it like that when it could be so much smaller and simpler..
Reply
#4

You use showdialog each time in the foreach loop, instead of putting all admins in 1 line and then putting that in your dialog.
Reply
#5

format the string inside the loop then show the dialog outside the loop, like this;

pawn Код:
CMD:admins(playerid, params[])
{
    foreach(Player, i)
    {
        new string[256], name[MAX_PLAYER_NAME];
        GetPlayerName(i, name, sizeof(name));

        if(pInfo[i][Adminlevel ] > 0)
        {
            format(string, sizeof(string), "%s%s %s\n", string, AdminLevelName(playerid), name);
        }
    }
    ShowPlayerDialog(playerid, DIALOG_ONLINE_ADMINS, DIALOG_STYLE_MSGBOX, "Admins online", string, "Close", "");
    return 1;
}
Reply
#6

What I just said..
Reply
#7

My post relates to yours in no way whatsoever.
Reply
#8

Quote:
Originally Posted by Luis-
Посмотреть сообщение
My post relates to yours in no way whatsoever.
I just said that he should put the dialog outside of the foreach, which is exactly which you did. Not sure if you're postcount/rep whoring, but let users do something different than just copying code. They gotta learn somehow.
Reply
#9

Quote:
Originally Posted by AnthonyTimmers
Посмотреть сообщение
I just said that he should put the dialog outside of the foreach, which is exactly which you did. Not sure if you're postcount/rep whoring, but let users do something different than just copying code. They gotta learn somehow.
Uh.. Okay then.

OP: Hmm, that's how i'd do it, what's cutting off exactly?
Reply
#10

Quote:
Originally Posted by Luis-
Посмотреть сообщение
format the string inside the loop then show the dialog outside the loop, like this;

pawn Код:
CMD:admins(playerid, params[])
{
    foreach(Player, i)
    {
        new string[256], name[MAX_PLAYER_NAME];
        GetPlayerName(i, name, sizeof(name));

        if(pInfo[i][Adminlevel ] > 0)
        {
            format(string, sizeof(string), "%s%s %s\n", string, AdminLevelName(playerid), name);
        }
    }
    ShowPlayerDialog(playerid, DIALOG_ONLINE_ADMINS, DIALOG_STYLE_MSGBOX, "Admins online", string, "Close", "");
    return 1;
}
Thanks for the help guys, i think this /admin command worked, but i can not check as it might have been a problem with my hoster, as none of my files are saving so it was showing no admins online
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)