I'm trying to create a statistic for a player if it doesn't exist. (Ideally, I'd like all players to be initialized with the statistic on first login but not sure how to do that.)
The problem is that CreatePlayerStatisticDefinition returns "Player Statistic with the specified name already exists", but when I go to my dashboard under the appropriate player, I can't see that statistic. Are statistic definitions and statistics different?
private void OnPlayerStatCreated(CreatePlayerStatisticDefinitionResult createPlayerStatisticDefinitionResult, string playerPlayFabId) { Debug.LogFormat("Fetching wins."); Action<GetPlayerStatisticsResult> onStatsFetched = result => { foreach (var resultStatistic in result.Statistics) { Debug.Log("Retrieved " + resultStatistic); } var updateRequest = new UpdatePlayerStatisticsRequest { PlayFabId = playerPlayFabId, Statistics = new List<StatisticUpdate> { new StatisticUpdate {StatisticName = MagicIntsAndStringsForSocialGaming.Wins, Value = result.Statistics.First(x=>x.StatisticName == MagicIntsAndStringsForSocialGaming.Wins).Value + 1} }, }; PlayFabServerAPI.UpdatePlayerStatistics(updateRequest, statisticsResult => { }, ConnectionErrorHandler.HandlePlayFabError); }; Debug.LogFormat("Updating wins."); var fetchRequest = new GetPlayerStatisticsRequest { PlayFabId = playerPlayFabId }; PlayFabServerAPI.GetPlayerStatistics(fetchRequest, onStatsFetched, ConnectionErrorHandler.HandlePlayFabError); } // TODO: Lots of refactorings!!!! private void UpdateWins(Player player) { Debug.LogFormat("Creating wins for {0}.", player.Number); var id = player.PlayFabId; PlayFabAdminAPI.CreatePlayerStatisticDefinition(new CreatePlayerStatisticDefinitionRequest() { AggregationMethod = StatisticAggregationMethod.Sum, StatisticName = MagicIntsAndStringsForSocialGaming.Wins }, result => { OnPlayerStatCreated(result, id);}, ConnectionErrorHandler.HandlePlayFabError); }