> ## 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.

# Construct 3

> Gamavas Pass for Construct 3: event-sheet actions for sign-in, achievements and selling, with no code needed.

A Construct 3 plugin for web exports, built on the current addon SDK (r401 or later). It works whether Construct runs your game in a worker or not, and it brings the Gamavas script with it.

## Install

**1. Install the addon**

Download `gamavas-pass-<version>.c3addon` from [github.com/Gamavas/pass-construct/releases](https://github.com/Gamavas/pass-construct/releases) and drag it into Construct, or use **Menu → View → Addon manager → Install new addon**.

**2. Add the object**

Add the **Gamavas Pass** object to your project (under **Web**) and set its **Client ID** property.

**3. Register your page**

At [developer.gamavas.fun](https://developer.gamavas.fun), add the page your game runs on under **Where sign-in returns**. To test in Construct's preview, add the preview page's address too, without anything after `?` or `#`.

## Sign players in

| Event | Action |
| - | - |
| Button: On clicked | GamavasPass: **Sign in** |
| GamavasPass: **On signed in** | Text: Set text to `"Hi @" & GamavasPass.PlayerHandle` |
| GamavasPass: **On sign-in error** | Text: Set text to `GamavasPass.ErrorCode` |

Use **Sign in** from a click or touch: browsers only open popups then. Players stay signed in between visits, and Gamavas Pass knows who's signed in before your first layout starts, so check **Is signed in** on start of layout.

Player expressions: `PlayerID`, `PlayerHandle`, `PlayerName`, `PlayerAvatarURL` and `PlayerEmail`.

## Achievements and progress

| Event | Action |
| - | - |
| Player wins | GamavasPass: **Unlock achievement** `"first-win"` |
| GamavasPass: **On achievement "first-win" unlocked** | Use `UnlockWasNew`, `UnlockedXP` |

**Load achievements**, then **On achievements loaded**: `AchievementCount` and, for `i` from 0, `AchievementKey(i)`, `AchievementName(i)`, `AchievementDescription(i)`, `AchievementIconURL(i)`, `AchievementXP(i)`, `AchievementUnlocked(i)`. Use **Repeat** `AchievementCount` times with `loopindex`. `AchievementsJSON` gives them all for the JSON object, and **Has achievement** tests one key.

**Load progress**, then **On progress loaded**: `Level`, `XP`, `LevelTitle`, `XPToNextLevel`.

## Selling your game

| Event | Action |
| - | - |
| On start of layout, **Is signed in** | GamavasPass: **Check ownership** |
| **On ownership checked**, **Owns game** | Go to layout "Game" |
| Buy button: On clicked | GamavasPass: **Purchase** |
| **On purchased** | Go to layout "Game" |

**On purchase cancelled** fires when the player closes the checkout without buying.

## Your server

Use **Get access token**, then on **On access token**, send `GamavasPass.AccessToken` to your server (with the AJAX object, for example). Verify it there with [`@gamavas/pass-server`](https://docs.gamavas.fun/sdks/server).

## Errors

**On error** fires when an action fails. Pick which action, or **any**. `ErrorCode` is one of `popup_closed` or `access_denied` (signing in), `popup_blocked`, `signed_out`, `forbidden`, `not_found`, `rate_limited` or `network`. `ErrorMessage` explains it, and `ErrorAction` names the action.

## Properties

| Property | |
| - | - |
| Client ID | From developer.gamavas.fun |
| Test mode | Free test purchases for you and your testers. Off before you ship |
| Analytics | Play time for your Analytics page. Never earns XP. On by default |
| Server | Leave empty. Only for testing against staging |

## Scripting

Scripts get the same features, as promises:

```js theme={"theme":{"light":"github-light","dark":"github-dark"}}
const pass = runtime.objects.GamavasPass.getFirstInstance();
pass.player;                         // { id, handle, displayName, avatarUrl, email } or null
const player = await pass.signIn();  // from a click; throws GamavasPassError (e.code)
await pass.unlock("first-win");
if (!(await pass.owns())) await pass.purchase();
const token = await pass.getAccessToken();
```

NW\.js, Windows WebView2 and mobile exports aren't supported yet.


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