> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gamavas.fun/llms.txt
> Use this file to discover all available pages before exploring further.

# GameMaker

> Gamavas Pass for GameMaker's HTML5 export: GML functions for sign-in, achievements and selling.

A GameMaker extension for the **HTML5** export, for GameMaker LTS 2022 and later. It adds the Gamavas script to your game's page by itself. Windows, macOS, Linux, mobile and GX.games exports aren't supported yet; guard your calls with `os_browser != browser_not_a_browser` if your game builds for those too.

## Install

**1. Import the package**

Download `GamavasPass-<version>.yymps` from [github.com/Gamavas/pass-gamemaker/releases](https://github.com/Gamavas/pass-gamemaker/releases). In GameMaker, choose **Tools → Import Local Package**, pick the file and import **GamavasPass**.

**2. Register your page**

At [developer.gamavas.fun](https://developer.gamavas.fun), connect your listing to get a client ID, and add your game's page under **Where sign-in returns**. To test from GameMaker, add the local address the HTML5 runner opens too, for example `http://127.0.0.1:51264/` (your port).

## Sign players in

Start once, for example in your first room's Create event:

```gml theme={"theme":{"light":"github-light","dark":"github-dark"}}
gamavas_init("YOUR_CLIENT_ID");
gamavas_on_player_changed(function(_player) {
    show_debug_message(is_undefined(_player) ? "Signed out" : "Hi @" + _player.handle);
});
```

Sign in from a click or tap, for example in a button's Left Pressed event:

```gml theme={"theme":{"light":"github-light","dark":"github-dark"}}
gamavas_sign_in(false, function(_r) {
    if (_r.ok) show_debug_message("Hi @" + _r.value.handle);
    else show_debug_message(_r.error + ": " + _r.message);   // "popup_closed", "access_denied"…
});
```

Every call reports to your callback with a struct: `{ ok, value, error, message }`. Missing values are `""`, never undefined, because reading a missing struct field is an error in GML.

Once `gamavas_is_ready()` is true, `gamavas_is_signed_in()` and `gamavas_player()` say who's signed in: `{ id, handle, displayName, avatarUrl, email }`.

## Achievements, progress and selling

```gml theme={"theme":{"light":"github-light","dark":"github-dark"}}
gamavas_unlock("first-win", true, function(_r) {   // true: show the "Achievement unlocked" notice
    if (_r.ok && _r.value.newlyUnlocked) show_debug_message("+" + string(_r.value.xpAwarded) + " XP");
});

gamavas_achievements(function(_r) { /* _r.value: array of { key, name, … unlocked } */ });
gamavas_progress(function(_r) { /* _r.value: { xp, level, title, toNextLevel } */ });

gamavas_owns(function(_r) { if (_r.ok && _r.value) room_goto(rm_game); });
gamavas_purchase(function(_r) { if (_r.ok && _r.value) room_goto(rm_game); });   // from a click
```

## Your server

```gml theme={"theme":{"light":"github-light","dark":"github-dark"}}
gamavas_access_token(function(_r) { if (_r.ok) send_to_server(_r.value); });
```

Verify it on your server with [`@gamavas/pass-server`](https://docs.gamavas.fun/sdks/server).

## Options

```gml theme={"theme":{"light":"github-light","dark":"github-dark"}}
gamavas_init_ext("YOUR_CLIENT_ID", {
    test: false,        // test purchases for you and your testers; off before you ship
    analytics: true,    // play time for your Analytics page; never earns XP
    issuer: "https://staging.gamavas.fun/api/auth",   // only for testing against staging
});
```

## Errors

`error` is one of `popup_closed` or `access_denied` (signing in), `popup_blocked`, `signed_out`, `forbidden`, `not_found`, `rate_limited`, `network` or `not_initialized` (call `gamavas_init` first).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.