Skip to contentGo to cookie choices
Skip to docs navigation
Engines

GDevelop

Use the ZokoGames extension in GDevelop 5 with tagged actions, conditions and expressions, automatic pause and mute during ads, and ready event recipes.

About 19 minutes

https://docs.zokogames.com/engines/gdevelop

The ZokoGames extension (ZokoGames.json) for GDevelop 5 lives in packages/sdk-engines/gdevelop. It is an ordinary events extension: every action, condition and expression is a small JavaScript code event, so it works in previews and in every web export without any extra file. Terms such as "midgame" and "rewarded" are in the glossary.

Note

Plugin 1.7.2. Verified on 2026-11-23 with GDevelop 5.6.287: the extension file imports in the GDevelop web editor without errors, and an HTML5 export of the example made with GDevelop's own exporter passes the production check. The editor's preview button and editing event sheets by hand have not been exercised. If something fails, send the GDevelop version and the exact error to support.

Install#

Download the GDevelop extension: /sdk-engines/zokogames-gdevelop-1.7.2.zip. It holds ZokoGames.json (built from the gdevelop folder in the repository), an example project, the README and the changelog.

/sdk-engines/gdevelop.zip is always the latest version. Checksums: /sdk-engines/SHA256SUMS. Index of every engine package with its version, size and SHA-256: /sdk-engines/engines.json.

  1. Unzip the download. In GDevelop open the Project manager, then Extensions > Import extension, and choose ZokoGames.json (not the zip).
  2. The actions, conditions and expressions appear under ZokoGames in the events editor. Expressions are written ZokoGames::UserName().
  3. Run the Initialize action at the beginning of the first scene. The extension adds https://sdk.zokogames.com/zokogames-sdk-v1.js to the page itself, so you do not edit any export file.
  4. Export as HTML5 and upload the zip.

To see it working first, open examples/zokogames-example/game.json from the download and preview it: the text on screen lists each check.

Which path#

You are Do this
A GDevelop creator with a finished game Import the extension, add Initialize and the ad events below, export as HTML5, upload. No JavaScript needed.
Comfortable with JavaScript events The same SDK is reachable from a JavaScript code event as window.ZokoGames.SDK once Initialize has completed.

Tags, results and errors#

Every asynchronous action takes a Tag first. When the call ends, On request completed (with that tag) or On request failed (with that tag) is true for one frame; On any request failed is true for every failure. Use one tag per request in flight.

GDevelop waits for these actions: the actions after one in the same event, and its sub-events, run only once the request has ended. That makes simple chains easy (the result expressions already hold the new value in the next action), but put an ad request or a slow call in its own event when the rest of the event should not wait for it.

Expression Contents
ResultString The last result when it is text: a token, an invite link, a saved item.
ResultNumber The last result as a number (booleans are 1 and 0; Check ad blocker sets 1 when blocked).
ResultJSON The last result as JSON (the friends page, the account link answer).
ErrorCode, ErrorMessage, ErrorContainerId Details of the last failure. ErrorContainerId is set for banner errors. ErrorDescription(code) gives the English text of a code.

Ads pause and mute the game for you#

When an ad starts, the extension mutes all game sound at once, lets On ad started run for one frame, and then pauses the game. When the ad finishes or fails, it resumes the game and restores the sound before On ad finished or On ad error runs. A pause your game made itself is left alone. Switch either part off with Pause the game during ads and Mute the game during ads if your game handles it. Game sound also follows the portal's mute setting by default (Follow the portal mute setting).

A working set of events#

The events below cover init, a midgame ad, a rewarded ad, gameplay start and stop, save and load, and a leaderboard score. Use the scene variables Coins, Best and RewardPending.

At the beginning of the scene (first scene)
    -> ZokoGames: Initialize (tag "init")

ZokoGames: On request completed ("init")
    -> ZokoGames: Get saved item (tag "load", key "best")
       ZokoGames: Loading stop (tag "ls")
    sub-event: ZokoGames::HasSavedItem("best") = 1
       -> Change Best: set to ToNumber(ZokoGames::SavedItem("best"))
ZokoGames: On request failed ("init")              // SDK missing or blocked: just start
    -> Change the scene to "Menu"

