Custom room properties update question

Options
Hello, currently I'm setting up a menu where game options such as frags, time limit can be set to the custom room properties. Since different game modes such as DM and CTF will have a different number of options, the custom room options will differ in size when switching between modes. e.g. DM room options [frags=10,time=10], CTF room options [points=10,time=10]. What I'll do on the master side when changing game modes is clear the room options then get the all the new modes options and add them to the room options before using SetCustomProperties(). This works on the master, but on the client it seems any differences are only updated and/or added to their room options e.g. when switching from DM to CTF: Master [frags=10,time=10], client(s) [frags=10,time=10,points=10], ideally the client should match the master. Is there an option to replace client room options rather than update or do I have to make my own system that updates the clients room options manually once an update is detected?

Comments

  • why don't you have a Multiplayer_GameManager in the scene that checks for: OnPlayerPropertiesUpdate
    it would look something like:
    public override void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps)
        {
            if (!PhotonNetwork.IsMasterClient)
            {
                return;
            }
            foreach (Player p in PhotonNetwork.PlayerList)
            {
                p.SetCustomProperties(changedProps);
            }
        }
    
    This way, all you have to do is update the master clients customProperties and everyone in the rooms will update to the same
  • Iamspiff
    Options
    Aren't player properties different from room properties? I want all players to get the same game option updates, so changing the room property seemed like the ideal solution. Will the set custom player properties method not do the same thing as set custom room properties in that it only updates/adds what's already set?
  • ahh i see whatcha mean there, was a little mistaken.

    should be something like this than:
    if (PhotonNetwork.IsMasterClient)
            {
                ExitGames.Client.Photon.Hashtable customPropreties = new ExitGames.Client.Photon.Hashtable();
                customPropreties[GAME_MODE_PROP_KEY] = gmValue;
                PhotonNetwork.CurrentRoom.SetCustomProperties(customPropreties);
            }
    
  • Iamspiff
    Options
    Yeah, I've already done this, what I'm saying is that it seems only new items or changes are updated to the clients room properties. For example the current mode is Deathmatch so the hashtable would look like this: [frag=10,time=10], I(as the master, clients cannot change game mode options) change the mode to CTF the room properties will gather all the default CTF options(I've implemented this logic already) and SetCustomProperties with a new hashtable that looks like this [point=10,time=10]. Side note: On the master client, I made it so when a mode change occurs, the previous room properties are basically cleared removing all items, before adding anything new. The room properties on the master look fine [point=10,time=10], but the clients end up as [frag=10,point=10,time=10], frag should not be there. So my question is, is there some way to have room property update functionality overwrite client room properties or do I have do some kind of out of the way work around?
  • hmm try resetting the properties to the roomOptions and then broadcasting them
    ExitGames.Client.Photon.Hashtable customPropreties = new ExitGames.Client.Photon.Hashtable();
            customPropreties[GAME_MODE_PROP_KEY] = gmValue;
            RoomOptions roomOptions = new RoomOptions()
            {
                CustomRoomProperties = customPropreties, IsVisible = true, IsOpen = true MaxPlayers = 5, CleanupCacheOnLeave = false
            };
            roomOptions.CustomRoomPropertiesForLobby = new string[]
            {
                 GAME_MODE_PROP_KEY
            };
            roomOptions.BroadcastPropsChangeToAll = true;