Question About JoinRandomRoom in SqlLobby

Options
I want a user join a random room with using SQL Filter. But I find that if I put ExpectedCustomRoomProperties and SQLFilter together, the SQLFilter will be ignored. I want to know if I can only use either one of them?
Does it mean that I need to put all ExpectedCustomRoomProperties to C* and compare their equality?

Here is part of my code:
int maxPlayers = 4;
TypedLobby sqlLobby = new TypedLobby("Lobby", LobbyType.SqlLobby);

public void CreateRoom (string roomName, int userLevel)
{
	RoomOptions options = new RoomOptions ();
	options.CustomRoomPropertiesForLobby = new string[3];
	options.CustomRoomPropertiesForLobby[0] = "RN";
	options.CustomRoomPropertiesForLobby[1] = "OP";
	options.CustomRoomPropertiesForLobby[2] = "C0";

	options.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable ();
	options.CustomRoomProperties.Add ("GameRule", "1");
	options.CustomRoomProperties.Add ("C0", userLevel); 	//C0 = User level

	options.MaxPlayers = maxPlayers;

	PhotonNetwork.CreateRoom (roomName, options, sqlLobby);
}

public void JoinRandomRoom()
{
        ExitGames.Client.Photon.Hashtable expectedCustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "GameRule", "1" } };

        string sqlLobbyFilter = "C0 <= " + level;
        PhotonNetwork.JoinRandomRoom(expectedCustomRoomProperties, maxPlayers, MatchmakingMode.FillRoom, 
        sqlLobby, sqlLobbyFilter);
}
The GameRule is for different game mode of a room.
What I want to do is if the room is created by a Player with Level 10, only players with level 10 or higher can join this room. Those below Level 10 cannot join the room.

But if I put GameRule in expectedCustomRoomProperties, the player can join room without checking the Level.
If I pass null to expectedCustomRoomProperties, the player will now check the level and fail to join room if the level do not reached with the room creator.

Does it mean that I need to change "GameRule" to C1 and check in the SQL "C0 <= userLevel And C1 = 1" ?

Best Answer

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @RockYip,

    Thank you for choosing Photon!

    Before I test this and try to reproduce make sure "GameRule" is part of the custom room properties visible from the lobby, which is not the case in your snippet.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @RockYip,

    Did you fix the lobby properties array on room creation?
    Can you tell me what are the results of your tests?
  • RockYip
    Options
    Sorry, I forgot I have posted a question here and thanks for answering .
    I have removed expectedCustomRoomProperties and only use SQL filter in my code.
    It works perfect now .