How to use Join random room with filter

Options
I have two working maps that i want users to be able to join , however i am currently using joinRandom so users just join rooms they are not supposed to join.
Can you please help me with a simple script that only uses the max players as a filter because one map should have only 2 max players and the other 4

I am building using the DemoVoice-push to talk scene...the one with the baby and teddybear looking characters showing how to use photon voice (max 4 players)

and the other scene was built using the punBasics scene from the photon realtime (max 2 players)

Please help me

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited January 2017
    Options
    Hi @VictorChildishK,

    You need to use the proper JoinRandom method that sets the expected MaxPlayers:
    void JoinRandomRoom(byte expectedMaxPlayers){
        PhotonNetwork.JoinRandomRoom(null, expectedMaxPlayers, MatchmakingMode.FillRoom, TypedLobby.Default, null);
    }
    Do not forget to set MaxPlayers value when you create rooms:
    void CreateRoom(string roomName, byte maxPlayers){
        RoomOptions roomOptions = new RoomOptions();
        roomOptions.MaxPlayers = maxPlayers;
        PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default);
    }
  • mahmoud93p
    edited February 2018
    Options
    if you want just joinRandomRoom with 1 condition "Maxplayers"
    you can use this


    void JoinRandomRoom(byte MaxPlayers_) { PhotonNetwork.JoinRandomRoom(null, MaxPlayers_); }