/admins in dialog
#1

My problem with this codes is its only show only 1 admin even there is 3 admins online :
PHP код:
CMD:admins(playeridparams[])
{
    new 
count 0string[256],AdmRank[500];
    for(new 
0MAX_PLAYERSi++)
       if(
PlayerInfo[i][Level] == 1)
    {
    
AdmRank "Trial Admin";
    }
    else if(
PlayerInfo[i][Level] == 2)
    {
    
AdmRank "Server Admin";
    }
    else if(
PlayerInfo[i][Level] == 3)
    {
    
AdmRank "Senior Admin";
    }
    else if(
PlayerInfo[i][Level] == 4)
    {
    
AdmRank "Lead Admin";
    }
    else if(
PlayerInfo[i][Level] == 5)
    {
    
AdmRank "Global Admin";
    }
    else if(
PlayerInfo[i][Level] == 6)
    {
    
AdmRank "Developer";
    }
    else if(
PlayerInfo[i][Level] == 7)
    {
    
AdmRank "Co Owner";
    }
    else if(
PlayerInfo[i][Level] == 8)
    {
    
AdmRank "Owner";
    }
    for(new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerConnected(i))
        {
            if(
PlayerInfo[i][Level] > 0)
            {
                new 
Name[MAX_PLAYER_NAME];
                
GetPlayerName(i,Name,sizeof(Name));
                {
                
format(stringsizeof(string), ""cwhite"Level: "cgreen"%d "cwhite"| "cwhite"Name:"cgreen" %s "cwhite"(ID:"cgreen"%i"cwhite") | Rank : "cgreen"%s"PlayerInfo[i][Level], Namei,AdmRank);
                
ShowPlayerDialog(playerid,2312,DIALOG_STYLE_MSGBOX,"Admins Online",string,"OK","");
                
count++;
            }
        }
    }
}
    if (
count == 0ShowPlayerDialog(playerid,2322,DIALOG_STYLE_MSGBOX,"Admins Online","{FF0000}No Admins online right now","OK","");
    return 
1;

Reply
#2

First of all, you are using 2 exactly same loops, no reason to do that.

I havent tested this code so let me know if there are any problems
PHP код:
#define MYADMINDIALOG 5
stock GetPlayerAdminRank(playerid) {
    new 
rank[24];
    switch(
PlayerInfo[playerid][Level]) {
        case 
0rank "Player";
        case 
1rank "Trial Admin";
        case 
2rank "Server Admin";
        case 
3rank "Senior Admin";
        case 
4rank "Lead Admin";
        case 
5rank "Global Admin";
        case 
6rank "Developer";
        case 
7rank "Co Owner";
        case 
8rank "Owner";
    }
    return 
rank;
}
stock GetName(playerid)
{
    new 
szName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridszNamesizeof(szName));
    return 
szName;
}
CMD:admins(playerid,params[]) {
    
#pragma unused params
    
new string[128];
    for (new 
0MAX_PLAYERSi++) {
        if(
IsPlayerConnected(i)) {
            if(
PlayerInfo[i][Level] >= 1) {
                
format(string,sizeof(string),"%s %s\n",GetName(i),GetPlayerAdminRank(i));
            }
        }
    }
    
ShowPlayerDialog(playerid,MYADMINDIALOG,DIALOG_STYLE_MSGBOX,"Administrators online",string,"Confirm","Decline");
    return 
true;

EDIT: Fixed the problem with the name.


EDIT: its always good to have predefined stuff in some cases, for example admin ranks so you can use stuff such as
pawn Код:
format(string,sizeof(string),"%s is my admin rank",GetPlayerAdminRank(playerid));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)