SDKboxPlay getMyScore Android

SDKboxPlay getMyScore Android
0.0 0

#1

I have been testing SDKboxPlay on Android and have come across a problem. The SDKboxPlay API shows to use sdkbox.PluginSdkboxPlay.getMyScore for my score. Problem is that due to Google rate limits, I can’t get all scores I need.

On the google site: https://developers.google.com/games/services/web/api/scores/get

It shows you can pass “ALL” for leaderboardId. Is there a way to pass “ALL” via SKDBox? It would be better this way to avoid many Google API calls. It should function the same as sdkbox.PluginSdkboxPlay.loadAchievements. Please let me know if such a function is available.

Also it seems I can only call sdkbox.PluginSdkboxPlay.showAchievements and sdkbox.PluginSdkboxPlay.showAllLeaderboards on first load. If I change scenes it no longer works.

I am using Cocos Creator.


#2

thanks feedback, we will fix this issues ASAP.


#3

Thank you htlxyz for looking into this. I really appreciate it. Please let me know when you have updated SDKboxplay so that I can update and make changes to my project.


#4

@ota

I found a way that you can use this to test for temporarily.

add a item to sdkbox_config.json:


{
    "android": {
        "sdkboxplay": {
            "leaderboards": [

                ...

                {
                    "id": "ALL", 
                    "name": "ALL"
                },

                ...

            ],
        }
    },
    "ios": {

        ...

    }
}

and then you can invoke

sdkbox::PluginSdkboxPlay::getMyScore("ALL", WEEK, GLOBAL);

#5

Ok, thank you. I will give it a try soon. Will this return an object similar to onAchievementsLoaded with all IDs or each item is returned separately? Because onMyScore has leaderboard_name, time_span, collection_type, score but no object.

Also do you know why sdkbox.PluginSdkboxPlay.showAchievements and sdkbox.PluginSdkboxPlay.showAllLeaderboards doesn’t work after changing scenes?


#6
  1. getMyScore will trigger onMyScore.

  2. showAchievements/showAllLeaderboards doesn’t work after changing scenes
    any error in logcat?


#7

Ok, I will test and let you know.

I will check if the log shows anything.


#8

Ok, I tested getMyScore with ALL and it’s not working. Did you test this?

onMyScore returns: “Can’t get score”. I have multiple leaderboards.

Here is log error:

05-18 03:26:27.558 17138-18289/? E/Volley: [3737] BasicNetwork.performRequest: Unexpected response code 400 for https://www.googleapis.com/games/v1/leaderboards/ALL?language=en_US
05-18 03:26:27.558 17138-26830/? E/LeaderboardAgent: Unable to retrieve leaderboard ALL
05-18 03:26:28.088 17138-26830/? E/DataHolderOperation: Killing (on development devices) due to RuntimeException
java.lang.IllegalStateException: Found multiple entries for player, in leaderboard (ALL)

In JSON I added:

{
                    "id": "ALL", 
                    "name": "ALL"
                }

In my code I trigger:

sdkbox.PluginSdkboxPlay.getMyScore("ALL", 2, 2);

Also tried:

sdkbox.PluginSdkboxPlay.getMyScore("ALL", 1, 2);

Even though from my understanding “ALL_TIME” should work only “ALL” isn’t supposed to work. Either way both “ALL_TIME” and “WEEKLY” don’t work.

Google:

NOTE: You cannot ask for ‘ALL’ leaderboards and ‘ALL’ timeSpans in the same request; only one parameter may be set to ‘ALL’.


#9

Also no error after changing scenes and relaunching showAchievements/showAllLeaderboards. Just doesn’t open after changing scenes. In IOS they open fine. Same code for Android and iOS.


#10

I need to know whether SDKbox is working on this? I don’t have too many options. I had to start another project. Very disappointing issue.


#11

sorry for late.

this show params ‘ALL’ is passed to google, and google return error back.

is it possible share a sample with us?


#12

