make disappear room which has maximum player connected

Hi,.

I am making realtime multiplayer game using photon networking.

How to make disappear room which has max player connected ?

I am using following function to make text(list) empty which room has full :

void   OnReceivedRoomListUpdate()
{
	roomList.text = "";
	RoomInfo[] rooms = PhotonNetwork.GetRoomList ();
	Debug.Log (rooms.Length);
	foreach(RoomInfo room in rooms)
	{
		Debug.Log(" from on received room list update");;
		roomList.text += room.name + "

";
}
}

To make visible false I am doing following :

    public void OnPhotonPlayerConnected(PhotonPlayer player)
{	
	if (PhotonNetwork.player.isMasterClient) 
	{
		RoomInfo[] rooms = PhotonNetwork.GetRoomList ();
		foreach (RoomInfo room in rooms)
		{
			if(room.playerCount == 2)
			{
				PhotonNetwork.room.visible = false;
				PhotonNetwork.room.open = false;
				roomList.text = "";
			}
		}
	}
}

But still not able to make room visible false.

Please help

Thanks in advance

You use PhotonNetwork.GetRoomList() from the lobby, not within the room.

The example in my original answer shows how to get this information while in the lobby. Making the room visible is still the same as in your other question.

Related Question : Photon multiplayer room make disappear in lobby when room is getting full - Questions & Answers - Unity Discussions


Original Question :

get no of connected player of room in lobby in photon

Hi,.

I am making realtime multiplayer game using photon networking.

is there any method to get no of connected player list in room from lobby ?

how to check room joined players in lobby in photon network ? i.e room1
Topics: photon,networking,realtime,multiplayer

Answer :

Poll for the RoomInfo from the lobby with GetRoomList.

http://doc-api.exitgames.com/en/pun/current/class_photon_network.html#aeef2085375accb7d4bc88e60cbe15eb9

The RoomInfo contains a lot of information :

http://doc-api.exitgames.com/en/pun/current/class_room_info.html

Use this to get the name, current players in room and max player count (untested example code) :

RoomInfo[] roomInfo = PhotonNetwork.GetRoomList();

for ( int i = 0; i < roomInfo.Length; i ++ )
{
	roomText = roomInfo[ i ].name + " (" + roomInfo[ i ].playerCount + "/" + roomInfo[ i ].maxPlayers + ")";
}

would display AwesomeRoom (2/4)