[Help] Dialog Help?
#1

Okay, so I want to create a dialog with style DIALOG_STYLE_LIST.
The problem is, I don't know the items inside that list for sure.
my question is, how do I add them?
================================================== ================
Let's say I want that list to consist all players online.
How do I do that?

My suggestion, by logic would be:
pawn Код:
CMD:showplayers(playerid, params[])
{
  new i;
  for(i=0;i<MAX_PLAYERS;i++)
   {
   if(IsPlayerConnected(i))
      {
         // Somehow add him to the list
      }
   }
}
How do I do that?

=Thanks in Advance
Reply
#2

pawn Код:
CMD:showplayers(playerid, params[])
{
  new i,name[MAX_PLAYER_NAME],show[1300];
  format(show,sizeof(show),"");
  for(i=0;i<MAX_PLAYERS;i++)
   {
   if(IsPlayerConnected(i))
      {
         GetPlayerName(i,name,sizeof(name));
         strcat(show,name,sizeof(show));
         strcat(show,"\n",sizeof(show));
      }
   }
ShowPlayerDialog(playerid, 100, DIALOG_STYLE_LIST, "{00cc00}Online Players", show, "Cool", "");
return 1;
}
Reply
#3

pawn Код:
#define DIALOG_MSGBOX 999
CMD:showplayers(playerid, params[])
{
    new playercount, string[128];

    foreach(new i : Player)
    {
        format(string, sizeof(string), "%s%i) %s[%i]\n", string, ++playercount, PlayerName(i), i);
    }
   
    if(!playercount)
    {
        ShowPlayerDialog(playerid, DIALOG_MSGBOX, DIALOG_STYLE_MSGBOX, "Online Players", "There are no players online", "OK", "");
        return 1;
    }

    else ShowPlayerDialog(playerid, DIALOG_MSGBOX, DIALOG_STYLE_MSGBOX, "Online players", string, "OK", "");
    return 1;
}
untested but it should work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)