leaderboard error

Hello community! good afternoon.
I want to ask you a question, because I am learning the world of photon.

I'm trying to do a better time table.
the idea is to compare which of the two players passes the goal first

I use a trigger to detect: username, country and time.

username and country, it works correctly. but time is not saved ...

using debug.log () the time is previously marked to save, but then upon request, it marks me 0.

Someone to give me a hand and explain a little? Thank you so much!

code:

void SetScore(Player photonPlayer, float tiemponline) {
Debug.Log(tiemponline);
photonPlayer.SetCustomProperties(new ExitGames.Client.Photon.Hashtable(id) { { "tiempo" + id, tiemponline } });
}

void SetPais(Player photonPlayer, string pais) {
photonPlayer.SetCustomProperties(new ExitGames.Client.Photon.Hashtable(1) { { "pais" + id, pais } });
}
void SetName(Player photonPlayer, string name) {
photonPlayer.SetCustomProperties(new ExitGames.Client.Photon.Hashtable(1) { { "nombre" + id, name } });
}

private void DisplayPlayerList() {
usuariostot.Clear();
for (int i = 0; i < PhotonNetwork.PlayerList.Length; i++) {
Player player = PhotonNetwork.PlayerList;

usuariostot.Add(new uspic());

if (player.CustomProperties["tiempo" + i] != null) {
usuariostot.tiempo = (float)player.CustomProperties["tiempo" + i];
Debug.Log((float)player.CustomProperties["tiempo" + i]);
} else {
usuariostot.tiempo = 0;
}

if (player.CustomProperties["pais" + i] != null)
usuariostot.pais = (string)player.CustomProperties["pais" + i];
else usuariostot.pais = "Argentina";

if (player.CustomProperties["nombre" + i] != null)
usuariostot.usuario = (string)player.CustomProperties["nombre" + i];
else usuariostot.usuario = player.NickName;

// if (usuariostot != null)
// usuariostot.Sort((p, q) => string.Compare(p.tiempo.ToString(), q.tiempo.ToString()));

tiempos.text = usuariostot.tiempo + " Seg";
paises.text = usuariostot.pais;
usuarios.text = usuariostot.usuario;
}
}

public void OnTriggerEnter(Collider other) {
if(other.tag == "ref" && isEndRace) {
for(int i = 0; i < PhotonNetwork.PlayerList.Length; i++) {
Player player = PhotonNetwork.PlayerList;
if(and.username == player.NickName) {
id = i;
// break;
}
}

string tiempo = System.Math.Round(largada.timeronline, 3).ToString();
float tpm = float.Parse(tiempo);
SetScore(PhotonNetwork.LocalPlayer, tpm);
SetPais(PhotonNetwork.LocalPlayer, and.pais);
SetName(PhotonNetwork.LocalPlayer, and.username);

passed = passed + 1;

if (passed == 2) {
StartCoroutine(obtenerTiempos());

this.GetComponent<BoxCollider>().enabled = false;
}
}

if(other.tag == "object") {
passed = passed + 1;
if (passed == 2) {
StartCoroutine(obtenerTiempos());

this.GetComponent<BoxCollider>().enabled = false;

}
}
}

IEnumerator obtenerTiempos() {
yield return new WaitForSeconds(2.25f);
DisplayPlayerList();
}
}
Sign In or Register to comment.