Sign In Register

How can we help you today?

Start a new topic

Leaderboard - Last Rank

Hello!


"Sorry for my English"


 Tell me how to get and set the last rank?

When updating the leaderboard, with a high score, you can get "rankDetails" and the field "globalTo". How to get this information without a high score

Or, you need to sort the leaderboard list and get that value yourself, but how to set it in LeaderboardData ?

So then I could do this:
  

new LeaderboardDataRequest()
            .SetLeaderboardShortCode("LEADERBOARD")
                .SetEntryCount(100)
                .Send ((response) => {
                    
                    if(!response.HasErrors)
                    {
                        int index = 0;
                        foreach(LeaderboardDataResponse._LeaderboardData entry in response.Data)
                        { 
                            int rank = (int)entry.Rank;  // Get Current Rank // Maybe - #5  
                            int lastRank = (int) entry.BaseData.GetInt("lastRank").GetValueOrDefault(rank);  //Get Last Rank // Maybe  A) #2.  B) #9  C) #5
                            int diff = lastRank - rank;

                            if ( diff < 0)
                            {
                                // A) Change of position    (-3)
                               changePosition[index].text =  "V" + " (" + diff + ")";     // V (-3)
                            }
                            else if (diff > 0)
                            {
                                    // B) Change of position    (+4)
                                changePosition[index].text =  "Λ" + " (" + diff + ")";  // Λ (+4)
                            }
                            else if (diff == 0)
                            {
                                    // C) Without changes   (0)
                                changePosition[index].text =  "=" + " (" + diff + ")";  // = (0)
                            }
                            index++;
                        }
                    }
                });

       Sorry for my English


I do not like how, but I did

 

Before updating the leaderboard, I get the rank using GetLeaderboardEntriesRequest, and after I send it along with the update of Leaderboard

I answered for Cloud code

var Scoresplayer = Spark.getData().Score;

var Levelplayer=Spark.getData().Level;

var requestLB = new SparkRequest.SocialLeaderboardDataRequest();

var responseLB = requestLB.Send();

var requestData = new SparkRequest.LeaderboardDataRespnse();

var responseData = requestData.Send();

var ScoreData = responseData.Score;

var scriptDataLB = responseLB.scriptData;

var scriptDataDB = responseData.scriptData;

var SendPlayerLevel = requestLB.Send().Level;

var SendPlayerScore = requestLB.Send().Score;

var requestmyData = {"SendPlayerLevel":SendPlayerLevel,"SendPlayerScore":SendPlayerScore };

function setRequestData(){ var data = Spark.getData()["requesmyData"]; Spark.setScriptData("scriptData",requestmyData); }

function getRequestData(){

var data =Spark.getData()["scriptData"]["requestmyData"];

return data;

}

Login to post a comment