I’m trying to implement a leaderboard into my game using the LootLocker API. It works when I use a stage leaderboard, however, I can’t get it to work using a live leaderboard. I’m still new to game development so I might be doing something wrong. I keep getting the error that the leaderboard doesn’t exist even though I’m giving it the id that’s within LootLocker, here’s my code:
public static Leaderboard instance;
//Handling showing uploading scores
int leaderboardID = 2892; //used to reference leaderboard
[SerializeField] private TextMeshProUGUI playerNames;
[SerializeField] private TextMeshProUGUI playerScores;
void Start()
{
if(instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
} else
{
Destroy(gameObject);
}
if (playerNames != null || playerScores != null)
{
return;
}
}
//Coroutine to wait for the LoginCo before executing
public IEnumerator SubmitScoreCo(int score)
{
bool done = false;//used to wait until server is done
string playerID = PlayerPrefs.GetString("PlayerID"); //who is uploading score?
//pass in the player, their score, and the leaderboard this information is going to
LootLockerSDKManager.SubmitScore(playerID, score, leaderboardID, (response) =>
{
if(response.success)
{
Debug.Log("Successfully uploaded score");
done = true;
} else
{
Debug.Log("Couldn't upload score: " + response.Error);
done = true;
}
});
yield return new WaitWhile(() => done == false);
}
public IEnumerator FetchHighscoresCo()
{
bool done = false;
//getting the top 10 scores from the leaderboard
LootLockerSDKManager.GetScoreListMain(leaderboardID, 10, 0, (response) =>
{
if (response.success)
{
string tempPlayerNames = "";
string tempPlayerScores = "";
LootLockerLeaderboardMember[] players = response.items;
//set the names and scores from players
for (int i = 0; i < players.Length; i++)
{
tempPlayerNames += players*.rank + ". ";*
//does the player have a name?
if (players*.player.name != “”)*
{
tempPlayerNames += players*.player.name;*
}
else
{
tempPlayerNames += players*.player.id;*
}
_tempPlayerScores += players*.score + "
";*
*tempPlayerNames += "
";
}
done = true;
if(playerNames != null || playerScores != null)
{
playerNames.text = tempPlayerNames;
playerScores.text = tempPlayerScores;
}
}
else
{
Debug.Log("Couldn’t display leaderboard: " + response.Error);
done = true;
}
});*_
yield return new WaitWhile(() => done == false);
}
Any help would be appreciated, and thank you in advance.