question

mihadelo avatar image
mihadelo asked

update and get statistic in same call,Updating and geting same value in one call

Hey in sample code we update and get statistic in same call.

Problem is that returned values are old, not updated values.

Is this bug?

handlers.gameCompletedEvent = function(args) {
	
	var score = args["score"];
	
	var _resp = server.UpdatePlayerStatistics({
		"PlayFabId" : currentPlayerId,
		"Statistics" : [
			{
				"StatisticName": "Local", //This is actually weekly statisticcs
				"Value": score
			},
			{
				"StatisticName": "All",
				"Value": score
			}
		]
	});
	
	var _leaderboardPositionUser = server.GetLeaderboardAroundUser({
		"PlayFabId" : currentPlayerId,
		"StatisticName" : "All", // Weekly
		"MaxResultsCount" : 1
	});
	
	return {
		"UserPosition" : _leaderboardPositionUser.Leaderboard //,
		//"Alltime" : _leaderboardAroundUser_Alltime.Leaderboard
	};
}
,

Hey in sample code we update and get statistic in same call.

Problem is that returned values are old, not updated values.

Is this bug?

handlers.gameCompletedEvent = function(args) {
	
	var score = args["score"];
	
	var _resp = server.UpdatePlayerStatistics({
		"PlayFabId" : currentPlayerId,
		"Statistics" : [
			{
				"StatisticName": "Local", //This is actually weekly statisticcs
				"Value": score
			},
			{
				"StatisticName": "All",
				"Value": score
			}
		]
	});
	
	var _leaderboardPositionUser = server.GetLeaderboardAroundUser({
		"PlayFabId" : currentPlayerId,
		"StatisticName" : "All", // Weekly
		"MaxResultsCount" : 1
	});
	
	return {
		"UserPosition" : _leaderboardPositionUser.Leaderboard //,
		//"Alltime" : _leaderboardAroundUser_Alltime.Leaderboard
	};
}
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

No, the statistic has been updated. You'll find that if you change that leaderboard call to GetPlayerStatistics, that the correct value is returned. However, leaderboards take a second to be updated, since they have more work to do.

It's also worth noting that we do have a backlog item to add the updated values to the returned data on a call to UpdatePlayerStatistics. You can expect to see than in the coming weeks.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.