// Ads: the extension pauses and mutes; grant the reward only in On ad finished
ZokoGames: On ad finished
    + RewardPending = 1
    -> Add 10 to Coins ; Set RewardPending to 0
ZokoGames: On ad error
    -> Set RewardPending to 0

// Gameplay start/stop
Game scene: At the beginning of the scene (player can act)
    + ZokoGames: Is available
    -> ZokoGames: Gameplay start (tag "gs")
Game over (or pause menu opened)
    + ZokoGames: Is available
    -> ZokoGames: Gameplay stop (tag "gx")

// Midgame ad at a natural break, in its own event
Game over screen: At the beginning of the scene
    + ZokoGames: Is available
    -> ZokoGames: Request ad (type midgame, tag "mid")

// Rewarded ad
Reward button is clicked
    + ZokoGames: Is available
    -> Set RewardPending to 1 ; ZokoGames: Request ad (type rewarded, tag "rew")

// Save
Round ends and Score > Best
    -> Set Best to Score ; ZokoGames: Set saved item (tag "save", key "best", value ToString(Best))

// Leaderboard (signed-in players only; board enabled in the console)
Round ends
    + ZokoGames: Is available
    -> ZokoGames: Submit score (tag "score", encrypted "", score Score)

Two traps are built into this sheet on purpose:

  • On request completed ("rew") is not "ad finished". When an ad is unfilled, blocked or in cooldown, the SDK delivers On ad error and the action still completes, so grant rewards in On ad finished only. When the SDK is disabled, the action fails (On request failed) and neither ad event fires; the game was never paused, so nothing is left to resume.
  • Submit score with an empty encrypted value works only on a board without an encryption key (the plain score is validated against the board rules). A keyed board counts only a correctly encrypted payload (leaderboards), and the extension has no encryption helper: compute the score on your server and use the server API, or leave the board keyless for a casual game. A player who is not signed in is not ranked.

Purchases#

ZokoGames: On request completed ("init") + ZokoGames: Is store available
    -> Show the shop button ; ZokoGames: Get catalogue items (limit 50, offset 0, tag "cat")
ZokoGames: On request completed ("cat")
    -> Repeat ZokoGames::StoreItemCount() times: row with StoreItemName(i), StoreItemPrice(i), StoreItemCurrency(i)
Buy button is clicked
    -> ZokoGames: Buy item (ZokoGames::StoreItemSku(selected), tag "buy")
ZokoGames: On request completed ("buy")
    -> grant ZokoGames::PurchasedItemId() ; ZokoGames: Get purchase token (tag "tok")   // then send PurchaseToken to your server
ZokoGames: On request failed ("buy") + Last error is "purchaseCancelled"     -> (nothing)
ZokoGames: On request failed ("buy") + Last error is "userNotAuthenticated"  -> ZokoGames: Show login prompt (tag "login")

Verify ownership on your server (see in-game purchases). StoreItemPrice is -1 when there is none and InventoryQuantity is -1 when not counted.

Actions#

Group Actions
Start-up Initialize
Ads Request ad (midgame or rewarded), Check ad blocker, Pause the game during ads, Mute the game during ads, Follow the portal mute setting
Banners Request banner (id, size 728x90, 300x250, 320x50, 468x60 or 320x100, x, y, width, height), Request responsive banner (id, x, y, width, height), Clear banner, Clear all banners
Game Gameplay start, Gameplay stop, Loading start, Loading stop, Report loading progress (0 to 100), Happytime, Report completed percentage, Set game context (JSON), Clear game context, Report chat message, Set screenshot provider, Answer screenshot
Multiplayer Update room, Set room public, Left room, Create invite link, Show invite button and Hide invite button (deprecated), Show invite button (portal only) and Hide invite button (portal only) (SDK 1.7.0)
User Get user, List friends, Get user token, Show login prompt, Show account link prompt, Submit score
Store Get catalogue items, Get player inventory, Buy item, Consume item, Set sandbox, Get purchase token, Get payment provider user token (deprecated)
Cloud save Get saved item, Set saved item, Remove saved item, Clear saved data, Mirror localStorage to cloud save, Stop mirroring localStorage
Achievements Unlock achievement (key), List achievements
Analytics Track event (SDK 1.7.0), Track order

