Joining Random Room with a Specific Number of Max Players

Options
Hi, I was hoping someone could help me. I want to allow players to join a random room with A SPECIFIC NUMBER of max players (since I want to allow 1v1 or 4 player ffa modes). I can create the rooms with a max number of players no problem with the following code:

RoomOptions roomOptions = new RoomOptions ();
roomOptions.isVisible=true;
roomOptions.maxPlayers=4; //or max.Players=2;
PhotonNetwork.CreateRoom (null, roomOptions, TypedLobby.Default);


The problem comes when i try to enter a random room with A SPECIFIC NUMBER of max players (for example i want to enter a random room that has ONLY max players of 2).

Ive tried the following code with no succes (since the second parameter determines the maxnumber of players expected):

PhotonNetwork.JoinRandomRoom (null, (byte) 2);

Ive even tried with the second parameter as an int and not as a byte like: PhotonNetwork.JoinRandomRoom (null, 2); but doesnt works. I keep joining random rooms with max number of players of 4.

How can I achieve this?? what am I doing wrong??

Thank you!

Best regards.

Comments

  • vadim
    Options
    This is bug in PUN.
    Will be fixed and published soon.
    Until that happen, you can fix it in project plugin copy changing line 1677 of Assets\Photon Unity Networking\Plugins\PhotonNetwork\PhotonNetwork.cs:
    replace
    return networkingPeer.OpJoinRandomRoom(expectedRoomProperties, 0, null, matchingType, typedLobby, sqlLobbyFilter);
    with
    return networkingPeer.OpJoinRandomRoom(expectedRoomProperties, expectedMaxPlayers, null, matchingType, typedLobby, sqlLobbyFilter);
  • Tobias
    Options
    I missed this topic and released PUN v1.50 without a fix. Sorry about that.
    I will probably update PUN in the Asset Store in the next days or week.
    I hope the workaround will do. The point is: You need to replace the hard-coded 0 in the OpJoinRandomRoom call with the expectedMaxPlayers. Then it works.
  • Replacing the line worked perfectly! Thanks Vadim, and Exit games team.
  • Tobias
    Options
    Thanks for the feedback.
    I now released PUN 1.50.1 (an update) with this fix, too. So updating won't revert this fix for you.