Sign In Register

How can we help you today?

Start a new topic
Answered

Leaderboards not retrieving

Hi,


On Friday gamesparks stop retrieving something when I called "ListLeaderboardsRequest". Now despite I have two leaderboards created it only gives me access to one of them. By the way I what to have a third leaderboard that resets every week, can I use the same variable as the one that is the all time leaderboard or do I need to use another event variable for that?


Best Answer

Hi Ines,


The issue here was that the Leaderboard used to be set to Reset Weekly, and scores were posted, then after that (probably last Friday) it was changed to Calculate Weekly.

When a leaderboard is changed -be it how it calculates or adding another attribute to track- the system creates a new instance of the leaderboard as the data structure has changed. Any old leaderboard information will still exist in the NoSQL database, however it will be inaccessible to your users.

In your specific case, the issue has been resolved; though to prevent this from happening again, if you have leaderboards with data already being tracked, it's best to create a new leaderboard rather than change the old one.

The new data structure will invalidate the previous entries.


Apologies for the confusion.
We're working on a solution to warn users about the above scenario when editing a leaderboard that is already tracking data.


Thanks,


Oisin.


Hi Ines,


Can you confirm this is still the case with the latest SDK we released yesterday?

https://docs.gamesparks.net/sdk/unity3d-sdk


Shane

Any news on this issue?

Ok I think I understand how it works now. 

The only problem is with Unity (using Unity4.6 with Gamesparks SDK v3). I'm getting:


GS: SEND:{"@class":".LeaderboardDataRequest","entryCount":10,"leaderboardShortCode":"high_score_week.week.201513","requestId":"635631436135709845_4"}

GS: RECV:{"@class":".LeaderboardDataResponse","error":{"leaderboardShortCode":"INVALID"},"requestId":"635631436135709845_4","scriptData":null}


and on the test harness:


{
 "@class": ".LeaderboardDataResponse",
 "data": [
  {
   "userId": "54da5019e4b0e48c1ca40fb6",
   "player_score": 1000,
   "week": "201513",
   "when": "2015-03-28T12:41Z",
   "city": "Sesimbra",
   "country": "PT",
   "userName": "user1",
   "externalIds": {},
   "rank": 1
  }
 ],
 "leaderboardShortCode": "high_score_week.week.201513",
 "scriptData": null
}

{
 "@class": ".LeaderboardDataRequest",
 "entryCount": 10,
 "leaderboardShortCode": "high_score_week.week.201513"
}

Ok I see. 


So you are not saying that I can have one leaderboard that does both things but the same variable can store the score for different leaderboard, is that correct? 

I don't think this would work (or I'm not understanding how this is working still) because what I want is a leaderboard that only updates the position of the player in the end of the week based on the player score and another that resets every week (on the end of the week every score returns to zero).

Let's say our partitioned variable is called "level".

Any string you set as the partitioned variable with create a new sub leaderboard with that string as its heading. If your leaderboard shortcode is "highScoreLeaderboard" and you post your score and set the partitioned varable to "level1" your score will be posted to "highScoreLeaderboard.level.level1".

 Any time you post a score the partitioned variable will try to find a sub leaderboard of that name and if it doesn't it will create that sub leaderboard. The calculate weekly and reset weekly options cannot work on the same leaderboard. 

 Shane

Ok lets focus on one issue at a time. 


Can you explain me what the partitioned variable does on the leaderboard? What do you mean "post my leaderboard"? What I understood was that I just post a variable and that variable updates the leaderboard. There a calculate weekly and a reset weekly. Isn't that what I need?

For the player login you would modify the Cloud Code of AuthenticationResponse, you can then modify any script data you store on the player, we don't support modifying scores of an already existing leaderboard, the only way this would be achievable is if the Default Calc is set to sum but this would constantly add to your players score over the week.


For partitioning a leaderboard you set the week attribute Type to "String", set the Default Value to "${formatToday("yyyyww")}" and the Default Calc to "Grouped".


Then in your leaderboard that you want partitioned, you add this attribute and set the Group to "Partition".


When you post your score to your leaderboard, it will create a new sub leaderboard for every week.so if you call your leaderboard "weekly" this weeks leaderboard would be "weekly.201513".


Shane

I cannot understand exactly how this works. I check the documentation for partitioned leaderboards but still it is not very clear. Do you have a tutorial or something that I could follow? It may not be exactly for what I want but something similar just so I can understand the concepts.


Since you didn't answer I can assume that I cannot create a something that would make the player lose points if he doesn't login for some time?

Hi Ines,


One way to calculate and reset:


Create a partitioned leaderboard with the variables you want, and an extra variable for "week", set it to String and set the default to ${formatToday("yyyyww")} This should do the trick and all previous leaderboards will be available via the listLeaderboardsRequest.



You can make a similar leaderboard for the percentages with week, win and loss. Set win and loss to sum. Then you could create an event called "getUserWinPercentageForWeek" with an attribute of week. In the Cloud Code for that event use GetLeaderboardEntriesRequest:


var entry = Spark.sendRequest({

 "@class": ".GetLeaderboardEntriesRequest",

 "leaderboards": [

  "leaderboard.1513"

 ]

});


"entry" will equal the response, use the data that comes back to calculate the win percentage.


Shane

Ok but what I did (and maybe that was the problem) was that I want to create 4 leaderboards (one that calculates the score weekly and resets after ever every week, one that was the all time score and calculates weekly, one that was the percentage of games won that resets weekly and another with the percentage of games won of all time that calculates weekly) and I was using only two variables for those 4 leaderboards. Do I need 4 variables for this? How can I make the one that calculates percentages of games won? Can the leaderboard calculate the percentage given two variable? Is it possible to, for example, make the player lose points on the leaderboard if he doesn't login for some time?


Thanks

Answer

Hi Ines,


The issue here was that the Leaderboard used to be set to Reset Weekly, and scores were posted, then after that (probably last Friday) it was changed to Calculate Weekly.

When a leaderboard is changed -be it how it calculates or adding another attribute to track- the system creates a new instance of the leaderboard as the data structure has changed. Any old leaderboard information will still exist in the NoSQL database, however it will be inaccessible to your users.

In your specific case, the issue has been resolved; though to prevent this from happening again, if you have leaderboards with data already being tracked, it's best to create a new leaderboard rather than change the old one.

The new data structure will invalidate the previous entries.


Apologies for the confusion.
We're working on a solution to warn users about the above scenario when editing a leaderboard that is already tracking data.


Thanks,


Oisin.

Thanks, Ines, 


Still looking at this.
Hope to have an answer for you tomorrow.

Done!

Hi Ines,

oisin.bourke@gamesparks.com

Thanks.

Hello Oisin,


Yes I can give you access but I think I need your email.


I'm using UNITY 4.6 and the version 3 of the gamesparks SDK.

Login to post a comment