Banner rectangles are in game resolution pixels (the size in the project properties) with the origin at the top left; the extension converts them to the scaled canvas. Request banners on menu scenes only.

Conditions#

  • Status: Is initialized, Is available (false when the SDK is disabled), Is QA tool.
  • Requests: On request completed, On request failed, On any request failed, Last error is (code).
  • Ads: On ad started, On ad finished, On ad error, Is ad playing.
  • Settings: On settings changed, Is mute requested, Is chat disabled, Is kids mode.
  • Offline: On offline changed, Is offline.
  • Multiplayer: Is instant multiplayer, On join room.
  • Achievements: On achievement unlocked.
  • Account: On auth changed, Is logged in, Is account available.
  • Store: Is store available.
  • Screenshots and storage mirror: On screenshot requested, On mirror error.

Triggers ("On ...") are true for one frame. When two of the same kind arrive together, the second is delivered on the next frame, so none is lost.

Kids mode. Is kids mode (KidsMode) is true when the game runs in kids mode (a game with the kids flag, or a player in kids mode); hide chat, rooms, sign-in prompts and shop screens then. A portal that does not send the field gives false, so also keep honouring Is chat disabled. To test it, add ?kidsMode=true to the page address in local mode. See kids mode.

Expressions#

Environment, SdkVersion, GameId, MuteAudio, DisableChat, KidsMode, InviteParam(key), InviteParamsJSON, UserName, UserPictureUrl, UserId (never trust it on a server; verify the token), UserToken, FriendCount, FriendsTotal, FriendsHasMore, FriendName(i), FriendId(i), FriendPictureUrl(i), Locale, CountryCode, DeviceType, SavedItem(key), HasSavedItem(key), ErrorCodes(module) (comma separated codes for ad, banner, user, data, store, room or general), ErrorDescription(code), ResultJSON, ResultString, ResultNumber, ErrorCode, ErrorMessage, ErrorContainerId, MirrorErrorCode, MirrorErrorMessage, the store expressions StoreItemCount, StoreItemSku(i), StoreItemName(i), StoreItemDescription(i), StoreItemImageUrl(i), StoreItemPrice(i), StoreItemCurrency(i), StoreItemConsumable(i), InventoryCount, InventorySku(i), InventoryName(i), InventoryDescription(i), InventoryImageUrl(i), InventoryQuantity(i), PurchasedItemId, PurchaseToken, XsollaUserToken (deprecated name for the purchase token), and the achievement expressions AchievementCount, AchievementKeyAt(i), AchievementNameAt(i), AchievementDescriptionAt(i), AchievementPointsAt(i), AchievementUnlockedAt(i), AchievementIsUnlockedAt(i) (1 or 0), LastUnlockReason, LastAchievementKey, LastAchievementName and LastAchievementPoints. Run List achievements before the ...At(i) expressions; Unlock achievement fills the LastAchievement... ones. For guests and unknown keys the action still completes, and LastUnlockReason is guest, not_found, not_live, rate_limited or error. See achievements.

SavedItem(key) reads the SDK directly once Initialize has completed, so a value saved anywhere in the game is visible at once.

JavaScript events#

JavaScript
// JavaScript code event, after the "init" request completed.
const SDK = window.ZokoGames.SDK;
SDK.user.getUser().then((user) => {
  runtimeScene.getVariables().get("PlayerName").setString(user ? user.username : "guest");
});

Room data channel#

Added in SDK 1.3.0. The room data channel lets the players of one room exchange small JSON messages and share a tiny state that only the host writes, so a simple multiplayer game needs no server of its own. It is for game data, not text chat. It exists after Update room (or after joining from an invite) and ends with Left room, needs a signed-in player and a portal with realtime enabled (otherwise roomUnavailable), and has these limits: 8 KB per message or patch, 20 messages per second, 64 KB of state, state keys of 1 to 40 characters of A-Z a-z 0-9 _ . : -. Messages are never echoed back to their sender on the portal; the first player in the room is the host. The full rules and error codes (notInRoom, notHost, payloadTooLarge, stateTooLarge, unknownMember, rateLimited, roomUnavailable) are in the game module and the multiplayer guide.

