Skip to content

Concurrent Players

LootLocker SDKs support managing multiple concurrent users in your game. This is useful for local multiplayer, hot seat, or any scenario where more than one player is authenticated at the same time.

Prerequisites

  • Unity, Unreal, or Godot SDK installed and configured in your project (not required for REST).

How It Works

Whenever you successfully authenticate a player (using any supported authentication method), the SDK automatically adds or updates that player's session in the multi user state — you don't need to manually add users, just authenticate them as usual.

Each player is tracked by their ULID, and you can make API calls for a specific player by providing their ULID.

Start Concurrent Sessions and Submit Scores

This example is simplified and abstracts away the game logic that would go between these two events — it's here to show how to make requests when there are multiple local users.

While we recommend always passing the ULID of the player you want to make a request for, this example also includes a request to fetch the current scores using the default player, to show the difference between performing a request on behalf of a specific player versus the default player.

// Replace with your actual leaderboard key
public static string leaderboardKey = "your_leaderboard_key_here";
public void OnLoginButtonPressed()
{
// Replace with your actual player identifier retrieval logic
string guest_player_identifier = GetGuestIdentifierFromInput();
if (string.IsNullOrEmpty(guest_player_identifier))
{
Debug.LogWarning("Please enter a valid guest player identifier.");
return;
}
LootLockerSDKManager.StartGuestSession(guest_player_identifier, response =>
{
if (!response.success)
{
Debug.LogError($"Login failed: {response.errorData}");
return;
}
Debug.Log($"Login successful for guest player: {guest_player_identifier} with ulid {response.player_ulid}. The default player ulid is {LootLockerSDKManager.GetDefaultPlayerUlid()}");
});
}
public void OnShowScoresButtonPressed()
{
// Fetch the top 10 scores from the leaderboard, while we recommend always specifying which player
// you want to make the request for, this is an example of making a request for the default player (simply not specifying a player).
LootLockerSDKManager.GetScoreList(leaderboardKey, 10, 0, response =>
{
if (!response.success)
{
Debug.LogError($"Failed to retrieve scores: {response.errorData}");
return;
}
Debug.Log($"Scores retrieved successfully: {response.text}");
// Replace with your actual UI display logic
DisplayScoresInUI(response.items);
}/*, lootLockerPlayerUlid <- To make the request for a specific player you'd add this parameter*/);
}
public void OnMatchFinished_SubmitScores()
{
// Replace with your actual game logic
MatchData matchData = GetCurrentMatchData();
foreach (var playerScore in matchData.PlayerScores)
{
// Submit each player's score to the leaderboard
LootLockerSDKManager.SubmitScore("", playerScore.Score, leaderboardKey, response =>
{
if (!response.success)
{
Debug.LogError($"Failed to submit score for player {playerScore.PlayerId}: {response.errorData}");
}
else
{
Debug.Log($"Score submitted successfully for player {playerScore.PlayerId}: {response.text}");
}
}, /* IMPORTANT: */ playerScore.LootLockerPlayerULID /* This makes the score submission for *this* player */);
}
}

Conclusion

You can now authenticate and make requests for multiple concurrent local users, targeting each by their player ULID.