"/admins" command
#1

Hey guys,

I've got this /admins command uh, sometimes it shows who's online and sometimes the server returns "SERVER: Unkown Command" after it gives "====[Online Administrators]====", so I'm going to paste the command here, and please tell me what's wrong?

pawn Код:
CMD:admins(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        SendClientMessage(playerid, COLOR_RED, "====[Online Administrators]====");
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(PlayerInfo[i][pAdmin] >= 1 && PlayerInfo[i][pAdmin] < 6)
                {
                    new admtext[64], sendername[MAX_PLAYER_NAME], string[128];
                    if(PlayerInfo[i][pAdmin] == 5) { admtext = "Owner"; }
                    else if(PlayerInfo[i][pAdmin] == 4) { admtext = "Head Admin"; }
                    else if(PlayerInfo[i][pAdmin] == 3) { admtext = "Lead Admin"; }
                    else if(PlayerInfo[i][pAdmin] == 2) { admtext = "Basic Admin"; }
                    else if(PlayerInfo[i][pAdmin] == 1) { admtext = "Trial Admin"; }
                    else { admtext = "Trial Admin"; }
                    GetPlayerName(i, sendername, sizeof(sendername));
                    sendername[strfind(sendername,"_")] = ' ';
                    if(AdminDuty[i] == 0)
                    {
                        format(string, 128, "%s: %s (AdminDuty: No)", admtext, sendername);
                        SendClientMessage(playerid, COLOR_RED, string);
                    }
                    else
                    {
                        format(string, 128, "%s: %s (AdminDuty: Yes)", admtext, sendername);
                        SendClientMessage(playerid, COLOR_GREEN, string);
                    }
                }
            }
        }
    }
    return 1;
}
I guess the problem starts from this line:

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
        {
Reply
#2

And if you want my command that sets admins, I have made a customized one by myself, here it is:

pawn Код:
CMD:setadmin(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        new targetid, level, adminrank[32];
        new sendername[32], string[128];
        if(sscanf(params, "uis[128]", targetid, level, adminrank))
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setadmin <playerid> <level> <Admin Rank Name>");
            return 1;
        }
        if(level > 5 || level < 0) { SendClientMessage(playerid, COLOR_GREY, "> Don't go below 0 or higher then 5!"); return 1; }

        if(IsPlayerConnected(targetid))
        {
            //new ranktext[32];
            /*if(PlayerInfo[targetid][pAdmin] == 5) { ranktext = "Trial Admin"; }
            else if(PlayerInfo[targetid][pAdmin] == 4) { ranktext = "Basic Admin"; }
            else if(PlayerInfo[targetid][pAdmin] == 3) { ranktext = "Lead Admin"; }
            else if(PlayerInfo[targetid][pAdmin] == 2) { ranktext = "Head Admin"; }
            else if(PlayerInfo[targetid][pAdmin] == 1) { ranktext = "Owner"; }
            else { ranktext = "Trial Admin"; }*/

            PlayerInfo[targetid][pAdmin] = level;
            SavePlayerStats(playerid);
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string),"> Admin %s has promoted you to a %s(Admin Level:%i)", sendername, adminrank, level);
            SendClientMessage(targetid, 0xFFFFFFFF, string);
        }
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF, "Only Admins can perform this action.");
    return 1;
}
I don't think it has any problem though.
Reply
#3

try to set it to
pawn Код:
return 0;
}
maybe its work
Reply
#4

MY COMMAND :
Код:
	COMMAND:adminson(playerid, inputtext[])
	{
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] >= 1)
			{
			        SPM(playerid, 0xAA3333AA, "== ADMINS ON‌LINE ==");
			   		new string[100],name[MAX_PLAYER_NAME];
                                                 GetPlayerName(i,name,sizeof(name));
				    format(string, sizeof(string), "ADMIN %s[ID: %d] ; LEVEL %d", name, i, PlayerInfo[i][pAdmin]);
				    SPM(playerid, 0xB8860BFF, string);
				    SPM(playerid, 0xAA3333AA, "== ADMINS ON‌LINE ==");
			}
		}
	}
Just try to change with your specific variables, if you can't, tell me I will customize by your codes.
Reply
#5

Okay guys, let me check and try what you said, I'll start firstly with the return 0
Reply
#6

I did EDIT on my post, check it out now, it should work.
Reply
#7

/adminson works but still it gives after it works Server: Unknown Command :/

/adminson doesn't work well, it sends twice the messages if there are 2 admins online, what if 4? It'll spam the chat lol.

Anyway, how can I fix my command? Return 0 didn't fix it :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)