handlers.UpdateTotalRanking = function(args){ var result = server.GetPlayerProfile( {PlayFabId: currentPlayerId, ProfileConstraints: {ShowLocations: true}} ); var profile = result.PlayerProfile; var gameMode = args.gameMode; var totalScore = 0; debug.log(profile.Statistics.Count); var i = 0; for(i;i<profile.Statistics.Count;i++){ var name = profile.Statistics[i].Name; debug.log(name); if(name.includes(gameMode)){ debug.log("TRUE"); totalScore+=profile.Statistics[i].Value; } } if(totalScore>0){ log.info("UPDATETOTALSCORE"); var req = { PlayfabId:currentPlayerId, Statistics : [{ StatisticName : "TotalRank"+gameMode, Value : totalScore }] } return server.UpdatePlayerStatistics(req); } return profile; };
When user statistics are updated, I want to set the sum of other statistics to total ranking. But this code doesn't work. I want your help.