Submit Scores To Leaderboards
Player type leaderboards are used for your typical ranking of players, be it by score or time trial etc.
For all other types or leaderboards, the generic type leaderboards can be used.
First, go ahead and setup a leaderboard, either in the admin console or using the admin api.
Be aware that when creating a leaderboard it's not shared across your stage and live environment.
If we want to reference the same leaderboard in the code later we can create the same leaderboard in both stage and live, but use the same key, like in the image below.
This way we can hardcode the leaderboard key in our game code and ensure it still works in both environments.

Now we have a leaderboard set up, it's time to submit scores to it. For this there are two ways we can do it. Either from the game client or using a server. If you do not have a server for your game you can submit the score directly from your game, but this can make it easier for bad actors to submit fraudulent scores.
If you're using a server for your game, you want to call the submit score endpoint using the server API. We recommend doing this as it makes it harder for the player to figure out how the leaderboard system works which means it's harder for them to submit fake scores.
We recommend not doing this as it makes it easier for the player to figure out how the leaderboard system works which means it's easier for them to submit fake scores.
To submit a score from your game, first make sure the
Enable Game API writes
toggle is enabled for your leaderboard.Unity
Unreal
REST
string memberID = "20";
int leaderboardID = 123;
int score = 1000;
LootLockerSDKManager.SubmitScore(memberID, score, leaderboardID, (response) =>
{
if (response.statusCode == 200) {
Debug.Log("Successful");
} else {
Debug.Log("failed: " + response.Error);
}
});
You need to exchange the
TriggerSubmitScore
event for whatever event you want to use to trigger this flow.Replace the input variables with the data you want to submit to the leaderboard.
We recommend branching the completed events on the success flag in the response, and if you do this, you will probably want to add error handling in case the request fails as well as what (if any) continued actions you want on success.
curl -X POST "https://api.lootlocker.io/game/leaderboards/1/submit" \
-d "{\"score\": 1000}" \
-H "Content-Type: application/json"
Last modified 6mo ago