In about 2 months, I plan to start work on a new game, where it would be very important to know when a player manually disconnects or they lose connection.
I would prefer not to punish a player for losing connection, but I don’t want to make it possible for people to evade being killed by an enemy by closing Roblox without having to suffer consequences.
(I think this thread exists but is very old, and I couldn’t find it.)
9 Likes
All the times i’ve ever had my Apocalypse Rising data deleted because of bandits and poor wifi…
2 Likes
That would let players game the system by turning on airplane mode.
You need to consider lots of variables to get a reasonably accurate prediction of whether they left intentionally
- Menu was open → probably intentional
- In a close-quarters combat game, WalkToPoint is zero → probably intentional
- Low health → probably intentional
- Derivative of the moving average of health is negative → probably intentional
- If this feature request is implemented, player was reported as disconnected → probably unintentional
- High ping → probably unintentional
There has to be a linear combination of those factors that will give you the probability of whether a player left by choice or not.
or
If you don’t want to spend all your time on that, only let them leave without consequences if their health is above some threshold and there are no enemies nearby. Clearly communicate that to the players.
7 Likes
You can already tell.
Make a RemoteFunction that the client calls in a loop to report to the server that it’s still connected. Keep a record of when the last time the player called that function was. When a player leaves, check how long ago their last response on that RemoteFunction was. On a properly functioning connection this will be within the past two seconds, so if the time since the last message is longer than that it’s safe to say they were disconnected for whatever reason. If it was shorter than that they definitely closed the game.
You can also keep a moving average of their ping and consider it intentional if there’s no significant increase in ping before the disconnect. Most of the time a legitimate loss of connection shows symptoms a few seconds before the connection is actually lost. Keep in mind that this is unreliable and may give you a false reading at times.
You could go even further with this and check if any recent damage they took was before the last time their client reported in, and if the damage they took was before then, check if whatever dealt that damage was still alive at the time they last checked in. That won’t let you catch people who disconnect before any shots were fired or that disconnect when they see a horde of zombies approaching, but it will let you catch those who disconnect the moment anything hits them.
Regardless of all this, you have to be very careful with penalizing players that were reported as having lost connection. There is no reliable way to tell why the connection loss happened, and all you have is a best guess. If that best guess happens to get it wrong you could frustrate a lot of players.
I also wouldn’t penalize players for leaving while enemies are nearby, because the player may very well be unaware of their presence, and also not for leaving with less than a certain amount of health because you don’t want to force players to continue playing to find a way to heal up.
Whatever you do I’d clearly communicate to the player when it’s okay to close the game and when it isn’t. I don’t want to leave thinking I’ll be fine only to find out that for some reason I wasn’t allowed to. Ideally you’d have a message on the screen saying “You may disconnect” in green or “You may not disconnect” in red, so unless you’d be giving away information that takes away from gameplay, you should definitely add such a feature.
13 Likes
Can you give us a code example on how to implement this? Thank you.
1 Like