question

Thomas Brown avatar image
Thomas Brown asked

I keep getting a StatisticVersionInvalid response when posting a score with a version. What's the problem?

/**
 * Update the current players score 
 * @param args.statName Name of the statistic to update. 
 * @param args.score The score to post
 * @param context
 * @returns {*}
 */
handlers.updatePlayerScore = function (args, context) {
    var score = args.score;
    var stat = args.statName;
    var version = args.version;
  
    var request = {
        PlayFabId: currentPlayerId, Statistics: [{
            StatisticName: stat,
            Value: score
        }]
    };


  	if(version != null){
      request.Statistics[0].Version = version;
    }
  
    log.debug(request.Statistics);
    return server.UpdatePlayerStatistics(request);
};




Above is my server code i'm using. Unity side i'm sending along an int for the version.

Can someone explain to me why this isn't working?
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

That error is returned if you're trying to write to a statistic version that doesn't exist yet. You can only write to the currently active version of the statistic. The call takes a version to allow you to control whether you actually write to the statistic if it versioned during play.

For completeness, if you try to write to a previous version of the statistic, you'll get the error StatisticVersionClosedForWrites.

1 comment
10 |1200

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

Thomas Brown avatar image Thomas Brown commented ·

Ah got it thanks for the heads up. The versioning system confused me a little bit but after some reading and this post things are adding up.

0 Likes 0 ·

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.