How can I tell if game shuts down on player removing?

So in my game I have a combat logging system, if on player removing you have a combat tag it will adjust ur data to punish u for combat logging. However BindToClose fires AFTER player removing events so how could I check if the game is shutting down during the player removing event?

Would it be a good idea to do something like task.wait(1) before checking for a combat log? Or could it be inconsistent.

Instead of checking if the game is shutting down, why not check to see how many players are left in the game during PlayerRemoving? If the player is the only one left in the entire server and coincidentally leaves while having combat log, do not inflict any punishments.

1 Like

What if the player isn’t the only one left in the server though?

Also I have combat tags that come from non-players. Things like monsters could combat tag a player.

Ah, I was under the impression that the combat log system strictly applies to a PvP environment.

What I gather from this, you are attempting to check if a server has crashed/shutdown which explains why a server would close with more than 1 player. In this case, there is no other way besides :BindToClose() to check for this.

1 Like

The issue is bind to close fires after player removing resulting in delay. Surely there has to be a way to detect shutdown with players being removed.

And yea im detecting when a server shuts down or crashes.

Why not add the combat logging on the PlayerRemoving event? You can always insert a folder inside of ServerStorage keeping track of all combat tags. When the player leaves, you can punish the player by adjusting their Data using DataStoreService.

1 Like

What do you mean by this? I already adjust the data in the player removing event.

So why would you need to check if it is shut down? I am just asking because maybe the solution to the problem can be found without checking for a shutdown because I think it isn’t possible to check if Roblox has shut down. Maybe by checking memory usage.

1 Like

I just did some research and BindToClose is your best bet.

1 Like

I dont think you read the post. I mention the issue with bindtoclose and why I want to check for the shutdown.

A hacky solution I came up with:

  1. Have a boolean variable saved to a datastore with the player’s userId
    • When a player is tagged, set this variable to true
    • When a player leaves, whatever data this variable contained is now saved
  2. When a player leaves the game, save their userId to a table
    • You could clear this table every x seconds
  3. On a :BindToClose() event, find every player’s userId from the table and set their bool value to false
    • If a player leaves the game while tagged and BindToClose fires, change every player’s bool value to false
1 Like

I did something similar before, instead of setting the data on player removing I set a boolean and when they rejoined I would punish them with adjusting their data. However I can no longer do it on rejoin as now my game forces you to drop your loot when you combat log.

Yikes, that is indeed a very complicated problem.

1 Like

Maybe something to do with memory or something would be the right solution.

My worse case solution is having a custom command in-game to shutdown all servers with message service. But if a server crashes people will get combat logged which can very well happen so I do want to fix this problem.

Ok so I found a potential solution but one issue remains.

~ Save what the players data was before combat logging as a variable, then adjust the data to punish them

~ setup event so that on shutdown we set the data back to the saved variable.
~ Disconnect that shutdown event after 30 seconds (since shutdowns run functions for a maximum of 30 seconds before force shutting down)

Now the issue with this solution is that what if they simply combat log before a shutdown or crash occurs? You may be thinking “Well so what” but the issue is this could leave a dupe in my game since u drop loot on death. Someone could open the loot bag and take out items before a shutdown if u actually combat logged before a shutdown occurred.

I added a property to the loot bags called “BeenOpened” so I can check if their loot bag has been opened. If they combat log and their loot bag hasn’t been opened during a shutdown then I reset the data. Realistically if u clog during a real shutdown nobody would be able to open ur loot bag so this cant create any issues. Only thing someone can do is potentially combat log 30 seconds before a shutdown but combat tags last 60 seconds anyways so the shutdown probably would’ve clog checked them anyways.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.