diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index fe60fadd..7775570f 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -330,6 +330,7 @@ namespace Components Dvar::OnInit([] () { Dvar::Register("sv_sayName", "^7Console", Game::dvar_flag::DVAR_FLAG_NONE, "The name to pose as for 'say' commands"); + Dvar::Register("sv_motd", "", Game::dvar_flag::DVAR_FLAG_NONE, "A custom message of the day for servers"); // Say command Command::AddSV("say", [] (Command::Params params) diff --git a/src/Components/Modules/Menus.cpp b/src/Components/Modules/Menus.cpp index 0e11c2dd..7973801f 100644 --- a/src/Components/Modules/Menus.cpp +++ b/src/Components/Modules/Menus.cpp @@ -623,7 +623,16 @@ namespace Components AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_MENUFILE, Menus::MenuFileLoad); // Don't open connect menu - Utils::Hook::Nop(0x428E48, 5); + //Utils::Hook::Nop(0x428E48, 5); + + // Use the connect menu open call to update server motds + Utils::Hook(0x428E48, []() + { + if (!Party::GetMotd().empty()) + { + Dvar::Var("didyouknow").set(Party::GetMotd()); + } + }, HOOK_CALL).install()->quick(); // Intercept menu painting Utils::Hook(0x4FFBDF, Menus::IsMenuVisible, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index 081f6410..f8c2eae7 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -72,6 +72,11 @@ namespace Components Command::Execute("openmenu menu_xboxlive_partyended"); } + std::string Party::GetMotd() + { + return Party::Container.motd; + } + Game::dvar_t* Party::RegisterMinPlayers(const char* name, int /*value*/, int /*min*/, int max, Game::dvar_flag flag, const char* description) { return Dvar::Register(name, 1, 1, max, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED | flag, description).get(); @@ -319,6 +324,11 @@ namespace Components info.set("securityLevel", fmt::sprintf("%i", Dvar::Var("sv_securityLevel").get())); info.set("sv_running", (Dvar::Var("sv_running").get() ? "1" : "0")); + if (Dedicated::IsEnabled()) + { + info.set("sv_motd", Dvar::Var("sv_motd").get()); + } + // Ensure mapname is set if (info.get("mapname").empty() || (Dvar::Var("party_enable").get() && Dvar::Var("party_host").get() && !Dvar::Var("sv_running").get())) { @@ -398,6 +408,8 @@ namespace Components } else { + Party::Container.motd = info.get("sv_motd"); + if (Party::Container.matchType == 1) // Party { // Send playlist request diff --git a/src/Components/Modules/Party.hpp b/src/Components/Modules/Party.hpp index 841d4d67..ba491063 100644 --- a/src/Components/Modules/Party.hpp +++ b/src/Components/Modules/Party.hpp @@ -21,12 +21,15 @@ namespace Components static void ConnectError(std::string message); + static std::string GetMotd(); + private: class JoinContainer { public: Network::Address target; std::string challenge; + std::string motd; DWORD joinTime; bool valid; int matchType; @@ -35,7 +38,7 @@ namespace Components // Party-specific stuff DWORD requestTime; - bool awaitingPlaylist; + bool awaitingPlaylist; }; static JoinContainer Container;