I'm trying to retrieve player statistic data (xp) from the server side using the GetPlayerStatisticsRequest() but when I go to access the list, the item doesn't seem to exist. Here my code:
function GetPlayerXp(args) { var statisticRequest = server.GetPlayerStatistics({ PlayFabId: currentPlayerId, StatisticNames: [ "xp" ] }); var xp = 0; for (var statistic in statisticRequest.Statistics) { // When going into the loop here, 'statistic' just equals "0" if (statistic.StatisticName == "xp") { xp = statistic.Value; } return xp; }
Now, I know that the request is correct, and it gives me the correct statistics list as shown when I write a title event:
But my problem is that when it goes into the 'for' loop for the list, the 'statistic' variable just equals "0". It's not a StatisticValue type of variable.
How can I access the statistic value from that list (statisticRequest.Statistics) ?