diff --git a/code/components/citizen-server-impl/src/GameServer.cpp b/code/components/citizen-server-impl/src/GameServer.cpp index c09fecae3e..21525ac049 100644 --- a/code/components/citizen-server-impl/src/GameServer.cpp +++ b/code/components/citizen-server-impl/src/GameServer.cpp @@ -127,8 +127,12 @@ namespace fx m_mainThreadCallbacks = std::make_unique("inproc://main_client", 0); - instance->OnRequestQuit.Connect([this](const std::string& reason) + instance->OnRequestQuit.Connect([this, instance](const std::string& reason) { + instance + ->GetComponent() + ->GetComponent() + ->TriggerEvent2("onServerStop", {}); m_clientRegistry->ForAllClients([this, &reason](const fx::ClientSharedPtr& client) { DropClient(client, "Server shutting down: %s", reason); diff --git a/code/components/citizen-server-impl/src/TerminalInput.cpp b/code/components/citizen-server-impl/src/TerminalInput.cpp index a915918286..13c4ef158b 100644 --- a/code/components/citizen-server-impl/src/TerminalInput.cpp +++ b/code/components/citizen-server-impl/src/TerminalInput.cpp @@ -21,6 +21,8 @@ #include #include +#include "ResourceEventComponent.h" + using namespace std::chrono_literals; static int utf8str_codepoint_len(char const* s, int utf8len) @@ -371,6 +373,10 @@ static InitFunction initFunction([]() if (exit) { con->AddToBuffer(fmt::sprintf("quit \"Ctrl-C pressed in server console.\"\n")); + instance + ->GetComponent() + ->GetComponent() + ->TriggerEvent2("onServerStop", {}); break; } else if (!result)