From c4630c4e2de31cca3fa2edd09c61351d5203756f Mon Sep 17 00:00:00 2001 From: jadebenn <jadebenn@users.noreply.github.com> Date: Sat, 14 Dec 2024 14:14:20 -0600 Subject: [PATCH] added uptime chat command --- dGame/dUtilities/SlashCommandHandler.cpp | 9 +++++++++ dGame/dUtilities/SlashCommands/GMZeroCommands.cpp | 9 +++++++-- dGame/dUtilities/SlashCommands/GMZeroCommands.h | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index c09668974..b1bf01afb 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -1056,6 +1056,15 @@ void SlashCommandHandler::Startup() { }; RegisterCommand(InstanceInfoCommand); + Command ServerUptimeCommand{ + .help = "Display the time the current server has been active", + .info = "Display the time the current server has been active", + .aliases = { "serveruptime", "uptime" }, + .handle = GMZeroCommands::ServerUptime, + .requiredLevel = eGameMasterLevel::CIVILIAN + }; + RegisterCommand(ServerUptimeCommand); + //Commands that are handled by the client Command faqCommand{ diff --git a/dGame/dUtilities/SlashCommands/GMZeroCommands.cpp b/dGame/dUtilities/SlashCommands/GMZeroCommands.cpp index 6c9811c24..51fa6e15b 100644 --- a/dGame/dUtilities/SlashCommands/GMZeroCommands.cpp +++ b/dGame/dUtilities/SlashCommands/GMZeroCommands.cpp @@ -225,8 +225,13 @@ namespace GMZeroCommands { ChatPackets::SendSystemMessage(sysAddr, u"Map: " + (GeneralUtils::to_u16string(zoneId.GetMapID())) + u"\nClone: " + (GeneralUtils::to_u16string(zoneId.GetCloneID())) + u"\nInstance: " + (GeneralUtils::to_u16string(zoneId.GetInstanceID()))); } + // Display the server uptime + void ServerUptime(Entity* entity, const SystemAddress& sysAddr, const std::string args) { + const auto time = Game::server->GetUptime(); + const auto seconds = std::chrono::duration_cast<std::chrono::seconds>(time).count(); + ChatPackets::SendSystemMessage(sysAddr, u"Server has been up for " + GeneralUtils::to_u16string(seconds) + u" s"); + } + //For client side commands void ClientHandled(Entity* entity, const SystemAddress& sysAddr, const std::string args) {} - }; - diff --git a/dGame/dUtilities/SlashCommands/GMZeroCommands.h b/dGame/dUtilities/SlashCommands/GMZeroCommands.h index d3f6753d0..00824bf86 100644 --- a/dGame/dUtilities/SlashCommands/GMZeroCommands.h +++ b/dGame/dUtilities/SlashCommands/GMZeroCommands.h @@ -15,6 +15,7 @@ namespace GMZeroCommands { void LeaveZone(Entity* entity, const SystemAddress& sysAddr, const std::string args); void Resurrect(Entity* entity, const SystemAddress& sysAddr, const std::string args); void InstanceInfo(Entity* entity, const SystemAddress& sysAddr, const std::string args); + void ServerUptime(Entity* entity, const SystemAddress& sysAddr, const std::string args); void ClientHandled(Entity* entity, const SystemAddress& sysAddr, const std::string args); }