How do I make a player list?

Options
Hi.
I tried to modify this code:
[code2=csharp]scrollPos = GUILayout.BeginScrollView(scrollPos);

foreach (RoomInfo game in PhotonNetwork.GetRoomList())
{
//Sets a string to x/y x is amount of players connected and y is maxplayers
string maxP = game.playerCount + "/" + game.maxPlayers;

//if the maxplayers is less than 1. Set it to the amount of players connected.
if(game.maxPlayers < 1) maxP = "" + game.playerCount;



GUILayout.BeginHorizontal("box");

GUILayout.Label(" " + game.name, GUILayout.Height(buttonHeight), GUILayout.Width(buttonHeight * 8));
GUILayout.Label(" " + maxP, GUILayout.Height(buttonHeight), GUILayout.Width(buttonHeight * 4));

//If the player presses the Join button connect to the game.
if(GUILayout.Button("JOIN", GUILayout.Height(buttonHeight)))
{
PhotonNetwork.JoinRoom(game.name);
}

GUILayout.EndHorizontal();


}

GUILayout.EndScrollView();[/code2]

It's from the Photon angry bots demo.

And I want it to show the players in the room.

How can I do this?

Comments

  • Tobias
    Options
    You can't. In the lobby, we don't provide the players per room.
    Potentially these lists are very long and sending names, too, would take up a lot of bandwidth.
  • Most FPS games has the feature that you can press the Tab key and see a list of players connected to the game, and show their score.
    Isn't this possible to make?

    the game I'm working on allows max 4 players in each room.
  • Tobias
    Options
    In a room, you can do this quite easily, yes. Just check the PhotonNetwork.playerList.
    We don't send the names to the lobby though. Until you're in a room, you can't show the player list usually.

    If you absolutely insist, you could store each player's name in a custom room property and let this sync with the lobby. However, unless a user knows the players, it won't help him much to see the names in the first place.
    Get players into rooms asap to maximize their play time. Don't worry about the room lists. They are not the game.