Online list
#1

How can i get all player names who are online and use it in dialog?
Im planing to make wiretransfer system like:
First u get dialog list where u can choose "Wiretransfer" then u get all ppls names in dialog list who are online, and then u get dialog input where u can put amount u want to transfer.
Is it possible at all?
Reply
#2

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");

Reply
#3

Im gonna test it tomorrow, tnx for reply.
Reply
#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
#5

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");

Not gonna work as far as I know.
Reply
#6

pawn Код:
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");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)