Search All Leaderboards
Use the LeaderboardAPI.GetAllLeaderboards function to load all leaderboard information in the specified World.
The callback function from the time of completion to the time of error occurrence is passed as an argument.
An example of loading LeaderboardAPI.GetAllLeaderboards function is as follows:
LeaderboardAPI.GetAllLeaderboards(this.OnResult, this.OnError);
The following is an example for loading the entire leaderboard information.
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { GetAllLeaderboardsResponse, LeaderboardAPI } from 'ZEPETO.Script.Leaderboard';
export default class GetAllLeaderboardExample extends ZepetoScriptBehaviour {
Start() {
LeaderboardAPI.GetAllLeaderboards(this.OnResult, this.OnError);
}
OnResult(result: GetAllLeaderboardsResponse) {
console.log(`result.isSuccess: ${result.isSuccess}`);
if (result.leaderboards) {
for (let i = 0; i < result.leaderboards.length; ++i) {
const leaderboard = result.leaderboards[i];
console.log(`i: ${i}, id: ${leaderboard.id}, name: ${leaderboard.name}`);
}
}
}
OnError(error: string) {
console.error(error);
}
}

LeaderboardAPI.GetAllLeaderboards Run Screen
Search Specific Leaderboards
Use the LeaderboardAPI.GetLeaderboardsfunction to load specific leaderboard information.
The callback function for the leaderboard ID, the time of completion, the time of error occurrence are passed as an argument.
An example of loading LeaderboardAPI.GetLeaderboard function is as follows:
LeaderboardAPI.GetLeaderboard(this.leaderboardId, this.OnResult, this.OnError);
The following is an example for loading certain leaderboard inofrmation.
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { GetLeaderboardResponse, LeaderboardAPI } from 'ZEPETO.Script.Leaderboard';
export default class GetLeaderboardExample extends ZepetoScriptBehaviour {
public leaderboardId: string;
Start() {
LeaderboardAPI.GetLeaderboard(this.leaderboardId, this.OnResult, this.OnError);
}
OnResult(result: GetLeaderboardResponse) {
console.log(`result.isSuccess: ${result.isSuccess}`);
if (result.leaderboard) {
console.log(`id: ${result.leaderboard.id}, name: ${result.leaderboard.name}`);
}
}
OnError(error: string) {
console.error(error);
}
}

LeaderboardAPI.GetLeaderboard Run Screen