MANUAL for GMnet ENGINE and GMnet CORE

14. Global Sync

The update to version 1.1 added a new feature called "Global Sync".

Before you learned how to sync instances between games in this tutorial. However this concept has one downside: Instances are only created and controlable by one client. All variables of an instance are read-only to all other clients. That's why we needed to create a seperate chat instance for each player that basicaly all jut synced one chat variable. That may be fine for a few variables, and in this case maybe even the best way of doing it, since every player still needs one "chat outbox", however you can now sync global variables that are read- and writeable by all clients at all times.

Summary of Global Sync's features: Change the value on one end and it will update on all other ends as well. All ends can update and access all variables

How it works

It's super simple. To store a variable in the Global Sync pool use this little code:

var value = 1+1;
htme_globalSet("name",value,buffer_u8);

The third argument is the Buffer type/data type.

This will now sync to all clients immediately (using the SMART syncType.).

You can retrieve this variable via this code on all connected clients and the server:

var value = htme_globalGet("name")

Please note that this function may return undefined if it wasn't set by any of the clients/server yet, so check if it is defined:

if (is_undefined((htme_globalGet("name")) {
    //Nope, that wasn't set yet...
}

» Next topic: PLUS - Bonus 3 - A LAN lobby

« Previous topic: PLUS - Bonus 1 - An ONLINE lobby


Back to index.


Creative Commons License

All pages in this manual are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Manuals / GMnet ENGINE Manual

GameMaker: Studio is owned by YoYoGames. GMnet is not affiliated with YoYoGames.
The GMnet logos use icons from Entypo (http://entypo.com/) and Open Iconic (https://useiconic.com/open/). They are licensed under CC BY-SA 4.0.