Update room's custom properties?

I am currently using the room's custom properties to hold the list of users and various stats about them, the issue I am having is that when I remove a user and his data from the hashtable, the next user to connect not only adds their data but also all the previous users data. When is PhotonNetwork.room.customProperties updated? Is there a way I can fetch the up to date version of the custom properties most recently set by room.setCustomProperties? I notice the cache method but I am not sure what it does or how to use it.

Comments

  • The issue I seem to be having is when a player disconnects and the master updates the room properties using PhotonNetwork.room.setCustomProperties, the information is not synced to other players, which is curious, because when each player connects and they change the room properties, those changes are synced. I am using void OnPhotonPlayerDisconnected when a player disconnects, does that have anything to do with the properties not being updated?
  • I don't know enough yet to try to reproduce the issue. What exactly is the master trying to set when a player leaves?

    Actually, for this case you could better use the player custom properties. They can be set by a player and get cleaned up when the player leaves, too. The workflow is basically the same but you can even set player properties before you join a room (which makes then synced immediately on join).

    Maybe you can describe what the master tries to achieve and then head on to use player properties.
  • Well essentially I just have a set of keys labelled "1" - "9" that hold each player's controlling object's id. That way if I want to do something to player 2 on team 3 I can just look up the key "8" under the custom properties hashtable. I dont think it would be easier to set each player's properties because iterating through is not as easy. I can easily send you the code if you like, there isn't much to it, but it isn't really your job to debug my code.
  • Unless I miss something, you don't have to set properties for the objects controlled by players. At least not, if those objects have a PhotonView.
    The PhotonView's viewId is a composition of the player's ID (* 1000) plus a sequence number. Even better: PhotonView.owner will get you the player who owns an object.
    There's a callback when a GO is created and you could use that to generate a list of PhotonViews and per owner?
  • In my game, each player creates a control object that has various methods to affect the player's object. These control objects do have a photon view attached to them. I know that this control object is always going to be the first object spawned by a player with a photon view, so I could just call the players id x 1000 + 1, but then I would miss out on one feature that I liked in the hashtable: the key number represented the team the player was on and I could simply call containsKey to find if a player occupied a team slot. I guess I can use findObjectsOfType and then go through each control object and see which slot it occupies. I may go to that instead, but is it not a fair amount slower?

    I could use the callback generated, but wouldn't I then have to send that information for GO to some place to store it where it can be called on all clients? (CustomProperties?)
  • Not sure if I understand correctly and either way: I just wanted to throw in some ideas :)

    If you use a GO to control others, then you should create and maintain the list of objects controlled. You shouldn't need to findObjectsOfType and you are right to avoid it in-game where possible.

    If you use PhotonViews on GOs, then the owner is always known per GO and through the owner you could get the custom player property "team", too. You can control those GOs through your control object while the individual GOs don't send anything themselves.