How to go about updating CustomPlayerProperties
Options
Good evening all. I have made a little multiplayer game and it's mostly working, I'm just messing around adding things trying new stuff, still in the learning process. Right now I want to create a Panel and with a hit of a button, list every Player's name in the current room, as well as their custom properties. For now the only custom property is a Player's "availableFunds" set up like this:
I had this issue where I placed a "Refresh Button" to create my list inside the aforementioned Panel, but for some reason I was getting the correct result for the LocalUser but a null result for all the other users. After some searching I found out that I actually have to use SetCustomProperties in order to synchronize in the server. So, is this the correct way to set, and sync custom properties for Players inside a room? And if this is the correct way, inside my game I update a player's AvailableFunds many many times, do I have to SetCustomProperties every single time a Player's AvailableFunds change?
Furthermore, why am I declaring a variable in order to set the customproperties at the beggining, when in order to reference those customproperties I just do
public ExitGames.Client.Photon.Hashtable playerProps = new ExitGames.Client.Photon.Hashtable(); void start() { PhotonNetwork.LocalPlayer.CustomProperties = playerProps; playerProps["PlayerMoney"] = startingMoney; PhotonNetwork.LocalPlayer.SetCustomProperties(playerProps); availableFunds = (int)playerProps["PlayerMoney"]; moneyText.text = availableFunds + "M"; }
I had this issue where I placed a "Refresh Button" to create my list inside the aforementioned Panel, but for some reason I was getting the correct result for the LocalUser but a null result for all the other users. After some searching I found out that I actually have to use SetCustomProperties in order to synchronize in the server. So, is this the correct way to set, and sync custom properties for Players inside a room? And if this is the correct way, inside my game I update a player's AvailableFunds many many times, do I have to SetCustomProperties every single time a Player's AvailableFunds change?
Furthermore, why am I declaring a variable in order to set the customproperties at the beggining, when in order to reference those customproperties I just do
foreach (Player player in PhotonNetwork.PlayerList) { Debug.Log(player.CustomProperties["PlayerMoney"]); }Thank you for your time.
0