Leaderboards¶
Creating a Leaderboard¶
The GOG GALAXY SDK allows you to handle leaderboards in 2 ways:
- Predefined leaderboards — defined in the Developer Portal first, then retrieved with the
FindLeaderboard()
method.
- Created at runtime — to create a leaderboard during the game runtime, you can call the
FindOrCreateLeaderboard()
method. It performs a request for a definition of a specified leaderboard, and creates the leaderboard if it does not exist yet. It might be useful if you want to create e.g. daily/weekly leaderboards.
Setting a User’s Leaderboard Score¶
In order to set a user’s score for a particular leaderboard, you need to call the following methods:
RequestLeaderboards()
— downloads leaderboards definitions; you have to call it before making any other calls related to leaderboards. Please keep in mind that this call is asynchronous, and you should wait for the callback onLeaderboardsRetrieveListener
.SetLeaderboardScore()
orSetLeaderboardScoreWithDetails()
— these methods allow you to set a score for a particular leaderboard for the current user.
Please keep in mind that these calls are asynchronous, so remember to initialize adequate listeners (LeaderboardsRetrieveListener
and LeaderboardScoreUpdateListener
) and wait for callbacks after calling these methods.
In order to reset leaderboards, you have to delete and create them anew. This can be done in the Developer Portal.
Important
Please note that there is no possibility to reset the leaderboards using the GOG GALAXY SDK call.
Setting a Leaderboard Score Does Not Work — What Should I Do?¶
- Have you called
RequestLeaderboards()
and waited for a callback to its listener before calling any other leaderboard methods? - Are you calling
ProcessData()
frequently enough? - Have you set up appropriate listeners properly?
- Have you set up error handling? It is possible to catch errors within the GOG GALAXY SDK methods or use the
GetError()
method to check if any errors occurred.
Requesting Leaderboard Entries¶
To retrieve leaderboard entries, for example to display them in game, you may use one of following methods:
Method | Function |
---|---|
RequestLeaderboardEntriesAroundUser() |
Performs a request for entries of a specified leaderboard for and near the specified user. The start and the end of the range of entries are passed as arguments. |
RequestLeaderboardEntriesForUsers() |
Performs a request for entries of a specified leaderboard for specific users |
RequestLeaderboardEntriesGlobal() |
Performs a request for entries of a specified leaderboard in a global scope, i.e. without specifying users |
Please remember that all these calls are asynchronous and responses indicating their success or failure will come to LeaderboardsRetrieveListener
.
For more detailed information about Leaderboards and their related GOG GALAXY SDK methods, please visit the GOG GALAXY SDK API documentation.