SetPropertiesListedInLobby in room

Options
it is a turnbased card game, I added some bots in game and having a customproperties (room) playerlist so that we can have bots and players in room, my problem is , any way to add player + bots numbers at getroomlist ?
I tried SetPropertiesListedInLobby but it seems cannot use this in room.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited April 2019
    Options
    Hi @kt2,

    Thank you for choosing Photon!

    I tried SetPropertiesListedInLobby but it seems cannot use this in room.
    Room.SetPropertiesListedInLobby works only when you are joined to that room. This method decides what custom properties keys should be visible to the lobby. If you want to change the actual custom properties use Room.SetCustomProperties.
  • kt2
    kt2
    edited April 2019
    Options
    I get it , thanks!
    public override void OnJoinedRoom() {
      if (PhotonNetwork.isMasterClient) {
        PhotonNetwork.room.SetPropertiesListedInLobby(new string[] { "custom_num" 
      });		
        Hashtable props = new Hashtable();
        props["total"] = myCustomPlayerList.Count;
        PhotonNetwork.room.SetCustomProperties(props);
      }
    }
    
    public void inRoomList() {
      if (PhotonNetwork.GetRoomList().Length > 0) {
        foreach (RoomInfo room in PhotonNetwork.GetRoomList()) {
          custom_num = (int)room.CustomProperties["custom_num"];
        }
    }