[Cloud Server] How to get the player's name, player's ID, and player's score from the leaderboard in one Callback()

The leaderboard API (Cloudsever: XXX) will only allow us to set data by using “key” and “score”. And since the player's name can be repeated. We usually use the player's ID as a key for the leaderboard.
The problem is when we want to retrieve data back from the leaderboard, we will get the player ID. But normally we want to show the player's name on the leaderboard.

Some map developers will use API “Player:getNickname()” to retrieve the player's name from the player's ID. But this method will not work if that player does not log in on the map at that time.
Some will create a new table to keep the list of the player's ID and player's name. This method requires more effort and needs to do one more connection from the server and have to wait for another Callback(). And since waiting for each Callback() from the Cloud server takes a long time (several seconds). So, this method is not good in real situations.

Here is the better solution
Use API “CloudSever:getOrderDataIndexArea()”
https://dev-wiki.mini1.cn/cyclopdeia?wikiMenuId=3&wikiId=2067#getOrderDataIndexArea
This API can return n ranks data in 1 Callback().
And when you use it in the cloud server by setting the player's ID as a key, you will able to access the attribute v.nick to get the player's name even if that player is not on the map at that time.

Please see this example.

Note this solution will work on the cloud server only. You cannot access v.nick in single-player mode or a normal online room.

This is the script for example.
Don't forget to create the leaderboard named “gold” before using it.


And this is the video demo.