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 was we can hardcode the leaderboard 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.

Submit score from server

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.

Documentation for calling the submit score endpoint can be found here

Submit score from game

To submit a score from your game, first make sure the Enable Game API writes toggle is enabled for your leaderboard.

Unity
Unreal Engine
REST
Unity
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);
}
});
Unreal Engine
REST
curl -X POST "https://api.lootlocker.io/game/leaderboards/1/submit" \
-d "{\"score\": 1000}" \
-H "Content-Type: application/json"