To be more precise:
I have the LoginWithAndroidDevice method, which logs the Player in, without the need of an Email or Password, and I wondered if there is a way to check on the Resultcallback, if the Player already has any Statistics created.
If the Player does not have any yet, statistics should be created for him, but if he does, it should be ignored and the Player should be logged in, without the creation or modifying of his/her Statistics.
I tried using the code which Updates the Player Statistics, without giving a Value, but this resets the Stats to 0, every time the Player logs in with the LoginWithAndroidDevice.
public void UpdatePlayerStats() { PlayFabClientAPI.UpdatePlayerStatistics(new UpdatePlayerStatisticsRequest { // request.Statistics is a list, so multiple StatisticUpdate objects can be defined if required. Statistics = new List<StatisticUpdate> { new StatisticUpdate { StatisticName = "PlayerLevel", Value = 1}, new StatisticUpdate { StatisticName = "AttackDamage", Value = 1}, new StatisticUpdate { StatisticName = "PlayerHealth", Value = 1}, new StatisticUpdate { StatisticName = "SpeedLevel", Value = 1}, } }, result => { Debug.Log("User statistics updated"); }, error => { Debug.LogError(error.GenerateErrorReport()); });; }
Is there a way to ask if the StatisticName already exists, and if yes, just skip the new StatisticUpdate?
I imagine it to look something like this in the end (I know that it´s wrong in this example):
public void UpdatePlayerStats() { PlayFabClientAPI.UpdatePlayerStatistics(new UpdatePlayerStatisticsRequest { // request.Statistics is a list, so multiple StatisticUpdate objects can be defined if required. if(Statistics already exist) { //Do nothing and just login } else { Statistics = new List<StatisticUpdate> { new StatisticUpdate { StatisticName = "PlayerLevel", Value = 1}, new StatisticUpdate { StatisticName = "AttackDamage", Value = 1}, new StatisticUpdate { StatisticName = "PlayerHealth", Value = 1}, new StatisticUpdate { StatisticName = "SpeedLevel", Value = 1}, } } }, result => { Debug.Log("User statistics updated"); }, error => { Debug.LogError(error.GenerateErrorReport()); });; }