mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 18:24:12 +00:00
feat: Remove reinterpret_casts from AG race timer script and add method and chat command to get current server uptime (#1673)
* use steady_clock race timer * formatting and const * improve time interface * added uptime chat command * fix bug and update documentation * inrease /uptime GM level requirement * update GM level for /uptime (again) * made changes according to feedback
This commit is contained in:
@@ -1056,6 +1056,15 @@ void SlashCommandHandler::Startup() {
|
||||
};
|
||||
RegisterCommand(InstanceInfoCommand);
|
||||
|
||||
Command ServerUptimeCommand{
|
||||
.help = "Display the time the current world server has been active",
|
||||
.info = "Display the time the current world server has been active",
|
||||
.aliases = { "uptime" },
|
||||
.handle = GMZeroCommands::ServerUptime,
|
||||
.requiredLevel = eGameMasterLevel::DEVELOPER
|
||||
};
|
||||
RegisterCommand(ServerUptimeCommand);
|
||||
|
||||
//Commands that are handled by the client
|
||||
|
||||
Command faqCommand{
|
||||
|
@@ -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) {}
|
||||
|
||||
};
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user