Online list
#4

Quote:
Originally Posted by Nuke547
Посмотреть сообщение
This should work. And I know there is a more efficient way to do it with the string, but for now, you can do it by how many people you have on your server.
PHP код:
for(new 0MAX_PLAYERSi++)
{
       new 
name[MAX_PLAYER_NAME], string[126];
       
GetPlayerName(inamesizeof(name));
       
format(stringsizeof(string), "%s\n%s",name);
       
showplayerdialog(playeridDIALOG_STYLE_LISTcasenumber"Users"string"Select""Cancel");

Wrong, this will keep showing the player a dialog with 1 user in it.

Use this:

pawn Код:
new users[256],username[MAX_PLAYER_NAME];
//"users" is the string we will format to show all users
//"username" is the string which will be used to get the name of the playerid
for(new i,ii = GetMaxPlayers(); i < ii; i++)
//The above is a for loop checking if i is under the maximum number of players that can enter the server
{
    if(IsPlayerConnected(i))
    //The above is to check if "i" (from the for loop) is a connected playerid (existing player!)
    {
        GetPlayerName(i,username,sizeof(username));//Get name of "i" (connected player)
        format(users,sizeof(users),"%s\n%s",users,username);
        //format the string "users" to be <username> and "\n" to symbolize a new line
    }
}
ShowPlayerDialog(playerid,DIALOG_STYLE_LIST,dialogid,"Users",users,"OK","GREAT");
A quick rep would be appreciated for the help.
Reply


Messages In This Thread
Online list - by ArmyOps - 28.02.2012, 23:03
Re: Online list - by Nuke547 - 28.02.2012, 23:09
Re: Online list - by ArmyOps - 29.02.2012, 01:30
Re: Online list - by coole210 - 29.02.2012, 01:53
Re: Online list - by suhrab_mujeeb - 29.02.2012, 01:56
Re: Online list - by Jefff - 29.02.2012, 01:59

Forum Jump:


Users browsing this thread: 1 Guest(s)