From 269dd2be19d32ec0887831eb7baa12e357c1d90a Mon Sep 17 00:00:00 2001 From: Pierce Date: Sat, 18 Dec 2021 20:51:41 -0500 Subject: [PATCH] use shutdown hook --- lua/cfc_disconnect_interface/client/cl_interface.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/cfc_disconnect_interface/client/cl_interface.lua b/lua/cfc_disconnect_interface/client/cl_interface.lua index 49639cb..d68718d 100644 --- a/lua/cfc_disconnect_interface/client/cl_interface.lua +++ b/lua/cfc_disconnect_interface/client/cl_interface.lua @@ -456,13 +456,19 @@ local function createInterface() end end + +local isShuttingDownManually = false +hook.Add( "ShutDown", "CFC_DisconnectInterface_MarkShutdown", function() + isShuttingDownManually = true +end ) + hook.Add( "CFC_CrashTick", "CFC_DisconnectInterface_InterfaceUpdate", function( isCrashing, _timeDown, _apiState ) timeDown = _timeDown if _apiState ~= CFCCrashAPI.PINGING_API then apiState = _apiState end - if isCrashing then + if isCrashing and not isShuttingDownManually then -- Open interface if server is crashing, API has responded, interface isn't already open, and interface has not yet been opened if _apiState == CFCCrashAPI.PINGING_API or _apiState == CFCCrashAPI.SERVER_UP then return end if interfaceDerma or previouslyShown then return end