I've just noticed something really weird in my test game... to get anyone reading up to speed this is how I've come to where I am
In my game Ive followed the getting started tutorials... Have players logging in and running around can see each other join, leave, move, etc. I also set up a spawner following the instances syncing tutorial. I have the instance created by the spawner only if the self_ismaster() is true and its set to full sync | local.
When the players disconnect in game end Im using:
if(gms_instance_is_owner(id))
{
gms_instance_handover(id);
}
just like the tutorial says. It _appears_ to work fine. But I started having weird issues with there being a mob in the room when I start the game without the spawner ever making any. I removed the spawner object from the room and started the game... still a mob wandering around... far away from where it should start.
I spent hours trying to figure out how an instance of my mob object could be in a room with no way to create it... Then I started thinking about the instance handoff thing. What if with just 1 player (me testing things) when I log out theres no other player to hand the instances off to so they just stay on the server and when I log back in they sync to my first player (me testing things again) and self_ismaster() takes over again in some kind of half way...
I say half way because those instances wont sync right on other players screens but if the master player leaves they suddenly work fine on the remaining players screen (cause that player is the new master)
SO! I ran the game with just 1 player and destroyed the mob. Again, nothing in the room to create any instances of my obj_mob... so I closed the game and restarted it and logged back in and the mystery mob was gone. I logged in another player and everything seemed to be back to normal.
So my question is: Is it possible for instances to be orphaned and what is the correct way to handle this? I can recreate this as often as I want so it doesnt appear to be a glitch of some [continued]
Replies (2)
Last message on 21 Oct 2018
Size43
(Administrator)
on
21 Oct 2018, 16:59:23
Yup, if you hand over the instances when there's nobody else in the room, they will be re-assigned to the next player that joins the room. Which might be you again if you log out and back in immediately.
If you don't want this behaviour, you should destroy the instances before ending the game.
aridale
(Topicstarter)
on
17 Oct 2018, 06:37:08
[continued] kind. But that doesnt rule out that its an issue in my code or the servers. Any help would be great as Im hesitant to work on my games npcs/mobs anymore with it crashing any players passed the first the join for testing