I am new to using any of the code present in the SDK, and I am fairly new to coding in general.
I am creating a game where I want to upload a time to the leaderboard, using anonymous sign-in, then be able to grab the top 5 values and put them into a basic TMPro leaderboard.
I have been able to upload the times as well as the anonymous names to my dashboard, and I can see them under Entries, but I do not know how to now grab those times. I used the built-in GetScores() method which should give the top 10 scores, but I do not understand the output of it. Could I get some clarification on what is being output? I have looked everywhere for some information, but nothing is helpful for what I’m trying to do.
Let’s take a look at the leaderboard SDK and its API. You use the GetScoresAsync() method to get the scores. Because this is an async method, in order to get the result, you should await it (you can also do coroutines if you want to…) like this: var scoresPage = await LeaderboardsService.Instance.GetScoresAsync("leaderboardName")
Note: I left the LeaderboardOptions out for this example.
This returns an object of type LeaderboardScoresPage which contains a property called Results with a list of LeaderboardEntry objects. These objects are the real entries.
You can then iterate (e.g. with a foreach or a for loop) through the Results property list and get the rank, player name and score like this:
foreach (var leaderboardEntry in scoresResponse.Results)
{
Debug.Log(leaderboardEntry.Rank.ToString());
Debug.Log(leaderboardEntry.PlayerName);
Debug.Log(leaderboardEntry.Score.ToString());
}
How to get player name without # and numbers? like if i call playername it returns rameez#5544
i just want rameez.
Also, is there a way to check in game for players that if there is already a user named rameez, we prompt user to change it?
I am actually making a multiplayer card game, now if a user obtains a card in game, i want to apply certain checks on it like he can not use it for 7 days after gaining and can only use it once in every 12 hours, i am saving card details in the cloud save but how can i save this extra meta data? Should i make leaderboard for every player that holds the meta data for this cloud save?