How can I add the player to the room that has the most person but not full using Photon, I'm working on a multiplayer game that using photon, I read the Photon's page documents but not seems to have any well detailed Infos, What I want is when the player click play, it took him to a server that has most people in it but not full, so it can make gameplay faster and they don't have to wait for other players, any tutorials about this?
Asked
Active
Viewed 137 times
-3
-
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Aug 28 '21 at 01:21
1 Answers
2
use the OnRoomListUpdate
function to keep track of the list of rooms
List<RoomInfo> RoomsInfo { get; set; }
void OnRoomListUpdate(List<RoomInfo> roomList)
{
RoomsInfo = roomList.ToList();
}
Now go throug the list to check that the player count is not full:
// Select non full rooms
var validRooms = RoomsInfo.Where(x => x.PlayerCount != x.MaxPlayers);
// Select the one of the most players
var room = validRooms.OrderByDescending(x => x.PlayerCount).FirstOrDefault();
And that would be the room you want.

derHugo
- 83,094
- 9
- 75
- 115

CorrieJanse
- 2,374
- 1
- 6
- 23