Two lobbies or rooms that aren't visible to all?

Options
Hi,

I have a Quickmatch option and a Tournament option in my game. When players select either option and create a room using this code:
public void createRoom(){
createroom.interactable = false;
RoomOptions roomOptions = new RoomOptions();
roomOptions.maxPlayers = (byte)MaxPlayer;
PhotonNetwork.CreateRoom (Random.Range(0, 9999).ToString(), roomOptions, null);
}
- The rooms that are created are visible to all players no matter which option they selected and I need the two lobbies or at least the rooms to be separate. i.e. the If you join the lobby via Quickmatch mode you should only see the rooms created in quickmatch and vice versa, Tournament rooms should only be visible to people who joined the lobby via the Tournament option. How do I separate the two?

This is how the lobby is joined for both options (not separate yet because Im not sure how):
public virtual void Start()
{
PhotonNetwork.autoJoinLobby = joinlobby;
}


public virtual void OnConnectedToMaster()
{

PhotonNetwork.JoinRandomRoom();
//PhotonNetwork.JoinLobby(QuickLobby); (I tried creating a custom lobby but that didn't separate the created rooms)

}

Comments

  • nikolabozin
    Options
    I think you can't do JoinRandomRoom() if you want to have this kind of architecture.
    Obviously, because it joins you into a random room without your control.
    And you wanted to control rooms based on whether they are Quick Match or Tournament.

    This would be my workaround.

    First of all, I would have a list of all created rooms. So I can keep track of them. You can find many tutorials about this topic.
    Very important for you is to understand how: OnRoomListUpdate callback works.


    Here is how would possibly I do it.

    In using section add this line:
    using HashtablePN = ExitGames.Client.Photon.Hashtable;

    When creating a room, I would add these lines:

    HashtablePN roomCustomProp = new HashtablePN();
    //if you make a room for quick match, add this line.
    roomCustomProp.Add("isQuickMatch",1);
    //if you make a room for tornament, add this line.
    roomCustomProp.Add("isQuickMatch",0);

    In RoomOptions() add:
    {
    CustomRoomProperties = roomCustomProp
    }

    With this, you separated rooms that are created with a custom property that differs only in value "isQuickMatch".

    What you should do now is to show the client only the rooms based on his mode selected.
    So something for example:

    void showRoomsForMode()
    {
    //roomMode==0 - tournament
    //roomMode==1 - quck match

    object roomMode=0;
    PhotonNetwork.CurrentRoom.CustomProperties.TryGetValue("isQuickMatch", out roomMode);
    if((bool)roomMode == 0)
    {
    //show Tournament rooms;
    }
    else
    {
    //show Quick match rooms;
    }
    }


    And now the client should decide what room to join.
    And of course, you would use PhotonNetwork.JoinRoom(roomName:), and roomName is based on clients selected room.

    I hope it helps.
  • petersenjmp
    Options
    Thank you very much for the detailed explanation. That helps me a lot, I'll get started on it right away :-)