/admins in Dialog
#1

Hi guys, who can help me with this cmd?
When I type /admins, its shows me a dialog with all admins
I already have the script but its shows only 1 Admin, if there are 2 Admins in the server, its shows only 1 Admin.

Код:
if (strcmp(cmd, "/admins", true) == 0)
	{
	    new count = 0;
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
		    if (IsPlayerConnected(i))
	  		{
  				if(AccountInfo[i][AdminLevel] >= 1 && AccountInfo[i][AdminLevel] <= 5 && Hide[i] == 0)
	    		{
					new playername[MAX_PLAYER_NAME];
					GetPlayerName(i, playername, sizeof(playername));
					format(string, 128, "%s 		 Level: %d\n",playername,AccountInfo[i][AdminLevel]);
    				        ShowPlayerDialog(playerid,2563,DIALOG_STYLE_LIST,"Admins Online:",string,"OK","");
					count++;
				}
			}
		}
		if (count == 0) SendClientMessage(playerid,LILA,"Server: No Admins online yet.");
		return true;
	}
Regards *******12
Reply
#2

show some code !!
Reply
#3

Код:
if (strcmp(cmd, "/admins", true) == 0)
	{
	    new count = 0;
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
		    if (IsPlayerConnected(i))
	  		{
  				if(AccountInfo[i][AdminLevel] >= 1 && AccountInfo[i][AdminLevel] <= 5 && Hide[i] == 0)
	    		{
					new playername[MAX_PLAYER_NAME];
					GetPlayerName(i, playername, sizeof(playername));
					format(string, 128, "%s 		 Level: %d\n",playername,AccountInfo[i][AdminLevel]);
    				        ShowPlayerDialog(playerid,2563,DIALOG_STYLE_LIST,"Admins Online:",string,"OK","");
					count++;
				}
			}
		}
		if (count == 0) SendClientMessage(playerid,LILA,"Server: No Admins online yet.");
		return true;
	}
Reply
#4

The problem is you call the function ShowPlayerDialog 500 times (500 = MAX_PLAYERS),
because there is a for-loop. And when the server finds an admin it will show you the dialog only with one admin on the list.

Try this.

EDIT: There was en error, it's fixed now.
pawn Код:
if (strcmp(cmd, "/admins", true) == 0)
{
    new count = 0, text[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            if(AccountInfo[i][AdminLevel] >= 1 && AccountInfo[i][AdminLevel] <= 5 && Hide[i] == 0)
            {
                new playername[MAX_PLAYER_NAME];
                GetPlayerName(i, playername, sizeof(playername));
                format(string, 128, "%s          Level: %d\n",playername,AccountInfo[i][AdminLevel]);
                strins(text, string, strlen(string), sizeof(string));
                count++;
            }
        }
    }
    if (count == 0) return SendClientMessage(playerid,LILA,"Server: No Admins online yet.");
    ShowPlayerDialog(playerid,2563,DIALOG_STYLE_LIST,"Admins Online:",text,"OK","");
    strdel(text, 0, strlen(text));
    return 1;
}
Reply
#5

If I type /admins now, Its Unknown the command "SERVER: Unknown command."
Reply
#6

PHP код:
if (strcmp(cmd"/admins"true) == 0)
    {
        new 
count 0,text[256];
        for(new 
0MAX_PLAYERSi++)
        {
            if (
IsPlayerConnected(i))
              {
                  if(
AccountInfo[i][AdminLevel] >= && AccountInfo[i][AdminLevel] <= && Hide[i] == 0)
                {
                    new 
playername[MAX_PLAYER_NAME];
                    
GetPlayerName(iplayernamesizeof(playername));
                    
format(string64"%s | Level:  %d\n",playernameAccountInfo[i[AdminLevel]);
strcat(text,string);
                    
count++;
                }
            }
        }
        if (
count == 0SendClientMessage(playerid,LILA,"Server: No Admins online yet.");
 
ShowPlayerDialog(playerid,2563,DIALOG_STYLE_LIST,"Admins Online:"text,"OK","");
        return 
true;
    } 
Reply
#7

Код:
16419	if (strcmp(cmd, "/admins", true) == 0)
16420   {
16421        new count = 0,text[256];
16422       for(new i = 0; i < MAX_PLAYERS; i++)
16423     {
16424            if (IsPlayerConnected(i))
16425              {
16426                  if(AccountInfo[i][AdminLevel] >= 1 && AccountInfo[i][AdminLevel] <= 5 && Hide[i] == 0)
16427               {
16428                    new playername[MAX_PLAYER_NAME];
16429                   GetPlayerName(i, playername, sizeof(playername));
16430                    format(string, 64, "%s | Level:  %d\n",playername, AccountInfo[i][AdminLevel]);
16431					strcat(text,string);
16432                    count++;
16433                }
16434            }
16435        }
16436        if (count == 0) SendClientMessage(playerid,LILA,"Server: No Admins online yet.");
16437 		ShowPlayerDialog(playerid,2563,DIALOG_STYLE_LIST,"Admins Online:"text,"OK","");
16438       return true;
16439   }







Errors:


C:\Users\Billy\Desktop\Server 0.3e-R2\gamemodes\Server.pwn(16437) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\Billy\Desktop\Server 0.3e-R2\gamemodes\Server.pwn(16437) : warning 215: expression has no effect
C:\Users\Billy\Desktop\Server 0.3e-R2\gamemodes\Server.pwn(16437) : warning 215: expression has no effect
C:\Users\Billy\Desktop\Server 0.3e-R2\gamemodes\Server.pwn(16437) : warning 215: expression has no effect
C:\Users\Billy\Desktop\Server 0.3e-R2\gamemodes\Server.pwn(16437) : error 001: expected token: ";", but found ")"
C:\Users\Billy\Desktop\Server 0.3e-R2\gamemodes\Server.pwn(16437) : error 029: invalid expression, assumed zero
C:\Users\Billy\Desktop\Server 0.3e-R2\gamemodes\Server.pwn(16437) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#8

deleted
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)