Leaderboard APIs
note
Leaderboards must be enabled on a per-game basis. If you'd like to enable them for your games, head to the Leaderboards page.
$msstart.submitGameResultsAsync
The submitGameResultsAsync
API is used to report the result/score that a user achieves during a gameplay session. The API works asynchronously and returns a promise that resolves with a boolean of whether or not the result was succesfully submitted.
This function should be called at the end of a user's gameplay session, or if this is not possible, when they reach a checkpoint/milestone.
The score
must be passed as an integer value:
- For leaderboards with a
score_type
ofNumeric
and a non-zeroscore_decimal_places
, the integer value should include all decimal places as if a decimal were inserted at thescore_decimal_places
position. For example, if you have configured 3 decimal places, submit a raw score of1.337
as1337
. - For leaderboards with a
score_type
configured asDuration
, values should be reported in milliseconds.
Usage
To use the submitGameResultsAsync
API, simply call the function and it will return a promise that resolves to a boolean.
$msstart.submitGameResultsAsync(score).then(result => {
// result will be true if result submitted successfully
});