Skip to content

Leaderboard

Francisco Dias edited this page Apr 9, 2024 · 3 revisions

Leaderboard

Functions

This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.

Constants

This module includes a set of predefined constants that can be utilized for various purposes. Browse through the available constants to find values relevant to your needs and enhance the efficiency of your code.



Back To Top

GameCenter_Leaderboard_Submit

This function requests the Apple GameCenter API to submit a score to a given leaderboard. The function will not return any value but it will create a request that will trigger a Social Async Event callback when the task is resolved.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

GameCenter_Leaderboard_Submit(id, score, context)
Argument Type Description
id String The unique identifier of the leaderboard.
score Real The value to be submitted to the leaderboard (remember that only the highest score value is displayed in the leaderboard).
context Real OPTIONAL This parameter corresponds to the context parameter.

Returns:

N/A


Triggers:

Social Async Event

Key Type Description
type String "GameCenter_Leaderboard_Submit"
success Boolean Whether or not the task succeeded.

Example:

var _score = irandom(999);
GameCenter_Leaderboard_Submit("YYLeaderboard2", _score);



Back To Top

GameCenter_Leaderboard_LoadGlobal

This function loads the leaderboard's global data for the specified leaderboard IDs that Game Center uses.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

GameCenter_Leaderboard_LoadGlobal(leaderboardID, timeScope, rangeStart, rangeEnd)
Argument Type Description
leaderboardID String ID of the leaderboard
timeScope GameCenter_Leaderboard_TimeScope The time scope to load (today, week or all time).
rangeStart Real Specifies the range of ranks to use for getting the scores. The minimum rank is 1 and the maximum rank is 100.
rangeEnd Real Specifies the range of ranks to use for getting the scores. The minimum rank is 1 and the maximum rank is 100.

Returns:

N/A


Triggers:

Social Async Event

Key Type Description
type String "GameCenter_Leaderboard_Load"
leaderboard_id String Whether or not the task succeeded.
id Real
time_scope GameCenter_Leaderboard_TimeScope The time scope that was loaded.
range_start Real The range start of ranks to use for getting the scores (1-100).
range_end Real The range end of ranks to use for getting the scores (1-100).
player_scope GameCenter_Leaderboard_PlayerScope The player scope that was loaded.
leaderboard_title String The title of the leaderboard.
leaderboard_group String
leaderboard_type GameCenter_Leaderboard_Type The type of leaderboard.
leaderboard_start_date Real The start date of the leaderboard.
leaderboard_next_start_date Real The next start date of the leaderboard.
leaderboard_duration Real The duration of the leaderboard.
success Boolean the error_* are only present if success is false (async response will not have any other members in that case)
error_code Real The error code returned, in case of an error.
error_message String The error message, in case of an error.
total_players_count Real The total number of players in the leaderboard.
local_context Real
local_date Real
local_rank Real
local_score Real
local_formatted_score String
local_info String
entries Real for the following X will take values from 0 to entries-1
entry_context_X Real The context for the X'th entry.
entry_date_X Real The date of the X'th entry.
entry_rank_X Real The rank of the X'th entry.
entry_score_X Real The score for the X'th entry.
entry_formatted_score_X String
entry_info_X String entry_info_X

Example:

GameCenter_Leaderboard_LoadGlobal("YYLeaderboard2", GameCenter_Leaderboard_TimeScope_AllTime, 1, 5);



Back To Top

GameCenter_Leaderboard_LoadFriendsOnly

This function loads the Friends data for the specified leaderboard IDs that Game Center uses.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

GameCenter_Leaderboard_LoadFriendsOnly(leaderboardID, timeScope, rangeStart, rangeEnd)
Argument Type Description
leaderboardID String The ID of the leaderboard to load.
timeScope GameCenter_Leaderboard_TimeScope The time scope to load (today, week or all time).
rangeStart Real Specifies the range of ranks to use for getting the scores. The minimum rank is 1 and the maximum rank is 100.
rangeEnd Real Specifies the range of ranks to use for getting the scores. The minimum rank is 1 and the maximum rank is 100.

Returns:

N/A


Triggers:

Social Async Event

Key Type Description
type String "GameCenter_Leaderboard_Load"
leaderboard_id String Whether or not the task succeeded.
id Real
time_scope GameCenter_Leaderboard_TimeScope The time scope that was loaded.
range_start Real The range start of ranks to use for getting the scores (1-100).
range_end Real The range end of ranks to use for getting the scores (1-100).
player_scope GameCenter_Leaderboard_PlayerScope The player scope that was loaded.
leaderboard_title String The title of the leaderboard.
leaderboard_group String
leaderboard_type GameCenter_Leaderboard_Type The type of leaderboard.
leaderboard_start_date Real The start date of the leaderboard.
leaderboard_next_start_date Real The next start date of the leaderboard.
leaderboard_duration Real The duration of the leaderboard.
success Boolean the error_* are only present if success is false (async response will not have any other members in that case)
error_code Real The error code returned, in case of an error.
error_message String The error message, in case of an error.
total_players_count Real The total number of players in the leaderboard.
local_context Real
local_date Real
local_rank Real
local_score Real
local_formatted_score String
local_info String
entries Real for the following X will take values from 0 to entries-1
entry_context_X Real The context for the X'th entry.
entry_date_X Real The date of the X'th entry.
entry_rank_X Real The rank of the X'th entry.
entry_score_X Real The score for the X'th entry.
entry_formatted_score_X String
entry_info_X String entry_info_X

Example:

GameCenter_Leaderboard_LoadFriendsOnly("YYLeaderboard1", GameCenter_Leaderboard_TimeScope_AllTime, 1, 5);



Back To Top

GameCenter_Leaderboard_PlayerScope

A constant that tells whose scores to show

These constants are referenced by the following functions:


Member Description
GameCenter_Leaderboard_PlayerScope_Global This leaderboard shows all scores
GameCenter_Leaderboard_PlayerScope_FriendsOnly This leaderboard shows friends only


Back To Top

GameCenter_Leaderboard_TimeScope

A constant that tells the time period to show scores from

These constants are referenced by the following functions:


Member Description
GameCenter_Leaderboard_TimeScope_Today The leaderboard shows today's scores
GameCenter_Leaderboard_TimeScope_Week The leaderboard shows this week's scores
GameCenter_Leaderboard_TimeScope_AllTime The leaderboard shows all-time scores


Back To Top

GameCenter_Leaderboard_Type

A constant describing the type of leaderboard: classic (all-time) or recurring (interval)

These constants are referenced by the following functions:


Member Description
GameCenter_Leaderboard_Type_Classic This type of leaderboard tracks all-time scores
GameCenter_Leaderboard_Type_Recurring This type of leaderboard resets based on an interval that you define