Using SQL Matchmaking in Unity

Hey!
I'm trying to use SQL Matchmating functionality to split my playerbase.

I set up my room like so -
RoomOptions newRoomOptions = new RoomOptions();

        newRoomOptions.isOpen = true;
        newRoomOptions.isVisible = true;
        newRoomOptions.maxPlayers = 4;
        newRoomOptions.customRoomPropertiesForLobby = new string[] { "1" }; // This changes between 0 and 1

        PhotonNetwork.CreateRoom(ReachNetworking.ReachSteam.SteamID, newRoomOptions, null);

And to join a random room I use this
PhotonNetwork.JoinRandomRoom(null, 4, MatchmakingMode.SerialMatching, null, "C0 = 1");

My problem is it joins a room irrelative of what value I set in the customRoomPropertiesForLobby. I'm sure my understanding of the SQL code is what is wrong!
Thanks,
Myles

Comments

  • Note I've also tried using a string instead,
    PhotonNetwork.JoinRandomRoom(null, 4, MatchmakingMode.SerialMatching, null, "C0 = \"public\"");
    
    newRoomOptions.customRoomPropertiesForLobby = new string[] { "private" };
    
  • I think this is due to a minor misunderstanding.
    The customRoomPropertiesForLobby string[] takes the KEYS of the properties you need in the lobby. Not some values. You are not setting a "C0" value, even though you use it in the matchmaking.

    You need to create a Hashtable and set it as newRoomOptions.customRoomProperties and you have to set "C0" as a property of the lobby. Example:

    [code2=csharp]RoomOptions newRoomOptions = new RoomOptions();

    newRoomOptions.isOpen = true;
    newRoomOptions.isVisible = true;
    newRoomOptions.maxPlayers = 4;
    newRoomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "C0", 1 } }; // C0 might be 0 or 1
    newRoomOptions.customRoomPropertiesForLobby = new string[] { "C0" }; // this makes "C0" available in the lobby

    TypedLobby sqlLobby = new TypedLobby("myLobby", LobbyType.SqlLobby);
    PhotonNetwork.CreateRoom(roomName, newRoomOptions, sqlLobby); // apply the lobby explicitly or PhotonNetwork.JoinLobby() before you create / join rooms[/code2]
  • Ah! This makes much more sense!
    Thanks for taking the time to explain this Tobias :)
Sign In or Register to comment.