Problem with /admins.
#1

Hi there,
I've changed simple style of /admins (SendClientMessage) to textdraw style.
But there's one problem. This only shows 1 randomly admin.
What I should do to fix it and show all admins?
Here's the code :
PHP код:
if(strcmp(cmd"/admins"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            
//SendClientMessage(playerid, COLOR_WHITE, "Admins Online:");
            
for(new 0MAX_PLAYERSi++)
            {
                if(
IsPlayerConnected(i))
                {
                    if(
PlayerInfo[i][pAdmin] >= && PlayerInfo[i][pStealthed] == 0)
                    {
                        new 
alevel[50];
                        if(
PlayerInfo[i][pAdmin] == 1) { alevel "{951FD0}Probie Admin"; }
                        if(
PlayerInfo[i][pAdmin] == 2) { alevel "{00FF0C}Junior Admin"; }
                        if(
PlayerInfo[i][pAdmin] == 3) { alevel "{00FF0C}General Admin"; }
                        if(
PlayerInfo[i][pAdmin] >= && PlayerInfo[i][pAdmin] <= 1335) { alevel "{F4A460}Senior Admin"; }
                        if(
PlayerInfo[i][pAdmin] >= 1336 && PlayerInfo[i][pAdmin] <= 99998) { alevel "{FF0000}Head Admin"; }
                        if(
PlayerInfo[i][pAdmin] >= 99999) { alevel "{B52B19}Executive Admin"; }
                        
format(string256"{FFFFFF}[ %s {FFFFFF}] %s"alevelPlayerRPName(i));
                        
//SendClientMessage(playerid, COLOR_GREY, string);
                        
ShowPlayerDialog(playerid,1378,DIALOG_STYLE_LIST,"{FFFFFF}Admins Online",string,"Ok","");
                    }
                }
            }
        }
        return 
1;
    } 
Reply
#2

Код:
format(string, 256, "%s{FFFFFF}[ %s {FFFFFF}] %s\n",string, alevel, PlayerRPName(i));
Your code can also be optimized:
Код:
if(strcmp(cmd, "/admins", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            for(new i = 0; i < GetPlayerPoolSize(); i++) if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] >= 1 && PlayerInfo[i][pStealthed] == 0)
            {
                   new alevel[50];
                   switch(PlayerInfo[i][pAdmin])
                   {
                          case 1: alevel = "{951FD0}Probie Admin";
                          case 2: alevel = "{00FF0C}Junior Admin";
                          case 3: alevel = "{00FF0C}General Admin";
                          case 1335: alevel = "{F4A460}Senior Admin";
                          case 99998: alevel = "{FF0000}Head Admin";
                          case 99999: alevel = "{B52B19}Executive Admin";
                   }
                   format(string, sizeof(string), "%s{FFFFFF}[ %s {FFFFFF}] %s\n", string, alevel, PlayerRPName(i));
            }
            ShowPlayerDialog(playerid,1378,DIALOG_STYLE_LIST,"{FFFFFF}Admins Online",string,"Ok","");
        }
        return 1;
    }
Edit: I've updated the above code.
Reply
#3

Quote:
Originally Posted by Sledgehammer
Посмотреть сообщение
....
You still need to show the dialog when the loop ends or else it wont work...

Код:
if(strcmp(cmd, "/admins", true) == 0)
{
    if (IsPlayerConnected(playerid))
    {
    	new 
    		string[128],
    		dialogstring[500];

        for(new i = 0; i < GetPlayerPoolSize(); i++) 
        {
        	if (!IsPlayerConnected(i))
        		continue;

        	if (!PlayerInfo[i][pAdmin])
        		continue;
        
        	if (!PlayerInfo[i][pStealthed])
        		continue;

            new 
            	alevel[30];

            switch(PlayerInfo[i][pAdmin])
            {
                case 1: 
             		alevel = "{951FD0}Probie Admin";

                case 2: 
                	alevel = "{00FF0C}Junior Admin";

                case 3: 
                	alevel = "{00FF0C}General Admin";

                case 4 .. 1335: 
                	alevel = "{F4A460}Senior Admin";

                case 1336 .. 99998: 
                	alevel = "{FF0000}Head Admin";

                case 99999: 
                	alevel = "Executive Admin";
            }

            format(string, sizeof(string), "{FFFFFF}[ %s {FFFFFF}] %s\n", alevel, PlayerRPName(i));
            strcat(string, dialogstring);
        }
        ShowPlayerDialog(playerid, 1378, DIALOG_STYLE_LIST, "{FFFFFF}Admins Online", string, "Ok", "");
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Sledgehammer
Посмотреть сообщение
Your code can also be optimized:
Код:
case 1336 .. 99998: alevel = "{FF0000}Head Admin";
That is actually very, very bad as a switch isn't built for this large number of cases. But in my opinion it's retarded to have levels greater than 10 or so, anyway. Just shows how unprofessional you are.
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
That is actually very, very bad as a switch isn't built for this large number of cases. But in my opinion it's retarded to have levels greater than 10 or so, anyway. Just shows how unprofessional you are.
Dude take it easy, he just wanted to help me. anyway thanks for your opinion.
EDIT : I've used that but didn't work properly and showed something else instead Admin's name and rank.
Also I have changed the array size of alevel I thought problem is there and increased to 60 but still doesn't work.
Any help?
Reply
#6

in my opinio , you can do something like this :

PHP код:
if(strcmp(cmd"/admins"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            
//SendClientMessage(playerid, COLOR_WHITE, "Admins Online:");
            
for(new 0MAX_PLAYERSi++)
            {
                if(
IsPlayerConnected(i))
                {
                    if(
PlayerInfo[i][pAdmin] >= && PlayerInfo[i][pStealthed] == 0)
                    {
                        new 
alevel[50];
                        if(
PlayerInfo[i][pAdmin] == 1) { alevel "{951FD0}Probie Admin"; }
                        if(
PlayerInfo[i][pAdmin] == 2) { alevel "{00FF0C}Junior Admin"; }
                        if(
PlayerInfo[i][pAdmin] == 3) { alevel "{00FF0C}General Admin"; }
                        if(
PlayerInfo[i][pAdmin] >= && PlayerInfo[i][pAdmin] <= 1335) { alevel "{F4A460}Senior Admin"; }
                        if(
PlayerInfo[i][pAdmin] >= 1336 && PlayerInfo[i][pAdmin] <= 99998) { alevel "{FF0000}Head Admin"; }
                        if(
PlayerInfo[i][pAdmin] >= 99999) { alevel "{B52B19}Executive Admin"; }
                        
format(string256"%s{FFFFFF}[ %s {FFFFFF}] %s\n",stringalevelPlayerRPName(i));
                        
                    }
                }
            }
            
ShowPlayerDialog(playerid,1378,DIALOG_STYLE_LIST,"{FFFFFF}Admins Online",string,"Ok",""); 
        }
        return 
1;
    } 
Note: this is based on Dialogs , not TextDraws
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)