HOW TO? Skill based matchmaking

Options
Hello so i've been looking through the forums and cant find any answer to this other than a link to "http://doc.exitgames.com/en/realtime/current/reference/matchmaking-and-lobby" which i do not need as i've already seen this, and still need help understanding how to do it so please do not post that as the answer to this.

I'm currently trying to set up 2 player rooms that players join "randomly" based on being within a range of their player rank.
	void OnJoinedLobby() {
		RoomOptions newRoomOptions = new RoomOptions();
		newRoomOptions.isOpen = true;
		newRoomOptions.isVisible = true;
		newRoomOptions.maxPlayers = 2;
		// C0 is the players rank
		newRoomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "C0" } };
		newRoomOptions.customRoomPropertiesForLobby = new string[] { "C0" }; // this makes "C0" available in the lobby

		TypedLobby sqlLobby = new TypedLobby(null, LobbyType.SqlLobby);
		string sqlLobbyFilter = "(C0 > (PlayerRank - 50) AND C0 < (PlayerRank + 50))";
		PhotonNetwork.JoinRandomRoom(null, 2, MatchmakingMode.FillRoom, sqlLobby, sqlLobbyFilter);
[code=csharp]

I dont understand exactly how this works, as PlayerRank would be an Int Variable, but it being between the " " i dont think it'd register. is there anywhere to get s tep by step tutorial on how to do this? because from what i've found it seems there is nothing more than a short vague paragraph on how to set this up.

Comments

  • vadim
    Options
    Hi,

    In your code, C0 is the room property representing room skill level. During room creation, you should set it to the value which will be compared with player rank during random matchmaking. You code would not compile because you do no set this value in Hashtable assigned to newRoomOptions.customRoomProperties.
    Putting PlayerRank into query string does not make sense since only C0-C9 and integer constants allowed. Replace PlayerRank with actual player rank.
    When PhotonNetwork.JoinRandomRoom get called, expression calculated for each available room C0 and room assigned if condition met for that room C0.
  • can you show me an example of how to set the value to PlayerRank? that's the very issue im having problems with. i don't 100% understand how customRoomProperties, or hashtables work.
  • vadim
    Options
    In case PlayerRank = 300
    instead of
    string sqlLobbyFilter = "(C0 > (PlayerRank - 50) AND C0 < (PlayerRank + 50))";
    
    set
    string sqlLobbyFilter = "(C0 > 250 AND C0 < 350)";
    
    'C0' set for the room will be substituted into expression and room will be filtered depending on result.
  • void PlayBtnPress() {
    //PhotonNetwork.JoinRandomRoom();
    RoomOptions newRoomOptions = new RoomOptions();
    newRoomOptions.isOpen = true;
    newRoomOptions.isVisible = true;
    newRoomOptions.maxPlayers = 2;
    string sqlLobbyFilter = "C0 = null";
    // C0 is the players rank
    if (Player.GetComponent<PlayerStats> ().playerRank <= 1149) {
    newRoomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "C0", "Bronze" } };
    newRoomOptions.customRoomPropertiesForLobby = new string[] { "C0" }; // this makes "C0" available in the lobby
    string sqlLobbyFilter = "C0 = Bronze"; // find a game with rank
    }
    if (Player.GetComponent<PlayerStats> ().playerRank >= 1150 && Player.GetComponent<PlayerStats> ().playerRank <= 1499) {
    newRoomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "C0", "Bronze" } };
    newRoomOptions.customRoomPropertiesForLobby = new string[] { "C0" }; // this makes "C0" available in the lobby
    string sqlLobbyFilter = "C0 = Silver"; // find a game with rank
    }
    PhotonNetwork.JoinRandomRoom(null, 4, MatchmakingMode.FillRoom, null, sqlLobbyFilter);
    }

    So this is the code i have, but i get an error when i do "string sqlLobbyFilter = "Something"
    i get this error: "error CS0136: A local variable named `sqlLobbyFilter' cannot be declared in this scope because it would give a different meaning to `sqlLobbyFilter', which is already used in a `parent' scope to denote something else"