CustomRoomPropertiesForLobby is not working

Options
AT1LLA
AT1LLA
Here is how i create my room:
public void CreateRoom(){
        LobbyOptions = new string[2];
        LobbyOptions[0] = MapIndex;
        LobbyOptions[1] = GameModeIndex;
        

        RoomOptions roomOptions = new RoomOptions();
        roomOptions.IsVisible = true;
        roomOptions.IsOpen = true;
        roomOptions.MaxPlayers = (byte)MaxPlayersIndex;
        roomOptions.CustomRoomPropertiesForLobby = LobbyOptions;

        PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default);
}
Here is how I get my rooms:
public override void OnReceivedRoomListUpdate()
    {
        Debug.Log("GET ROOMS: " + PhotonNetwork.GetRoomList().Length);

        foreach (RoomJoiner roomButton in rooms)
        {
            Destroy(roomButton.gameObject);
        }
        rooms.Clear();
        int i = 0;
        foreach (RoomInfo room in PhotonNetwork.GetRoomList())
        {
            if (!room.open)
                continue;
            GameObject roomButton = Instantiate<GameObject>(roomButtonPrefab);
            roomButton.GetComponent<RoomJoiner>().RoomName = room.name;
            string info = room.name.Trim() + " (" + room.playerCount + "/" + room.maxPlayers + ")";
            Debug.Log(info);
            Debug.Log("room.CustomProperties.Count " + room.CustomProperties.Count);
            roomButton.GetComponentInChildren<Text>().text = info;
            rooms.Add(roomButton.GetComponent<RoomJoiner>());
            roomButton.transform.SetParent(ServerListPanel, false);
            roomButton.transform.position.Set(0, i * 120, 0);
        }
}
CONSOLE
room.CustomProperties.Count 0

Am I doing something wrong? Thanks.

Best Answer

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited February 2017 Answer ✓
    Options
    Did you try merging my suggestion with your code?
    Room properties are key/values where keys are strings.
    Something like this:
    public void CreateRoom(){
            LobbyOptions = new string[2];
            LobbyOptions[0] = MapIndexKey;
            LobbyOptions[1] = GameModeIndexKey;
            ExitGames.Client.Photon.Hashtable customProperties = new ExitGames.Client.Photon.Hashtable() {
    		{ MapIndexKey, mapIndexValue }, { GameModeIndexKey, gameModeIndexValue }
    	};
            RoomOptions roomOptions = new RoomOptions();
            roomOptions.IsVisible = true;
            roomOptions.IsOpen = true;
            roomOptions.MaxPlayers = (byte)MaxPlayersIndex;
            roomOptions.CustomRoomPropertiesForLobby = LobbyOptions;
            roomOptions.CustomRoomProperties = customProperties;
            PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default);
    }

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @AT1LLA,

    Thank you for choosing Photon!

    Please try setting values to those custom room properties when creating the room.
    ExitGames.Client.Photon.Hashtable roomSettings = new ExitGames.Client.Photon.Hashtable() {
    		{ MapIndex, mapIndex }, { GameModeIndex, gameModeIndex }
    	};
    roomOptions.CustomRoomProperties = roomSettings;
  • AT1LLA
    Options
    Hi @JohnTube ,
    Sorry I didn't explained myself. I want to create a lobby. I will have some string variables like GameMode and Map. I want to show them in lobby. I tried your script but it didnt work. I tried
    roomOptions.CustomRoomProperties = new string[] { "1", "2", "3" };
    just to test but it alse didnt work. I think my problem is hov i get the values.
    I do
    Debug.Log("room.CustomProperties.Count " + room.CustomProperties.Count);
    as the sctipt i posted. Thank you for your answer.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited February 2017 Answer ✓
    Options
    Did you try merging my suggestion with your code?
    Room properties are key/values where keys are strings.
    Something like this:
    public void CreateRoom(){
            LobbyOptions = new string[2];
            LobbyOptions[0] = MapIndexKey;
            LobbyOptions[1] = GameModeIndexKey;
            ExitGames.Client.Photon.Hashtable customProperties = new ExitGames.Client.Photon.Hashtable() {
    		{ MapIndexKey, mapIndexValue }, { GameModeIndexKey, gameModeIndexValue }
    	};
            RoomOptions roomOptions = new RoomOptions();
            roomOptions.IsVisible = true;
            roomOptions.IsOpen = true;
            roomOptions.MaxPlayers = (byte)MaxPlayersIndex;
            roomOptions.CustomRoomPropertiesForLobby = LobbyOptions;
            roomOptions.CustomRoomProperties = customProperties;
            PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default);
    }
  • AT1LLA
    Options
    Oh, I did it thank you :smile: