/admins command isen't working ...
#1

Hello,
I have made an /admins command, that will display all admins in the game on a list. Only my problem is that it don't work. The list displays only one admin.
Код:
dcmd_admins(playerid, cmdtext[]) {
	#pragma unused cmdtext
    SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, "Admins online:");
	new admins = 0;
	new string[100];
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(pInfo[i][adminlevel] == 1)
   			{
				GetPlayerName(i, pname, sizeof(pname));
				format(string, sizeof(string), "%d) Name: %s, ID: %d", admins, pname, i,(i));
				SendClientMessage(playerid, COLOR_GREY, string);
				admins++;
				return 1;
			}
		}
	}
	if(admins == 0)
	{
		SendClientMessage(playerid,0xFF0000AA, "There are currently no admins online");
		return 1;
	}
	return 1;
}
Please help me if you know the answer.
Greetz,
Danny
Reply
#2

Your code seems to be fine
Reply
#3

pawn Код:
return 1;
Remove that from your loop, that's what kills it and results in it only submitting 1 message.

Quote:
Originally Posted by Claude
Посмотреть сообщение
Your code seems to be fine
What was the point in posting if you're unable to properly evaluate it?
Reply
#4

pawn Код:
dcmd_admins(playerid,params[])
{
    #pragma unused params
    if(IsPlayerConnected(playerid))
    {
        new AdminGuy[MAX_PLAYER_NAME];
        new string[50 + MAX_PLAYER_NAME];
        SendClientMessage(playerid, COLOR_WHITE, "Current Online Admins:");
        SendClientMessage(playerid, COLOR_WHITE, "__________________");
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            new lvl = pInfo[i][adminlevel];
            if(lvl > 0)
            {
                GetPlayerName(i, AdminGuy, sizeof(AdminGuy));
                format(string, sizeof(string), "Name: %s - Admin Level: %d", AdminGuy, lvl);
                SendClientMessage(playerid, COLOR_BLUE, string);
             }
        }
        SendClientMessage(playerid, COLOR_WHITE, "___________________");
    }
    return 1;
}
Not tested but must work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)