PostScoreToLeaderboardOnBehalfOf
Post score to another player's score.
| Service | Operation |
|---|---|
| leaderboard | POST_SCORE_TO_LEADERBOARD_ON_BEHALF_OF |
note
This call can be used to create a voting-style leaderboard, where players can vote for another player’s score (i.e., cast a vote for that person). To set it up, create the leaderboard as a Cumulative type, and have each vote increase the target player’s score by +1.
Method Parameters
| Parameter | Description |
|---|---|
| profileId | The profileId of the player to post on behalf of. |
| leaderboardId | The id of the leaderboard. |
| score | The score to post. |
| data | Optional user-defined data to post with the score. |
| forceCreate | Should a new score be created if one doesn't currently exist? |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
// Cloud code only. To view, switch to CC tab
// Cloud code only. To view, switch to CC tab
// Cloud code only. To view, switch to CC tab
// Cloud code only. To view, switch to CC tab
// Cloud code only. To view, switch to CC tab
// Cloud Code only. To view example, switch to the Cloud Code tab
var profileId = "the-profile-id";
var leaderboardId = "the-leaderboard-id";
var score = 10;
var data = {
"nickname": "batman"
};
var forceCreate = false;
var leaderboardProxy = bridge.getLeaderboardServiceProxy();
var postResult = leaderboardProxy.postScoreToLeaderboardOnBehalfOf(profileId, leaderboardId, score, data, forceCreate);
if (postResult.status == 200) {
// Success!
}
{
"service": "leaderboard",
"operation": "POST_SCORE_TO_LEADERBOARD_ON_BEHALF_OF",
"data": {
"profileId": "the-profile-id",
"leaderboardId": "a-leaderboard-id",
"score": 10,
"data": {
"nickname": "batman"
},
"forceCreate": false
}
}