/admins - command problem
#1

pawn Код:
CMD:admins(playerid)
{
     new count=0, PlayerName[MAX_PLAYER_NAME], rankname[32],color[100];
     new list1[900];
     strcat(list1, "{FFFFFF}NO\t{FFFFFF}Name(ID)\t{FFFFFF}Level\n");
     foreach(Player, i)
     {
           if(playerData[i][playerLevel] > 0)
           {
              GetPlayerName(i, PlayerName, sizeof(PlayerName));
              switch(playerData[i][playerLevel])
              {
                 case 1: { rankname = "{FFFFFF}LEVEL 1"; }
                 case 2: { rankname = "{FFFFFF}LEVEL 2"; }
                 case 3: { rankname = "{FFFFFF}LEVEL 3"; }
                 case 4: { rankname = "{FFFFFF}LEVEL 4"; }
                 case 5: { rankname = "{FFFFFF}LEVEL 5"; }
                 case 6: { rankname = "{FFFFFF}LEVEL 6"; }
                 case 7: { rankname = "{FFFFFF}LEVEL 7"; }
                 case 8: { rankname = "{FFFFFF}LEVEL 8"; }
              }
              if(playerData[i][playerAdminDuty] == true)
              {
                 color = "{FF0770}"; // pink
              }
              else color = "{C0C0C0}"; //grey
              format(list1, sizeof(list1), "%s\n%d\t%s%s(%d)\t%s\n", list1, count + 1,color, PlayerName, i, rankname);
              count++;
           }
           if(count == 0)
           {
             SendClientMessage(playerid, -1, "There are no administrators online.");
             return true;
           }
           ShowPlayerDialog(playerid, 555, DIALOG_STYLE_TABLIST_HEADERS, "Online Admins",list1, "Close", "");
     }
     return 1;
}
The problem in this script is that sometimes it is only outputing "There are no administrators online" from time to time even where is are administrators online.

Please help.
Reply
#2

bump help me please. I will +rep whoever helps me
Reply
#3

TRY, compile

