GameMaker Studio · GML · Leaderboards & scores
gmda_loadLeaderboardView
Loads a periodic / filtered leaderboard view; result arrives via the view_loaded event.
Signature
gmda_loadLeaderboardView(table, [period="all"], [options_struct]) -> realWhat it does
POSTs to /leaderboards/scores (or its daily/weekly/monthly variant) for the requested period and filters, then queues a view_loaded event. On the event, response.scores is the array of rows, response.player_score is the player's own row, and response.leaderboard is the table's dashboard config ({ name, sort_order, periods_enabled }); period views additionally include response.period and response.period_key. The event also carries a tag field holding the internal 0-based table index as a string (one less than the 1-based table you passed). Returns 1 if the request was sent, or 0 if there is no session or the table is out of range. The period is NOT validated locally: an invalid string just yields a failed event from the server.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| table | real | required | Table number to load. 1-based: the first declared table is 1, the second is 2, and so on. |
| period | string | "all" | Time window: "all", "daily", "weekly", or "monthly". |
| options_struct | struct | {} | Optional filters: { search: "name", friends_only: true }. Omit both for the plain top. |
How to call it
Call this for daily/weekly/monthly tabs or for friends-only / search filters, then read the rows from the "view_loaded" event in gmda_pollEvent(). For the plain global top you can also just read gmda_getTabledata() synchronously.
Result event: view_loaded { success, response }
Example
gmda_loadLeaderboardView(1, "weekly", { friends_only: true });
// later, in a Step event:
var e = gmda_pollEvent();
while (!is_undefined(e)) {
if (e.event == "view_loaded" && e.success) {
var rows = e.response.scores;
for (var i = 0; i < array_length(rows); i++) {
var r = rows[i];
show_debug_message("#" + string(r.rank) + " " + r.player_name + " " + string(r.score));
}
}
e = gmda_pollEvent();
}Use cases
- Build daily / weekly / monthly leaderboard tabs.
- Show a friends-only ranking or a name-filtered search result.