Making a team based scoreboard
Options
I've made a scoreboard which shows the players in a game
That if statement doesn't do what I initially thought it would, it just sets all players to be on one team (on the scoreboard at least) to what ever team the local player selected.
I tried to do a foreach statement for the players custom properties so it would display as I would like but it just throws up errors, I've searched around here and I haven't found help for this specific question.
So basically what I'm asking it how would I reference a players custom property in a foreach statement? I think that's what I need.
void OnGUI () { Hashtable PlayerCustomProps = new Hashtable(); if (sb == true){ GUI.Box(new Rect(Screen.width/2f +50, Screen.height /2f -250, 400, 500),""); GUILayout.BeginArea(new Rect(Screen.width/2f +50, Screen.height /2f -225, 400, 450)); GUILayout.Box ("Red"); if((int)PhotonNetwork.player.customProperties["team"] == 0){ foreach (PhotonPlayer game in PhotonNetwork.playerList){ GUILayout.Label(PhotonNetwork.playerName + " " + PhotonNetwork.player.customProperties["goals"] + " " + PhotonNetwork.GetPing()); } } GUILayout.EndArea(); GUI.Box(new Rect(Screen.width/2f -450, Screen.height /2f -250, 400, 500),""); GUILayout.BeginArea(new Rect(Screen.width/2f -450, Screen.height /2f -225, 400, 450)); GUILayout.Box ("Blue"); if((int)PhotonNetwork.player.customProperties["team"] == 1){ foreach (PhotonPlayer game in PhotonNetwork.playerList){ GUILayout.Label(PhotonNetwork.playerName); } } GUILayout.EndArea(); } } }
That if statement doesn't do what I initially thought it would, it just sets all players to be on one team (on the scoreboard at least) to what ever team the local player selected.
I tried to do a foreach statement for the players custom properties so it would display as I would like but it just throws up errors, I've searched around here and I haven't found help for this specific question.
So basically what I'm asking it how would I reference a players custom property in a foreach statement? I think that's what I need.
0
Comments
-
Use loop iterator for getting and setting properties instead of PhotonNetwork.player:
foreach (var player in PhotonNetwork.playerList) { var prop = player.customProperties["propName"]; player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { "propName", newPropValue } }); var playerName = player.name; }
0