Sign In Register

How can we help you today?

Start a new topic
Answered

Request response, GSData and BaseData

I am new to GameSparks and I am just combing through the Documentation, Tutorials, API and Forums trying to understand the proper ways for getting the data I need for my game. I am developing the game in Unity. For example, I want to get the rank for the current player. Here are the two methods I found that work:


public void GetLeaderboardScore(string _boardShortCode)
    {
        new GetLeaderboardEntriesRequest()
            .SetLeaderboards(new List<string>() { _boardShortCode })
            .Send((response) =>
        {
            if (!response.HasErrors)
            {
                // Method 1
                GSData data = (GSData)response.JSONData[_boardShortCode];
                Debug.Log("Current Player Rank: " + data.GetNumber("rank").ToString());

                // Method 2
                Debug.Log("Current Player Rank: " + response.BaseData.GetGSData(_boardShortCode).GetNumber("rank").ToString());
            }
            else
            {
                Debug.Log("Error: Could not get leaderboard score!");
            }
        });
    }

 Now, perhaps I am not going about obtaining this data in the best/fastest way. How else could I get this data?


Also, I can not find documentation on the GSData class and its inherited members or functions. If this exists, could you please point me to it?


Thanks!

Kevin


Best Answer

Hi Kevin,


Either method is correct, though most users end up using the second method, in which you parse the response as GSData and extract specific keys from that point onwards.


We don't have specific documentation for the GSData class, though we should be adding this in the future.


-Pádraig

1 Comment

Answer

Hi Kevin,


Either method is correct, though most users end up using the second method, in which you parse the response as GSData and extract specific keys from that point onwards.


We don't have specific documentation for the GSData class, though we should be adding this in the future.


-Pádraig

Login to post a comment