GameMaker Studio · GML · Currency & store
gmda_getBalances
Fetches the player's currency balances plus the game's currency catalog.
Signature
gmda_getBalances() -> realWhat it does
GETs /currency/balances with the session headers. The queued balances_loaded event carries response, a struct holding the player's balances together with the currency catalog: each currency entry has a code (plus its display name, icon and active flag) so you can label the amounts. Returns 1 once the request is dispatched, or 0 when there is no active session.
Parameters
This function takes no parameters.
How to call it
Call gmda_getBalances(), then read the balances_loaded event from the queue with gmda_pollEvent() in your Step loop. Call it again after a purchase, a grant, or returning from a Stripe top-up to refresh the displayed wallet.
Result event: balances_loaded { success, response }
Example
gmda_getBalances();
// in the Step event, drain the queue:
var e = gmda_pollEvent();
while (!is_undefined(e)) {
if (e.event == "balances_loaded" && e.success) {
var bals = e.response.balances;
for (var i = 0; i < array_length(bals); i++) {
show_debug_message(string(bals[i].currency_id) + ": " + string(bals[i].balance));
}
}
e = gmda_pollEvent();
}Use cases
- Show the player's coin or gem balance in a shop or HUD.
- Refresh the wallet after a purchase, grant, or top-up completes.