SA-MP Forums Archive
[Help] Dialog Help? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help] Dialog Help? (/showthread.php?tid=507994)



[Help] Dialog Help? - Elie1996 - 20.04.2014

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


Re: [Help] Dialog Help? - BroZeus - 20.04.2014

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;
}



Re: [Help] Dialog Help? - itsCody - 20.04.2014

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