Whenever you use mp_add, you need to do 2 things for each variable you sync with it:
Add the following to the end step event:
self.VARIABLENAME = mp_map_syncOut("VARIABLENAME", self.VARIABLENAME);
Where you replace "VARIABLENAME" with the name of your variable.
This also needs to be done at least once after you set up the engine if you don't put it in begin step.
THIS DOES NOT TO BE DONE FOR ANY OTHER FUNCTION STARTING WITH mp_add. ONLY WITH mp_add ITSELF!
The engine needs to know what variables it needs to sync. So if you execute this code:
Then we know you want to sync the variable message. The problem/limitation in Game Maker is, that we can't get the value of the message variable of this instance now. Why?
Well let me have an example. This works:
var instance; //Some valid instance var test = (instance).x; //Test will now have the x position of the instance as value
Now in that case we are directly accessing the x-Position of the instance. That's what all other mp_add* functions besides mp_add itself do, because they can be hardcoded. When writing the code we already know what to sync and in what order.
We don't know how your variables are called while coding, so we have to get them dynamically. Let's take the following exmaple:
var instance; //Some valid instance var variable = "x"; //What now??? var test = (instance).variable; //? Doesn't work! var test = (instance).(variable); //? Doesn't work! var test = (instance)[variable]; //? Doesn't work!
There's no way in Game Maker Studio of doing that. That's why we use a ds_map to cache your instances variables. Because with a ds_map, that does work!
var map; //Some valid ds_map that belongs to your instance; That's what you change when using the syncIn and syncOut command var variable = "x"; var test = ds_map_find_value(map,variable); //Yay! Works!
All pages in this manual are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Manuals / GMnet ENGINE Manual
|0. What is GMnet ENGINE?|
|1. Basic configuration|
|2. PLUS - Setup GMnet PUNCH|
|3. PLUS - Hosting a master server|
|4. Starting the engine|
|5. Setting up the basic platformer|
|6. The network controller|
|7. Adding a player|
|8. A second room and doors|
|9. Showing a list of players|
|10. Adding day/night|
|11. Creating a chat system|
|12. Conclusion / What's next|
|BONUS 1 - PLUS - ONLINE lobby|
|BONUS 2 - Global Sync|
|BONUS 3 - LAN lobby|
|BONUS 4 - Event Handlers for Connecting/Disconnecting|
|BONUS 5 - RPC|
|Local and remote Instances|
|Instance scope and rooms|
|Players and Playerhashes|
|States of the engine|
|mp_map_syncIn and mp_map_syncOut|
|VarGroup SyncTypes (mp_type)|
|PLUS - GMnet PUNCH|
|PLUS - Master Server (GMnet GATE.PUNCH)|
|The debug overlay|
|PLUS - GMnet GATE.TESTER|
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.