PHP код:
CMD:admins(playerid)
{
     new 
count=0PlayerName[MAX_PLAYER_NAME], rankname[32],color[100];
     new 
list1[256];
     
strcat(list1"{FFFFFF}NO\t{FFFFFF}Name(ID)\t{FFFFFF}Level\n");
     foreach(
Playeri)
     {
        if(!
playerData[i][playerLevel])
            continue;
        
count++;
        
GetPlayerName(iPlayerNamesizeof(PlayerName));
        
color = ((playerData[i][playerAdminDuty])?("{FF0770}"):("{C0C0C0}"));
        
format(list1sizeof(list1), "%s\n%d\t%s%s(%d)\t{FFFFFF}LEVEL %i\n"list1count 1,colorPlayerNameiplayerData[i][playerLevel]);
     }
    if(!
count)
    {
        
SendClientMessage(playerid, -1"There are no administrators online.");
    }
    else
    {
        
ShowPlayerDialog(playerid555DIALOG_STYLE_TABLIST_HEADERS"Online Admins",list1"Close""");
    }
       return 
1;

Reply
#4

Problem is mate you've put the 'no admin' handler inside the loop - example, when the loop starts from player 0 if he isn't administrator it terminates because of the return. Always let the loop finish, unless you've found what you have looked for i guess?

pawn Код:
CMD:admins(playerid)
{
    new count, PlayerName[MAX_PLAYER_NAME], rankname[32], color[100];
    new list1[900];
    strcat(list1, "{FFFFFF}NO\t{FFFFFF}Name(ID)\t{FFFFFF}Level\n");
    foreach(Player, i)
    {
        if(playerData[i][playerLevel] > 0)
        {
            GetPlayerName(i, PlayerName, sizeof(PlayerName));
            switch(playerData[i][playerLevel])
            {
                case 1: { rankname = "{FFFFFF}LEVEL 1"; }
                case 2: { rankname = "{FFFFFF}LEVEL 2"; }
                case 3: { rankname = "{FFFFFF}LEVEL 3"; }
                case 4: { rankname = "{FFFFFF}LEVEL 4"; }
                case 5: { rankname = "{FFFFFF}LEVEL 5"; }
                case 6: { rankname = "{FFFFFF}LEVEL 6"; }
                case 7: { rankname = "{FFFFFF}LEVEL 7"; }
                case 8: { rankname = "{FFFFFF}LEVEL 8"; }
            }
            if(playerData[i][playerAdminDuty] == true)
            {
                color = "{FF0770}"; // pink
            }
            else color = "{C0C0C0}"; //grey
            format(list1, sizeof(list1), "%s\n%d\t%s%s(%d)\t%s\n", list1, count + 1,color, PlayerName, i, rankname);
            count++;
        }
    }
    if(count == 0)
    {
        SendClientMessage(playerid, -1, "There are no administrators online.");
        return true;
    }
    ShowPlayerDialog(playerid, 555, DIALOG_STYLE_TABLIST_HEADERS, "Online Admins",list1, "Close", "");
    return 1;
}
Reply
#5

What...

pawn Код:
color[100];
pawn Код:
if(playerData[i][playerAdminDuty] == true)
            {
                color = "{FF0770}"; // pink
            }
            else color = "{C0C0C0}"; //grey
can easy be done
pawn Код:
new color, string[12];
color = 0xFF0770AA >>> 8;
format(string, 12, "{%06x}", color);
Reply
#6

Thank you all! how to give rep?
Reply
#7

Press the star near the user's post at the left
Reply
#8

thanks sir
Reply
#9

Quote:
Originally Posted by d3ll
Посмотреть сообщение
Problem is mate you've put the 'no admin' handler inside the loop - example, when the loop starts from player 0 if he isn't administrator it terminates because of the return. Always let the loop finish, unless you've found what you have looked for i guess?

pawn Код:
CMD:admins(playerid)
{
    new count, PlayerName[MAX_PLAYER_NAME], rankname[32], color[100];
    new list1[900];
    strcat(list1, "{FFFFFF}NO\t{FFFFFF}Name(ID)\t{FFFFFF}Level\n");
    foreach(Player, i)
    {
        if(playerData[i][playerLevel] > 0)
        {
            GetPlayerName(i, PlayerName, sizeof(PlayerName));
            switch(playerData[i][playerLevel])
            {
                case 1: { rankname = "{FFFFFF}LEVEL 1"; }
                case 2: { rankname = "{FFFFFF}LEVEL 2"; }
                case 3: { rankname = "{FFFFFF}LEVEL 3"; }
                case 4: { rankname = "{FFFFFF}LEVEL 4"; }
                case 5: { rankname = "{FFFFFF}LEVEL 5"; }
                case 6: { rankname = "{FFFFFF}LEVEL 6"; }
                case 7: { rankname = "{FFFFFF}LEVEL 7"; }
                case 8: { rankname = "{FFFFFF}LEVEL 8"; }
            }
            if(playerData[i][playerAdminDuty] == true)
            {
                color = "{FF0770}"; // pink
            }
            else color = "{C0C0C0}"; //grey
            format(list1, sizeof(list1), "%s\n%d\t%s%s(%d)\t%s\n", list1, count + 1,color, PlayerName, i, rankname);
            count++;
        }
    }
    if(count == 0)
    {
        SendClientMessage(playerid, -1, "There are no administrators online.");
        return true;
    }
    ShowPlayerDialog(playerid, 555, DIALOG_STYLE_TABLIST_HEADERS, "Online Admins",list1, "Close", "");
    return 1;
}
Can't compile this script
Reply
#10

Quote:
Originally Posted by DarkBr
Посмотреть сообщение
TRY, compile

PHP код:
CMD:admins(playerid)
{
     new 
count=0PlayerName[MAX_PLAYER_NAME], rankname[32],color[100];
     new 
list1[256];
     
strcat(list1"{FFFFFF}NO\t{FFFFFF}Name(ID)\t{FFFFFF}Level\n");
     foreach(
Playeri)
     {
        if(!
playerData[i][playerLevel])
            continue;
        
count++;
        
GetPlayerName(iPlayerNamesizeof(PlayerName));
        
color = ((playerData[i][playerAdminDuty])?("{FF0770}"):("{C0C0C0}"));
        
format(list1sizeof(list1), "%s\n%d\t%s%s(%d)\t{FFFFFF}LEVEL %i\n"list1count 1,colorPlayerNameiplayerData[i][playerLevel]);
     }
    if(!
count)
    {
        
SendClientMessage(playerid, -1"There are no administrators online.");
    }
    else
    {
        
ShowPlayerDialog(playerid555DIALOG_STYLE_TABLIST_HEADERS"Online Admins",list1"Close""");
    }
       return 
1;

This worked! thank you
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)