for(new i = 0; i < MAX_PLAYERS; i++)
{
new name[MAX_PLAYER_NAME], string[126];
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s\n%s",name);
showplayerdialog(playerid, DIALOG_STYLE_LIST, casenumber, "Users", string, "Select", "Cancel");
}
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 код:
|
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");
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 код:
|
new name[MAX_PLAYER_NAME], string[MAX_PLAYER_NAME * YOUR_SERVER_SLOTS]; // YOUR_SERVER_SLOTS more than 50 is very big
for(new i,g = GetMaxPlayers(); i < g; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, name, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s%s\n",string,name);
}
}
ShowPlayerDialog(playerid, dialog_ID, DIALOG_STYLE_LIST, "Users OnLine", string, "Select", "Cancel");