- Home /
Steam Leaderboard delays
I have implemented steam leaderboard in my game. Here is the question. I have 50 levels. Correct me if my steps are wrong.
To get data :
Find leaderboard by name (for each leaderboard) and get the SteamLeaderboard_t object (which is basically the leaderboard reference?)
Then download leaderboard entries from that instance and store it as LeaderboardScoresDownloaded_t object
Now I need to process the LeaderboardScoresDownloaded_t to get an array of LeaderboardEntry_t objects
Process each LeaderboardEntry_t to get my Integer value (Score)
To upload data: 1. Find the leaderboard and get the isntance. 2. Upload the score to that particular instance.
The problem I have is, since these are all async callbacks, I do not always get the data at the right time when I try to download data. The achivements and stats are very straight forward though. Am I doing something wrong with the leaderboard? Why do I always have to find the leaderboard, download leaderboard entries, get the data from the entry and then pass the data to my UI?
Did you try using Coroutines? You can add flags and checks for your specific scenario. It should eli$$anonymous$$ate race conditions.
Hey, So I am trying to imagine how I can work with coroutines in this scenario.
Lets say I have a function updategloballeaderboard();
I want this function to get the current user's score in all the 50 leaderboards (1 leaderboard for each level).
So I am imagining it will be like this
public int m_NumberOf$$anonymous$$erboardretrieved = 0;
IEnumerator Updategloballeaderboard()
{
while(m_NumberOf$$anonymous$$erboardretrieved < 50)
{
while (!Found$$anonymous$$erboard )
{
yield return null;
}
//Found leaderboard instance
GetDownloaded$$anonymous$$erboardentry(m_leaderboardInstance)
while(!Downloadedentries)
{
yield return null;
}
//Debug.Log(Downloaded $$anonymous$$erboard entry);
GetUserScorefromDownloaded$$anonymous$$erboard();
// I get the score and add it to the new total score
// I increment the number of leaderboard processed by 1 and continue until 50
m_NumberOf$$anonymous$$erboardretrieved ++;
yield return null;
}
UploadScore(newScore);
}
Answer by DanBarreno · Dec 02, 2016 at 08:28 PM
IEnumerator WaitingUpToDateToPrint()
{
while (!RankUpToDate )
{
yield return null;
}
foreach (SteamLeaders.UserInRank User in MortalRank.UserList)
{
print("Rank: " + User.UserName + " Name: " + User.UserName + " Score: " + User.UserScore);
}
}
Hey could you tell me what is S$$anonymous$$m$$anonymous$$ers and Userlist? If I am not wrong, you have to find the leaderboard, downloadleaderboard entries, retrieve data and then update the value before you upload right
Your answer
Follow this Question
Related Questions
Can't access to Time.time in callback method AsyncCallback 1 Answer
SceneManager.LoadScene used within promise (or async callback) does nothing 0 Answers
If i use async function, during the await Task.delay() , It starts another task 1 Answer
Unity TCP async functions 0 Answers
TCP Socket Async BeginSend never happens 3 Answers