/admins command
#1

So I have a command called /admins that shows how many admins are online.

Its working good but there is a problem tho.

Sometimes the chats get spammed with "There are currently no admins online".

Then it looks like this for an example

There are currently no admins online
There are currently no admins online
There are currently no admins online
There are currently no admins online
There are currently no admins online
There are currently no admins online
Server Owner: David Sparks Status: Roleplaying

How can I fix this?

Here's my code.

Code:
CMD:admins(playerid, params[])
{
        new string[128], count = 0;
		SendClientMessage(playerid, COLOR_WHITE, "Admins Online");
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
		    if(IsPlayerConnected(i))
		    {
		        if(PlayerInfo[i][pAdmin] >= 1)
		        {
				    if(PlayerInfo[i][pAdminDuty] == 1)
				    {
				        if(IsAFK[i] == 0)
				        {
				    		format(string, sizeof(string), "%s: %s(ID: %d) Status: {4BB74C}Administrating", AdminRankName(i), RemoveUnderScore(i), i);
							SendClientMessage(playerid, COLOR_WHITE, string);
							count++;
						}
						else
						{
			                format(string, sizeof(string), "%s: %s(ID: %d) Status: {FF6600}Away From Keyboard", AdminRankName(i), RemoveUnderScore(i), i);
							SendClientMessage(playerid, COLOR_WHITE, string);
							count++;
						}
					}
					else
					{
					    if(IsAFK[i] == 0)
					    {
					    	format(string, sizeof(string), "%s: %s(ID: %d) Status: {FF0000}Roleplaying", AdminRankName(i), RemoveUnderScore(i), i);
							SendClientMessage(playerid, COLOR_WHITE, string);
							count++;
						}
						else
						{
			                format(string, sizeof(string), "%s: %s(ID: %d) Status: {FF6600}Away From Keyboard", AdminRankName(i), RemoveUnderScore(i), i);
							SendClientMessage(playerid, COLOR_WHITE, string);
							count++;
						}
					}
				}
            }
		if(count == 0)
		{
		    SendClientMessage(playerid, COLOR_GREY, "There are currently no Admins online.");
		}
	}
	return 1;
}
Reply
#2

One of the last brackets is placed wrong:
pawn Code:
CMD:admins(playerid, params[])
{
    new string[128], count = 0;
    SendClientMessage(playerid, COLOR_WHITE, "Admins Online");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdmin] >= 1)
        {
            if(PlayerInfo[i][pAdminDuty] == 1)
            {
                if(IsAFK[i] == 0)
                {
                    format(string, sizeof(string), "%s: %s(ID: %d) Status: {4BB74C}Administrating", AdminRankName(i), RemoveUnderScore(i), i);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    count++;
                }
                else
                {
                    format(string, sizeof(string), "%s: %s(ID: %d) Status: {FF6600}Away From Keyboard", AdminRankName(i), RemoveUnderScore(i), i);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    count++;
                }
            }
            else
            {
                if(IsAFK[i] == 0)
                {
                    format(string, sizeof(string), "%s: %s(ID: %d) Status: {FF0000}Roleplaying", AdminRankName(i), RemoveUnderScore(i), i);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    count++;
                }
                else
                {
                    format(string, sizeof(string), "%s: %s(ID: %d) Status: {FF6600}Away From Keyboard", AdminRankName(i), RemoveUnderScore(i), i);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    count++;
                }
            }
        }
    }

    if(count == 0)
    {
        SendClientMessage(playerid, COLOR_GREY, "There are currently no Admins online.");
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by IstuntmanI
View Post
One of the last brackets is placed wrong:
pawn Code:
CMD:admins(playerid, params[])
{
    new string[128], count = 0;
    SendClientMessage(playerid, COLOR_WHITE, "Admins Online");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdmin] >= 1)
        {
            if(PlayerInfo[i][pAdminDuty] == 1)
            {
                if(IsAFK[i] == 0)
                {
                    format(string, sizeof(string), "%s: %s(ID: %d) Status: {4BB74C}Administrating", AdminRankName(i), RemoveUnderScore(i), i);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    count++;
                }
                else
                {
                    format(string, sizeof(string), "%s: %s(ID: %d) Status: {FF6600}Away From Keyboard", AdminRankName(i), RemoveUnderScore(i), i);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    count++;
                }
            }
            else
            {
                if(IsAFK[i] == 0)
                {
                    format(string, sizeof(string), "%s: %s(ID: %d) Status: {FF0000}Roleplaying", AdminRankName(i), RemoveUnderScore(i), i);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    count++;
                }
                else
                {
                    format(string, sizeof(string), "%s: %s(ID: %d) Status: {FF6600}Away From Keyboard", AdminRankName(i), RemoveUnderScore(i), i);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    count++;
                }
            }
        }
    }

    if(count == 0)
    {
        SendClientMessage(playerid, COLOR_GREY, "There are currently no Admins online.");
    }
    return 1;
}
thanks +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)