Referência de funções
GameMaker Studio · GML · Setup & session
gmda_setController
Sets your credentials and begins the session bootstrap. Call once in the controller Create event.
Synchronous (returns directly)
Signature
gmda_setController(game_id, api_key) -> realWhat it does
Stores your credentials, restores any persisted player identity from the local save (gamdato.dat), and arms the session lifecycle (init phase 1). From here gmda_Updatefunction() starts the session and keeps it renewed on its own, so your game only reacts to the queued events.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| game_id | string | required | Your game's GAME_ID from the Gamdato panel. |
| api_key | string | required | Your API_KEY from the panel. Never hardcode or commit it in a shipped build: keep it out of source control. The game must be configured with hash_algorithm = "sha1" in the panel, because GameMaker only ships a sha1 hash for the signed session handshake. |
How to call it
Call exactly once in the persistent controller's Create event, then call gmda_setLeaderboard() right after to declare your tables. The session actually opens on the next Step, so read results from the event queue rather than expecting data immediately.
Returns: 1 (the session starts asynchronously; watch for the session_started event).
Example
gmda_setController("YOUR-GAME-ID", "YOUR-API-KEY");
gmda_setLeaderboard("scores_normal", "scores_hard");
// later, in the Step event, drain the queue:
var e = gmda_pollEvent();
while (!is_undefined(e)) {
if (e.event == "session_started") {
show_debug_message("session ok: " + e.player_name + " (new=" + string(e.is_new) + ")");
}
e = gmda_pollEvent();
}Use cases
- Boot the backend when your game launches.
- Re-authenticate a returning player automatically, since their identity is restored from the local save.