Yes, my code is pretty straight forward. My script is very long so I have to summarize what I did. For IOS, I call each leaderboard separately because they have no rate limit. Google has a rate limit after you make the 3rd sdkbox.PluginSdkboxPlay.getMyScore. So I am trying to use sdkbox.PluginSdkboxPlay.getMyScore(“ALL”, 2, 2); to get all leaderboards in 1 shot.

...
    "sdkboxplay": {
                "leaderboards": [
                    {
                        "id": "CgkImsvuy-wCEAIQAA", 
                        "name": "bestscore"
                    },
                    {
                        "id": "CgkImsvuy-wCEAIQAQ", 
                        "name": "perfectshots"
                    },
                    {
                        "id": "CgkImsvuy-wCEAIQAg", 
                        "name": "amazingshots"
                    },
                    {
                        "id": "CgkImsvuy-wCEAIQAw", 
                        "name": "gamesplayed"
                    },
                    {
                        "id": "ALL", 
                        "name": "ALL"
                    }
                ], 
...

Then in my JS script:

    initiatePlayCenter: function () {

        if(typeof(sdkbox) == "undefined" || !cc.sys.isMobile){

            return;
        }

        if (typeof(sdkbox.PluginSdkboxPlay) != "undefined") {
            
            sdkbox.PluginSdkboxPlay.setListener({
                
               onConnectionStatusChanged: function(connection_status) {
                
                console.log("connection status change: " + connection_status + " connection_status");

                    if (connection_status == 1000) {

                      if(!self.didDo){

                       self.didDo = true;

                        if (cc.sys.os == cc.sys.OS_IOS) {

                        sdkbox.PluginSdkboxPlay.getMyScore("bestscore", 2, 2);
                        sdkbox.PluginSdkboxPlay.getMyScore("perfectshots", 2, 2);
                        sdkbox.PluginSdkboxPlay.getMyScore("amazingshots", 2, 2);
                        sdkbox.PluginSdkboxPlay.getMyScore("gamesplayed", 2, 2);

                        }else{

                            sdkbox.PluginSdkboxPlay.getMyScore("ALL", 2, 2);

                        }
                        
                       }
                    }
                },

                onMyScore: function(leaderboard_name, time_span, collection_type, score) {
                    
                   console.log(leaderboard_name+" : "+score);

                },

                onMyScoreError: function(leaderboard_name, time_span, collection_type, error_code, error_description) {
                    
                   console.log(error_description);
                    
                }
                
            });

            sdkbox.PluginSdkboxPlay.init();

            if (!sdkbox.PluginSdkboxPlay.isSignedIn()) {

                sdkbox.PluginSdkboxPlay.signin();

            }

        }

    },
    
    start() {
    
     this.didDo = false;
    
     this.initiatePlayCenter();
     
    }

#13

i tried use ALL to get score.

but i figure out. the url https://developers.google.com/games/services/web/api/scores/get you give is a web interface. and we use google android client sdk, this maybe is not compatible with the ALL param.

i add just one leadboard to my game, and i can get my score with param ALL.
but i got INTER_ERROR when i add another leadboard to my game.

so, for now, i guess the ALL param just work in game which have just only one leaderboard in game.

@ota


#14

I figured it was compatible… I don’t know why Google would rate limit something so important. I need only on app launch to synchronize the scores in case someone exited a game before finishing a game or in case of a crash or some other unexpected issue.

I only want to compare the scores and update them if they are incorrect. I need the 4 leaderboards because achievements are dependent of them.

Problem is when I request the 4 leaderboards, on the 3rd leaderboard Google sends a rate limit error and I can’t get the data.

I read on Stackoverflow that you can wait 10 seconds after the 3rd request is made and do the request again but this would require people to wait longer for the game to load. Very impractical. Chances are people that have never played, would just close the app.

Of course another option is to just update the scores each time someone launches the app but that in my opinion is not good due to time spans. Also how would updating 4 leaderboards be better than requesting information about 4?

It’s hard to believe that Google wouldn’t have a way just to get all scores for all leaderboards at once when they have something similar available for achievements. Especially since they have rate limits set. The link to the web interface was the only thing I could find which was similar to what I need.