Message and value parameters accept text: valid JSON ({"x":1}, 5, true) is sent as that JSON value, anything else as plain text. On localhost the SDK's local mode makes two browser tabs that join the same room id behave like two players.

Kind Functions
Actions Send room message (tag, data), Send room message to member (tag, member id, data), Set room state key (tag, key, value; host only), Remove room state key (tag, key; host only)
Triggers On room message, On room state changed, On room members changed, On room host changed, On room left (SDK 1.7.0), On room error
Condition Is room host
Message expressions RoomMessageData, RoomMessageFrom, RoomMessageDirect, RoomMessageSeq, RoomMessageValue(key)
State expressions RoomStateJSON, RoomStateValue(key), RoomStateChangedKeys, RoomStateChangedBy, RoomStateRev
Member expressions RoomMemberCount, RoomMemberIdAt(i), RoomMemberNameAt(i), RoomMemberPictureUrlAt(i), RoomHostId, RoomSelfId
Left expressions RoomLeftReason (left, kicked, closed, disconnected), RoomLeftRoomId (for On room left, SDK 1.7.0)
Error expressions RoomErrorCode, RoomErrorMessage (for the room error trigger; request failures still use On request failed)
ZokoGames: On room host changed
  + ZokoGames: Is room host        -> ZokoGames: Set room state key (key "turn", value "X", tag "turn")
Cell is clicked                    -> ZokoGames: Send room message ("{""cell"":" + ToString(Cell) + "}", tag "move")
ZokoGames: On room message         -> place a mark at ZokoGames::RoomMessageValue("cell")
ZokoGames: On room state changed   -> Text: set to ZokoGames::RoomStateValue("turn")

Export settings that matter on the web#

  • Export as HTML5 (local folder) and zip the export folder contents so index.html is at the archive root.
  • No pre-compression. GDevelop requests plain file names; upload the export as is. Limits: 1,500 files, 250 MB unpacked, about 50 MB initial download (20 MB for mobile); compress images and audio, and see first frame fast.
  • Canvas sizing. The frame size changes with fullscreen and rotation. Set the game resolution to adapt (Project properties > Resolution and rendering) so the scene fits every required resolution.
  • Audio unlock. Browsers keep audio suspended until the first click or tap. Start music from a "tap to play" button, not at the beginning of the first scene.
  • Fullscreen. Prefer the fullscreen button in the portal's frame bar; do not add a competing button.
  • Loading. Run Loading start in your first scene, Report loading progress while you load resources, and Loading stop when play can begin.

Chat reports, screenshots and storage mirror#

Since SDK 1.4.0: the action Report chat message (name, message, reason, optional user id, room id and context JSON), the actions Set screenshot provider and Answer screenshot with the condition On screenshot requested, and Mirror localStorage to cloud save with the condition On mirror error. When the screenshot provider is on and the game does not answer within 1.5 seconds, the game canvas is sent. GDevelop's Storage actions keep their data in IndexedDB, so the mirror does not copy them; use the cloud save actions for those saves.

SDK 1.7.0#

  • Track event (name, params JSON): fire and forget. Name: a lowercase letter, then lowercase letters, digits or underscore, at most 40 characters. Params: an optional flat JSON object with at most 10 text, number or yes/no values.
  • On room left with RoomLeftReason and RoomLeftRoomId: the portal ended the player's room membership without the game asking (kicked, room closed, disconnected). The host flag is cleared.
  • Show invite button (portal only) and Hide invite button (portal only): the portal's invite button without changing whether the room is joinable. The link is in ResultString.
  • data.mirrorIndexedDB is not an action: it must run in the page before the game reads its files, so call ZokoSDK.data.mirrorIndexedDB from a page script before the game loads.

Ad rules#

There are no prerolls: your game cannot request an ad before it starts. Midgame is the only interstitial type, so an interstitial or commercial break from another platform becomes a midgame ad (Request ad with type midgame); the only other type is rewarded. In local mode (testing on localhost, outside the portal) a midgame request fails with On ad error with adCooldown until your game has called the Gameplay start action or 30 seconds of visible page time have passed. On the portal the first midgame ad needs the Gameplay start action first as well, so call it when the player takes control (a game that never calls it gets midgame ads 30 seconds after play begins). Rewarded ads are not held back by this. Details: ads reference and ads guide.

