Godot 4 · GDScript · Leaderboards & scores
submit_with_retry
Submits a score with automatic offline retry; the queue survives app closes and crashes.
Signature
submit_with_retry(table_index: int, score: int, meta: Dictionary = {}) -> voidWhat it does
Queues the score in a persistent (encrypted on-disk) pending list, then tries to flush it. If the device is offline or the send fails, it retries on its own and recovers when the network returns. A higher score on the same table replaces a lower queued value; a lower one is ignored. On historic-only tables (periods_enabled = false) a score that cannot beat the cached best is silently skipped instead of queued, and a queued score that can no longer improve such a table is dropped at flush time.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| table_index | int | required | Table number, from set_leaderboard() order (1-based: 1, 2, 3…). |
| score | int | required | The score to submit. |
| meta | Dictionary | {} | Extra fields for this table in the panel, e.g. {"level": 3} (sent as custom_data). |
How to call it
Connect submit_completed first, then call this instead of submit() whenever you want the score delivered even if the player loses connection or quits. Recommended default for most games.
Result signal: submit_completed(success: bool, table_index: int, server_score: int)
Example
Gamdato.submit_completed.connect(_on_sent)
Gamdato.submit_with_retry(1, 1500, {"level": 3})
func _on_sent(ok: bool, table_index: int, server_score: int) -> void:
if ok:
print("delivered, server best = %d" % server_score)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.