[Commands] Cleanup #resetdisc_timer Command. (#2133)

- Cleanup messages and logic.
This commit is contained in:
Kinglykrab 2022-05-06 19:50:58 -04:00 committed by GitHub
parent 55629ce396
commit 128e8ce08d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 14 deletions

View File

@ -305,7 +305,7 @@ int command_init(void)
command_add("repop", "[delay] - Repop the zone with optional delay", AccountStatus::GMAdmin, command_repop) || command_add("repop", "[delay] - Repop the zone with optional delay", AccountStatus::GMAdmin, command_repop) ||
command_add("resetaa", "- Resets a Player's AA in their profile and refunds spent AA's to unspent, may disconnect player.", AccountStatus::GMMgmt, command_resetaa) || command_add("resetaa", "- Resets a Player's AA in their profile and refunds spent AA's to unspent, may disconnect player.", AccountStatus::GMMgmt, command_resetaa) ||
command_add("resetaa_timer", "Command to reset AA cooldown timers.", AccountStatus::GMMgmt, command_resetaa_timer) || command_add("resetaa_timer", "Command to reset AA cooldown timers.", AccountStatus::GMMgmt, command_resetaa_timer) ||
command_add("resetdisc_timer", "Command to reset all discipline cooldown timers.", AccountStatus::GMMgmt, command_resetdisc_timer) || command_add("resetdisc_timer", "[All|Timer ID] - Command to reset discipline timers.", AccountStatus::GMMgmt, command_resetdisc_timer) ||
command_add("revoke", "[charname] [1/0] - Makes charname unable to talk on OOC", AccountStatus::GMMgmt, command_revoke) || command_add("revoke", "[charname] [1/0] - Makes charname unable to talk on OOC", AccountStatus::GMMgmt, command_revoke) ||
command_add("roambox", "[Remove|Set] [Box Size] [Delay (Milliseconds)] - Remove or set an NPC's roambox size and delay", AccountStatus::GMMgmt, command_roambox) || command_add("roambox", "[Remove|Set] [Box Size] [Delay (Milliseconds)] - Remove or set an NPC's roambox size and delay", AccountStatus::GMMgmt, command_roambox) ||
command_add("rules", "(subcommand) - Manage server rules", AccountStatus::GMImpossible, command_rules) || command_add("rules", "(subcommand) - Manage server rules", AccountStatus::GMImpossible, command_rules) ||

View File

@ -2,22 +2,59 @@
void command_resetdisc_timer(Client *c, const Seperator *sep) void command_resetdisc_timer(Client *c, const Seperator *sep)
{ {
Client *target = c->GetTarget()->CastToClient(); int arguments = sep->argnum;
if (!c->GetTarget() || !c->GetTarget()->IsClient()) { if (!arguments) {
target = c; c->Message(Chat::White, "Usage: #resetdisc_timer all - Reset all Discipline timers");
c->Message(Chat::White, "Usage: #resetdisc_timer [Timer ID] - Reset Discipline timer by ID");
return;
}
auto target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
target = c->GetTarget()->CastToClient();
}
bool is_all = !strcasecmp(sep->arg[1], "all");
if (is_all) {
c->Message(
Chat::White,
fmt::format(
"Reset all Discipline timers for {}.",
(
c == target ?
"yourself" :
fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
)
)
).c_str()
);
target->ResetAllDisciplineTimers();
return;
} }
if (sep->IsNumber(1)) { if (sep->IsNumber(1)) {
int timer_id = atoi(sep->arg[1]); auto timer_id = std::stoul(sep->arg[1]);
c->Message(Chat::White, "Reset of disc timer %i for %s", timer_id, c->GetName()); c->Message(
c->ResetDisciplineTimer(timer_id); Chat::White,
} fmt::format(
else if (!strcasecmp(sep->arg[1], "all")) { "Reset Discipline timer {} for {}.",
c->Message(Chat::White, "Reset all disc timers for %s", c->GetName()); timer_id,
c->ResetAllDisciplineTimers(); (
} c == target ?
else { "yourself" :
c->Message(Chat::White, "usage: #resetdisc_timer [all | timer_id]"); fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
)
)
).c_str()
);
target->ResetDisciplineTimer(timer_id);
} }
} }