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?
You'll want to use
1 | 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.
1 | game:BindToClose( function () |
2 | print ( "Starting callback..." ) |
3 | wait( 5 ) |
4 | print ( "Done callback..." ) |
5 | end ) |
You could try using the OnClose function.
1 | game.OnClose = function () --When the last player leaves, connect. |
2 | --Do stuff here... |
3 | wait( 60 ) --Waits a minute, should be long enough |
4 | end |