Test locally#

There is no separate simulator. When the page's host is localhost, 127.0.0.1 or a *.localhost name, the JavaScript SDK runs its own local mode: a three-second overlay for each ad, a fake player, a localStorage cloud save and a three-item test store, so the same events fire as on the portal. On any other host the environment is disabled, and Is available is false.

  • GDevelop's preview runs from a small local web server. If Environment reads disabled there (a network address instead of localhost), export the project and serve the folder from localhost, or open the page with ?useLocalSdk=true.
  • A second midgame request within three minutes fails with adCooldown (fires On ad error): the real rule, so your events must cope.
  • Useful switches: ?sdk_debug=true, ?ad_response=unfilled, ?user_response=logged_out.
  • Then open the Preview tool with your local address and watch the checklist tick.

API#

init#

JavaScript GDevelop
init Action Initialize; conditions IsInitialized, IsAvailable
environment Expression Environment
isQaTool Condition IsQaTool
JavaScript GDevelop
ad.requestAd Action RequestAd; conditions OnAdStarted, OnAdFinished, OnAdError, IsAdPlaying
ad.requestAd.adStarted Condition OnAdStarted; IsAdPlaying true
ad.requestAd.adFinished Condition OnAdFinished
ad.requestAd.adError Condition OnAdError; expression ErrorCode
ad.hasAdblock Action HasAdblock
JavaScript GDevelop
banner.requestBanner Action RequestBanner
banner.requestResponsiveBanner Action RequestResponsiveBanner
banner.clearBanner Action ClearBanner
banner.clearAllBanners Action ClearAllBanners

game.*#

JavaScript GDevelop
game.settings Expressions MuteAudio, DisableChat, KidsMode; conditions IsMuteRequested, IsChatDisabled, IsKidsMode
game.addSettingsChangeListener Condition OnSettingsChanged
game.gameplayStart Action GameplayStart
game.gameplayStop Action GameplayStop
game.loadingStart Action LoadingStart
game.loadingStop Action LoadingStop
game.loadingProgress Action LoadingProgress
game.happytime Action Happytime
game.reportGameCompletedPercentage Action ReportCompleted
game.reportChat Action ReportChat
game.onScreenshotRequest Actions SetScreenshotProvider, AnswerScreenshot; condition OnScreenshotRequested
game.setGameContext Action SetGameContext
game.clearGameContext Action ClearGameContext
game.isInstantMultiplayer Condition IsInstantMultiplayer
game.isInstantJoin Condition IsInstantMultiplayer
game.isOffline Condition IsOffline
game.gameId Expression GameId
game.addOfflineListener Condition OnOfflineChanged
game.updateRoom Action UpdateRoom; action SetRoomPublic
game.leftRoom Action LeftRoom
game.addJoinRoomListener Condition OnJoinRoom
game.inviteParams Expressions InviteParamsJSON, InviteParam
game.inviteLink Action InviteLink
game.getInviteParam Expression InviteParam
game.showInviteButton Actions ShowInviteButton; ShowInviteButtonPortalOnly ({ portalOnly: true })
game.hideInviteButton Actions HideInviteButton; HideInviteButtonPortalOnly ({ portalOnly: true })
game.room Actions SendRoomMessage, SendRoomMessageTo, SetRoomStateKey, RemoveRoomStateKey; conditions OnRoomMessage, OnRoomStateChanged, OnRoomMembersChanged, OnRoomHostChanged, OnRoomError, IsRoomHost
game.room.send Actions SendRoomMessage, SendRoomMessageTo
game.room.onMessage Condition OnRoomMessage; expressions RoomMessageData, RoomMessageFrom, RoomMessageDirect, RoomMessageSeq, RoomMessageValue
game.room.addMessageListener Condition OnRoomMessage
game.room.setState Actions SetRoomStateKey, RemoveRoomStateKey
game.room.getState Expressions RoomStateJSON, RoomStateValue
game.room.onState Condition OnRoomStateChanged; expressions RoomStateChangedKeys, RoomStateChangedBy, RoomStateRev
game.room.addStateListener Condition OnRoomStateChanged
game.room.members Expressions RoomMemberCount, RoomMemberIdAt, RoomMemberNameAt, RoomMemberPictureUrlAt
game.room.onMembers Condition OnRoomMembersChanged
game.room.addMembersListener Condition OnRoomMembersChanged
game.room.isHost Condition IsRoomHost
game.room.onHostChange Condition OnRoomHostChanged; expression RoomHostId
game.room.addHostChangeListener Condition OnRoomHostChanged
game.room.selfId Expression RoomSelfId
game.room.onError Condition OnRoomError; expressions RoomErrorCode, RoomErrorMessage
game.room.addErrorListener Condition OnRoomError
game.room.addLeftListener Condition OnRoomLeft; expressions RoomLeftReason, RoomLeftRoomId

