/admins
#1

hello i've this command to see the online admins but the problem its only show me one admin even if is there two or more admins online any way to fix that?

PHP код:
CMD:admins(playerid,params[])
{
  new 
name[24], str[100];
  new 
count 0;
  for(new 
0<MAX_PLAYERSi++)
  {
    if(!
IsPlayerConnected(i)) continue;
    if(
pdata[i][Adminstator])
    {
      
GetPlayerName(i,name,sizeof(name));
      
format(str,sizeof(str),"%s (%d): %s",name,i,AdminLevel(i));
      
ShowPlayerDialog(playerid,20,DIALOG_STYLE_LIST,"Online admins",str,"Close","");
      
count++;
    }
    if(
count == 0) return ShowPlayerDialog(playerid,22,DIALOG_STYLE_MSGBOX,"Online admins","No players found","Close","");
  }
  return 
1;

Reply
#2

You should use strcat for each admin online, instead of format, and then show a dialog.
Right now you're formatting a string and showing a new dialog for each admin online.
Reply
#3

pawn Код:
CMD:admins(playerid, params[])
{
    new name[24], string[60], stringend[60*10+1], count; // max 10 admins in dialog.
    //..
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(pdata[i][Administrador] >= 1)
            {
                GetPlayerName(i, name, sizeof(name));
                format(string, sizeof(string), "%s (%d): %s\n", name, i, AdminLevel(i));
                strcat(stringend, string);
                count++;
            }
        }
    }
    if(count < 1)
        ShowPlayerDialog(playerid, 22, DIALOG_STYLE_MSGBOX, "Online admins", "No players found", "Close","");
    else if(count >= 1)
        ShowPlayerDialog(playerid, 20, DIALOG_STYLE_LIST, "Online admins", stringend, "Close","");
    //..
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)