gms_settings_declare_syncable_object

Usage: gms_settings_declare_syncable_object ( object_index )

Description

This script must be called before gms_settings. It must be called exactly once for each object that might be used in a call to gms_instance_sync.

The extension will now refuse to sync objects that have not been declared with this method. If you do not call this script for all objects that will be synced, you might notice that they don't appear on other clients. In such a case, calling this function with the object as the first argument might fix this.

Example

gms_settings_declare_syncable_object(obj_bullet)
gms_settings_declare_syncable_object(obj_npc)
gms_settings(...)

Replies (4)

Last message on 30 May 2021

TheRetroBoy on 16 May 2021, 04:31:24
Hey, does this work with parent objects? I'm making a Megaman Online game and I have a parent bullet object for other types of bullets. I declared prt_bullet, but it doesn't show up on other clients though. I also made sure it tried to sync it to other clients.

if (instance_exists(bullet))
{
shootTimer = 15; //This is for the sprite changing, the reason it's not an alarm is that it pauses when the screen is scrolling to another spot.
gms_instance_sync(bullet,is_onetime);
}

I have no idea what's going on.
Size43 (Administrator) on 18 May 2021, 22:51:33
Syncing works with parent objects. I am assuming 'bullet' is the name of the object?

By passing 'bullet' to gms_instance_sync, you are passing the object ID. You should pass the instance ID instead. It might be easiest to put 'gms_instance_sync(id, is_onetime)' in the create event of the bullet object.
TheRetroBoy on 22 May 2021, 23:27:48
Hi, the bullet is not the name of the object it's a variable, It'd be obj_bullet or prt_bullet for me, I check the weapon the player is currently using and run specific code needed for that weapon. The variable: bullet is defined something like this:

bullet = instance_create(x,y,bullet object here);
bullet.image_xscale = image_xscale;

I've figured this out by just making all bullet objects declared in the GMS object, it works perfectly.

Thank you though.
Size43 (Administrator) on 30 May 2021, 17:01:16
Ah apologies, I misunderstood your question. Declaring all child objects as syncable is indeed the right way to do this.