[Commands] Cleanup #resetaa_timer Command. (#2131)

* [Commands] Cleanup #resetaa_timer Command.
- Cleanup messages and logic.

* Typos.
This commit is contained in:
Kinglykrab 2022-05-06 20:26:59 -04:00 committed by GitHub
parent 90725f9fd9
commit 37d5d96871
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 15 deletions

View File

@ -304,7 +304,7 @@ int command_init(void)
command_add("removeitem", "[Item ID] [Amount] - Removes the specified Item ID by Amount from you or your player target's inventory (Amount defaults to 1 if not used)", AccountStatus::GMAdmin, command_removeitem) ||
command_add("repop", "[Force] - Repop the zone with optional force repop", 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_timer", "Command to reset AA cooldown timers.", AccountStatus::GMMgmt, command_resetaa_timer) ||
command_add("resetaa_timer", "[All|Timer ID] - Command to reset AA cooldown timers for you or your player target.", AccountStatus::GMMgmt, command_resetaa_timer) ||
command_add("resetdisc_timer", "[All|Timer ID] - Command to reset discipline timers.", AccountStatus::GMMgmt, command_resetdisc_timer) ||
command_add("revoke", "[Character Name] [0|1] - Revokes or unrevokes a player's ability to talk in OOC by name (0 = Unrevoke, 1 = Revoke)", 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) ||

View File

@ -2,25 +2,59 @@
void command_resetaa_timer(Client *c, const Seperator *sep)
{
Client *target = nullptr;
if (!c->GetTarget() || !c->GetTarget()->IsClient()) {
target = c;
int arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Usage: #resetaa_timer all - Reset all Alternate Advancement timers");
c->Message(Chat::White, "Usage: #resetaa_timer [Timer ID] - Reset Alternate Advancement timer by ID");
return;
}
else {
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 Alternate Advancement timers for {}.",
(
c == target ?
"yourself" :
fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
)
)
).c_str()
);
target->ResetAlternateAdvancementTimers();
return;
}
if (sep->IsNumber(1)) {
int timer_id = atoi(sep->arg[1]);
c->Message(Chat::White, "Reset of timer %i for %s", timer_id, c->GetName());
c->ResetAlternateAdvancementTimer(timer_id);
}
else if (!strcasecmp(sep->arg[1], "all")) {
c->Message(Chat::White, "Reset all timers for %s", c->GetName());
c->ResetAlternateAdvancementTimers();
}
else {
c->Message(Chat::White, "usage: #resetaa_timer [all | timer_id]");
int timer_id = std::stoi(sep->arg[1]);
c->Message(
Chat::White,
fmt::format(
"Reset Alternate Advancement timer {} for {}.",
timer_id,
(
c == target ?
"yourself" :
fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
)
)
).c_str()
);
target->ResetAlternateAdvancementTimer(timer_id);
}
}