GameMaker Studio · GML · Leaderboards & scores
gmda_submitWithRetry
Submits a score with automatic offline retry; the queue survives app closes and crashes.
Signature
gmda_submitWithRetry(table, score, [custom_struct]) -> realWhat it does
Queues the score in a persistent, offline-safe pending list, then tries to flush it. No active session is required: it queues regardless and flushes once the session is up. If the device is offline or the send fails, it retries on its own and recovers when the network returns; the queue survives the app being closed. A higher score on the same table replaces a lower queued value; a lower one returns 1 without replacing it. Returns 0 only for an out-of-range table, or when the table is historic-only (periods_enabled = false) and the score cannot beat the cached best. Queued scores that can no longer improve a historic-only table are dropped at flush time.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| table | real | required | Table number, from gmda_setLeaderboard() order. 1-based: the first declared table is 1, the second is 2, and so on. |
| score | real | required | The score to submit. |
| custom_struct | struct | {} | Extra fields for this table in the panel, e.g. { level: 3 } (sent as custom_data). |
How to call it
Call this instead of gmda_submit() whenever you want the score delivered even if the player loses connection or quits. Read confirmation from the event queue: look for a "submit_completed" event in gmda_pollEvent(). Recommended default for most games.
Result event: submit_completed { success, table, response }
Example
gmda_submitWithRetry(1, 1500, { level: 3 });
// later, in a Step event:
var e = gmda_pollEvent();
while (!is_undefined(e)) {
if (e.event == "submit_completed" && e.success) {
show_debug_message("delivered to table " + string(e.table));
}
e = gmda_pollEvent();
}Use cases
- Reliably submit the player's best score even on a flaky mobile connection.
- Guarantee a game-over score is sent after a reconnect, even if the app was closed first.