Skip to content

Commit

Permalink
added uptime chat command
Browse files Browse the repository at this point in the history
  • Loading branch information
jadebenn committed Dec 14, 2024
1 parent 3695838 commit c4630c4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions dGame/dUtilities/SlashCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
9 changes: 7 additions & 2 deletions dGame/dUtilities/SlashCommands/GMZeroCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

};

1 change: 1 addition & 0 deletions dGame/dUtilities/SlashCommands/GMZeroCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit c4630c4

Please sign in to comment.