user.*#

JavaScript GDevelop
user.isUserAccountAvailable Condition IsAccountAvailable
user.systemInfo Expressions Locale, CountryCode, DeviceType
user.getUser Action GetUser; expressions UserName, UserPictureUrl, UserId; condition IsLoggedIn
user.listFriends Action ListFriends; expressions FriendCount, FriendsTotal, FriendsHasMore, FriendName, FriendId, FriendPictureUrl
user.getUserToken Action GetUserToken; expression UserToken
user.showAuthPrompt Action ShowAuthPrompt
user.addAuthListener Condition OnAuthChanged
user.showAccountLinkPrompt Action ShowAccountLinkPrompt
user.submitScore Action SubmitScore
user.getXsollaUserToken Action GetXsollaUserToken; expression XsollaUserToken

data.*#

JavaScript GDevelop
data.getItem Action GetItem; expressions SavedItem, HasSavedItem
data.setItem Action SetItem
data.removeItem Action RemoveItem
data.clear Action ClearData
data.mirrorLocalStorage Actions MirrorLocalStorage, StopMirrorLocalStorage; condition OnMirrorError; expressions MirrorErrorCode, MirrorErrorMessage

store.*#

JavaScript GDevelop
store.isAvailable Condition IsStoreAvailable
store.getCatalogItems Action GetCatalogItems; expressions StoreItemCount, StoreItemSku, StoreItemName, StoreItemDescription, StoreItemImageUrl, StoreItemPrice, StoreItemCurrency, StoreItemConsumable
store.getPlayerInventory Action GetPlayerInventory; expressions InventoryCount, InventorySku, InventoryName, InventoryDescription, InventoryImageUrl, InventoryQuantity
store.buyItem Action BuyItem; expression PurchasedItemId
store.consumeItem Action ConsumeItem
store.getPurchaseToken Action GetPurchaseToken; expression PurchaseToken
store.setSandbox Action SetSandbox

achievements.*#

JavaScript GDevelop
achievements.list Action ListAchievements; expressions AchievementCount, AchievementKeyAt, AchievementNameAt, AchievementDescriptionAt, AchievementPointsAt, AchievementUnlockedAt, AchievementIsUnlockedAt
achievements.unlock Action UnlockAchievement; expressions LastUnlockReason, LastAchievementKey, LastAchievementName, LastAchievementPoints
achievements.onUnlock Condition OnAchievementUnlocked

analytics.*#

JavaScript GDevelop
analytics.track Action TrackEvent
analytics.trackOrder Action TrackOrder

constants#

JavaScript GDevelop
ERROR_CODES Expression ErrorCodes; condition LastErrorIs
ERROR_CODE_DESCRIPTIONS Expression ErrorDescription
SDK_VERSION Expression SdkVersion

Known pitfalls#

  • Import fails. Import ZokoGames.json, not the zip.
  • A condition is never true. The tag in On request completed must equal the tag passed to the action, and only one request per tag should be in flight.
  • Actions run but nothing happens. Run Initialize first and wait for its completion.
  • sdkNotLoaded. Offline or the SDK host is blocked; the preview needs internet access to load the script.
  • Actions after an ad request run late. GDevelop waits for the request; start ads in their own event.
  • Banner in the wrong place. Rectangles are game resolution pixels, origin top-left.

Next#