Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I detect when a server is shutting down?

Asked by
GShocked 150
7 years ago

I have a database that keeps track of all the servers in my game. I need it to remove a server when it is being shut down so that its no longer in the database. Is there a way of detecting a server shutdown, and giving enough time to send an HTTP Post request?

2 answers

Log in to vote
3
Answered by 7 years ago

You'll want to use

game.OnClose = function()

like TheHospitalDev said.

There is also a new feature called BindToClose which allows you to bind all your "OnClose" functions if you have multiple.


game:BindToClose(function() print("Starting callback...") wait(5) print("Done callback...") end)
2
OnClose should not be used because it is deprecated. Use game:BindToClose from now on Validark 1580 — 7y
Ad
Log in to vote
1
Answered by 7 years ago

You could try using the OnClose function.

game.OnClose = function() --When the last player leaves, connect.
    --Do stuff here...
    wait(60) --Waits a minute, should be long enough
end

Answer this question