SA-MP Forums Archive
/admins command - Minor issue - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /admins command - Minor issue (/showthread.php?tid=266072)



/admins command - Minor issue - sim_sima - 03.07.2011

Hello guys.
I made a /admins command, and it works just perfect when admins are online.
But when there are no admins online, its a little bit buggy. When no admins are online, its supposed to send this message: "No admins online at the moment" but it shows up multiple times.
Here is the command:
pawn Код:
COMMAND:admins(playerid, params[])
{
    SendClientMessage(playerid, COLOR_SYSTEMRED, "=========== Online Admins ===========");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pAdminLevel] >= 1)
            {
                new name[MAX_PLAYER_NAME], string[21 + MAX_PLAYER_NAME];
                GetPlayerName(i,name,sizeof(name));
                format(string, sizeof(string), "(Level:%i) %s (ID:%i)", PlayerInfo[i][pAdminLevel], name, i);
                SendClientMessage(playerid, COLOR_SYSTEMRED, string);
            }
            else if(PlayerInfo[i][pAdminLevel] == 0) SendClientMessage(playerid, COLOR_SYSTEMRED, "No admins online at the moment");
        }
    }
    SendClientMessage(playerid, COLOR_SYSTEMRED, "===================================");
    return 1;
}
Hope you can help me. Thank you.


Re: /admins command - Minor issue - Jay. - 03.07.2011

Quote:
Originally Posted by sim_sima
Посмотреть сообщение
Hello guys.
I made a /admins command, and it works just perfect when admins are online.
But when there are no admins online, its a little bit buggy. When no admins are online, its supposed to send this message: "No admins online at the moment" but it shows up multiple times.
Here is the command:
pawn Код:
COMMAND:admins(playerid, params[])
{
    SendClientMessage(playerid, COLOR_SYSTEMRED, "=========== Online Admins ===========");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pAdminLevel] >= 1)
            {
                new name[MAX_PLAYER_NAME], string[21 + MAX_PLAYER_NAME];
                GetPlayerName(i,name,sizeof(name));
                format(string, sizeof(string), "(Level:%i) %s (ID:%i)", PlayerInfo[i][pAdminLevel], name, i);
                SendClientMessage(playerid, COLOR_SYSTEMRED, string);
            }
            else if(PlayerInfo[i][pAdminLevel] == 0) SendClientMessage(playerid, COLOR_SYSTEMRED, "No admins online at the moment");
        }
    }
    SendClientMessage(playerid, COLOR_SYSTEMRED, "===================================");
    return 1;
}
Hope you can help me. Thank you.
pawn Код:
COMMAND:admins(playerid, params[])
{
    SendClientMessage(playerid, COLOR_SYSTEMRED, "=========== Online Admins ===========");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pAdminLevel] >= 1)
            {
                new name[MAX_PLAYER_NAME], string[21 + MAX_PLAYER_NAME];
                GetPlayerName(i,name,sizeof(name));
                format(string, sizeof(string), "(Level:%i) %s (ID:%i)", PlayerInfo[i][pAdminLevel], name, i);
                SendClientMessage(playerid, COLOR_SYSTEMRED, string);
            }
            else if(PlayerInfo[i][pAdminLevel] == 0) SendClientMessage(playerid, COLOR_SYSTEMRED, "No admins online at the moment");
            return 1;
        }
    }
    SendClientMessage(playerid, COLOR_SYSTEMRED, "===================================");
    return 1;
}



Re: /admins command - Minor issue - sim_sima - 03.07.2011

Quote:
Originally Posted by Jay.
Посмотреть сообщение
pawn Код:
COMMAND:admins(playerid, params[])
{
    SendClientMessage(playerid, COLOR_SYSTEMRED, "=========== Online Admins ===========");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pAdminLevel] >= 1)
            {
                new name[MAX_PLAYER_NAME], string[21 + MAX_PLAYER_NAME];
                GetPlayerName(i,name,sizeof(name));
                format(string, sizeof(string), "(Level:%i) %s (ID:%i)", PlayerInfo[i][pAdminLevel], name, i);
                SendClientMessage(playerid, COLOR_SYSTEMRED, string);
            }
            else if(PlayerInfo[i][pAdminLevel] == 0) SendClientMessage(playerid, COLOR_SYSTEMRED, "No admins online at the moment");
            return 1;
        }
    }
    SendClientMessage(playerid, COLOR_SYSTEMRED, "===================================");
    return 1;
}
Whats changed?


Re: /admins command - Minor issue - Jay. - 03.07.2011

Quote:
Originally Posted by sim_sima
Посмотреть сообщение
Whats changed?
I added

pawn Код:
return 1;
Under your message for no admins. I don't know if it will work..


Re: /admins command - Minor issue - WooTFTW - 03.07.2011

pawn Код:
COMMAND:admins(playerid, params[])
{
    new count;
    SendClientMessage(playerid, COLOR_SYSTEMRED, "=========== Online Admins ===========");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pAdminLevel] >= 1)
            {
                count ++;
                new name[MAX_PLAYER_NAME], string[21 + MAX_PLAYER_NAME];
                GetPlayerName(i,name,sizeof(name));
                format(string, sizeof(string), "(Level:%i) %s (ID:%i)", PlayerInfo[i][pAdminLevel], name, i);
                SendClientMessage(playerid, COLOR_SYSTEMRED, string);
            }
        }
    }
    if(!count)
    {
        SendClientMessage(playerid, COLOR_SYSTEMRED, "No admins online at the moment");
    }
    SendClientMessage(playerid, COLOR_SYSTEMRED, "===================================");
    return 1;
}



Re: /admins command - Minor issue - sim_sima - 03.07.2011

Thanks everyone