Search Unity

Third Party Unity PUN 2 - LoadBalancingPeer.OpCreateRoom (Custom Properties)

Discussion in 'Multiplayer' started by xrjguajardo, Dec 15, 2018.

  1. xrjguajardo

    xrjguajardo

    Joined:
    Jan 25, 2014
    Posts:
    3
    Hi,

    I'm creating a room using the method:

    LoadBalancingClient.OpCreateRoom(EnterRoomParams params);


    this is my code:


    Code (CSharp):
    1.  public void CreateRoom(string roomName, int maxNumberOfPlayers, VisibilityMode gameRoomMode, string gameMode, string password = "")
    2.     {
    3.         RoomOptions options = new RoomOptions();
    4.         options.MaxPlayers = (byte)maxNumberOfPlayers;
    5.         Hashtable customProperties = new Hashtable();
    6.         customProperties.Add(roomVisibilityMode, gameRoomMode.ToString());
    7.         customProperties.Add(roomGameMode, gameMode);
    8.         if (gameRoomMode == VisibilityMode.PUBLIC)
    9.         {
    10.  
    11.         }
    12.         else if (gameRoomMode == VisibilityMode.PRIVATE)
    13.         {
    14.             customProperties.Add(roomPassword, password);
    15.         }
    16.  
    17.         options.CustomRoomProperties = customProperties;
    18.  
    19.         client.CreateRoomWithOptions(roomName, options);
    20.     }
    Code (CSharp):
    1. public void CreateRoomWithOptions(string name, RoomOptions options)
    2.     {
    3.         EnterRoomParams enterRoomParams = new EnterRoomParams();
    4.         RoomOptions roomOptions = options;
    5.         roomOptions.IsVisible = true;
    6.         roomOptions.IsOpen = true;
    7.         enterRoomParams.Lobby = typedLobby;
    8.         enterRoomParams.RoomName = name;
    9.         enterRoomParams.RoomOptions = roomOptions;
    10.    
    11.         OpCreateRoom(enterRoomParams);
    12.    
    13.     }
    then I try to retrieve the information sent as part of RoomOptions in another client when the RoomList is retrieved:


    Code (CSharp):
    1. public void UpdateRoomList(List<RoomInfo> roomList, GameRoomMode mode)
    2.   {
    3.         int indexDataDisplayed = 0;
    4.         for (int x = 0; x < roomList.Count; x++)
    5.         {
    6.            string mGameMode= roomList[x].CustomProperties[NetworkManager.roomGameMode].ToString();
    7. //more code....
    8.          }
    9. }
    but CustomProperties is always null... I can confirm that the first room that I get in the list is in fact the one that I have created in another client (at least the name of the room is the same)

    Am I doing something wrong? .....

    If I access this property "networkManager.Client.CurrentRoom.CustomProperties" within the client that has created the room, the CustomProperties are displayed correctly.

    Any Ideas?

    Thanks for the help, regards.
     
  2. xrjguajardo

    xrjguajardo

    Joined:
    Jan 25, 2014
    Posts:
    3
    I have aleready solved it.... In order to display the custom properties in the lobby you also need to fill the CustomRoomPropertiesForLobby...

    Code (CSharp):
    1. options.CustomRoomPropertiesForLobby = new string[] { roomGameMode, roomVisibilityMode, roomPassword };
     
    MechEthan likes this.