Can't reference the hashtable

Options
Need some help referencing a Hashtable I created in the awake function:

So in the Awake function I am trying to set up the custom properties:


public void Awake(){
ExitGames.Client.Photon.Hashtable props = new ExitGames.Client.Photon.Hashtable();
props.Add("score", 0);
PhotonNetwork.player.SetCustomProperties(props);
}



Later, in a function where the player has gotten a point added to his score, I have:

[code]
public void getPoint(){
score = (int)PhotonNetwork.player.CustomProperties["score"];
score++;
PhotonNetwork.player.CustomProperties ["score"] = score;
PhotonNetwork.player.SetCustomProperties(props);
}
[/code]

I get the following error: The name `props' does not exist in the current context

Anyone know how I can reference the props Hashtable?


Comments

  • Hi @wolf,

    when using PhotonNetwork.player.SetCustomProperties(props); the props variable is neither declared nor defined since you only used it inside your Awake() function. If you want to use this in other functions as well you need to declare it as a variable inside the class.

    For the behaviour above you maybe also want to check the PunPlayerScores script which already does what you want to achieve. It is part of the PUN package.