Admin Rank
#1

Hey guys
here is the cmd

pawn Код:
new AdmRank[128];
dcmd_admins(playerid,params[])
{
    #pragma unused params
        new count = 0;
        new string[128];
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
        if (IsPlayerConnected(i))
        {
        if(PlayerInfo[i][Level] >= 1 && PlayerInfo[i][Level] <= 5 /*&& Hide[i] == 0*/)
        {
        if(IsPlayerAdmin(playerid)) AdmRank = "RCON Administrator";
        else
        switch(PlayerInfo[i][Level])
        {
        case 1: AdmRank = "Basic Moderator";
        case 2: AdmRank = "Moderator";
        case 3: AdmRank = "Mod";
        case 4: AdmRank = "Admin";
        case 5: AdmRank = "Owner";
        }
        format(string, 128, "Admin: %s [%s],",PlayerName2(i), AdmRank);
        SendClientMessage(playerid, blue, string);
        count++;
        }
        }
        }
        if (count == 0)
        SendClientMessage(playerid,red,"No admin online in the list");
        return 1;
}
When i type /admins im getting spam
Online admins
Linus-[Owner]
Lolipop[Admin]
hahaw[Mod]


How to make it like this?:

Admins: Linus-[Owner], Lolipop[Admin], hahaw[Mod]

Help me please.

Sorry for my bad english
Reply
#2

pawn Код:
dcmd_admins(playerid,params[])
{
    #pragma unused params
        new count = 0;
        new string[128];
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if (IsPlayerConnected(i))
            {
                if(PlayerInfo[i][Level] >= 1 && PlayerInfo[i][Level] <= 5)
                {
                if(IsPlayerAdmin(playerid)) AdmRank = "RCON Administrator";
                else
                switch(PlayerInfo[i][Level])
                {
                    case 1: AdmRank = "Basic Moderator";
                    case 2: AdmRank = "Moderator";
                    case 3: AdmRank = "Mod";
                    case 4: AdmRank = "Admin";
                    case 5: AdmRank = "Owner";
                }
                format(string, 128, "%s [%s],",PlayerName2(i), AdmRank);
                count++;
                }
            }
        }
        SendClientMessage(playerid, white, "Administrators Online:");
        SendClientMessage(playerid, blue, string);
        if (count == 0)
        SendClientMessage(playerid,red,"No admin online in the list");
        return 1;
}
You put SendClientMessage in your loop.
Reply
#3

pawn Код:
new
    tmp[64],
    string[128];

for(new i = 0; i < MAX_PLAYERS; i++)
{
    if (IsPlayerConnected(i))
    {
        if(1 <= PlayerInfo[i][Level] <= 5)
        {
            if(IsPlayerAdmin(playerid)) AdmRank = "RCON Administrator";
           
            else
            switch(PlayerInfo[i][Level])
            {
                case 1: AdmRank = "Basic Moderator";
                case 2: AdmRank = "Moderator";
                case 3: AdmRank = "Mod";
                case 4: AdmRank = "Admin";
                case 5: AdmRank = "Owner";
            }

            format(tmp, sizeof(tmp), "%s [%s], ",PlayerName2(i), AdmRank)
            strcat(string, tmp);

            if ((i % 3) == 0) // This will print 3 names on one line and then move on to the next line
            {
                SendClientMessage(playerid, blue, string);
                string[0] = EOS;

                // Note: EOS = End Of String = '\0'
                // It empties the string (so to say)
                // This is needed for strcat to work correctly
            }
            count++;
        }
    }
}
Reply
#4

I'll test it later, btw, thank you u both.
Reply
#5

or that :P
pawn Код:
dcmd_admins(playerid,params[])
{
    #pragma unused params
    new count,string[255];
    for(new i,g=GetMaxPlayers(); i < g; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(1 <= PlayerInfo[i][Level] <= 5)
            {
                if(IsPlayerAdmin(i)) AdmRank = "RCON Administrator";
                switch(PlayerInfo[i][Level])
                {
                    case 1: AdmRank = "Basic Moderator";
                    case 2: AdmRank = "Moderator";
                    case 3: AdmRank = "Mod";
                    case 4: AdmRank = "Admin";
                    case 5: AdmRank = "Owner";
                }
                format(string,255, "%s%s [%s], ",string,PlayerName2(i),AdmRank);
                count++;
            }
        }
    }
    format(string,255,"Admins: %s",string);
    SendClientMessage(playerid, blue, string);
    if(!count) SendClientMessage(playerid,red,"No admin online in the list");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)