Photon JoinRandomRoom(expectedroomproperties, 12) Failed

I have an issue. When Player A creates a room, Player B does not detect that room, and creates their own room. Here’s my code…

public override void OnConnectedToMaster()
        {
            //set my own name and try joining a game
            PhotonNetwork.playerName = PlayerPrefs.GetString(PrefsKeys.playerName);
            Hashtable expectedCustomRoomProperties;
            expectedCustomRoomProperties = new Hashtable() { { "map", 1 } };
            PhotonNetwork.JoinRandomRoom(expectedCustomRoomProperties, 12);
        }
    

        /// <summary>
        /// Called when a joining a random room failed.
        /// See the official Photon docs for more details.
        /// </summary>
        public override void OnPhotonRandomJoinFailed(object[] codeAndMsg)
        {
            Debug.Log("Photon did not find any matches on the Master Client we are connected to. Creating our own room... (ignore the warning above).");
            RoomOptions roomOptions = new RoomOptions();
           
            roomOptions.CustomRoomProperties = new Hashtable() { { "map", 1 } };
            roomOptions.MaxPlayers = 12;
            //joining failed so try to create our own room
            PhotonNetwork.CreateRoom(null, roomOptions, null);
        }

When I remove the expectedCustomRoomProperties, the thing works. But I need some sort of filter so I need that code.

You most likely cannot use regular hashtable for custom room properties. Use stuff like

roomOpts.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable();

see e.g. here:
https://forum.photonengine.com/discussion/8758/how-to-get-customroompropertiesforlobby-and-customroomproperties

2 Likes

Thank you! I’ll try that for now.

1 Like