Studio GuideWorld SDK Guide
Log In

Searching Ranking Details

Get ranking information in a specific range

Use the LeaderboardAPI.GetRangeRank() function to load a specific range of ranking details.

The Boolean value to retrieve leaderboard ID, start ranking, last ranking, reset rule and last season's ranking information, and the callback function from the time of completion and time of error occurrence is passed as an argument.

User information that inquires ranking information is automatically entered, and up to 100 ranking information can be processed per inquiry (ex: paging in 1~100, 101~200 format for implementation)

❗️

Caution

If more than 100 data are loaded at a time, it may not work properly due to API load issues and rate-limits.


Example function call

An example of calling LeaderboardAPI.GetRangeRank() function is as follows:

LeaderboardAPI.GetRangeRank(this.leaderboardId, this.startRank, this.endRank, this.resetRule, false, this.OnResult, this.OnError);

The following code is an example for loading a specific range of ranking information.
You can use the Member value from OnResult to load the profile photo.


📘

Please refer to the following guide. [User Information]

import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { GetRangeRankResponse, LeaderboardAPI, ResetRule } from 'ZEPETO.Script.Leaderboard';

export default class GetRangeRankExample extends ZepetoScriptBehaviour {

    public leaderboardId: string;
    public startRank: number;
    public endRank: number;
    public resetRule: ResetRule;

    Start() {
        LeaderboardAPI.GetRangeRank(this.leaderboardId, this.startRank, this.endRank, this.resetRule, false, 
            this.OnResult, this.OnError);
    }

    OnResult(result: GetRangeRankResponse) {
        console.log(`result.isSuccess: ${result.isSuccess}`);
        if (result.rankInfo.myRank) {
            console.log(`member: ${result.rankInfo.myRank.member}, rank: ${result.rankInfo.myRank.rank}, 
			            score: ${result.rankInfo.myRank.score}, name: ${result.rankInfo.myRank.name}`);
        }

        if (result.rankInfo.rankList) {
            for (let i = 0; i < result.rankInfo.rankList.length; ++i) {
                const rank = result.rankInfo.rankList.get_Item(i);
                console.log(`i: ${i}, member: ${rank.member}, rank: ${rank.rank}, 
                            score: ${rank.score}, name: ${result.rankInfo.myRank.name}`);
            }
        }
    }

    OnError(error: string) {
        console.error(error);
    }
}
1242

LeaderboardAPI.GetRangeRank Run Screen