Skip to content

Commit

Permalink
[Commands] Cleanup #resetaa_timer Command. (#2131)
Browse files Browse the repository at this point in the history
* [Commands] Cleanup #resetaa_timer Command.
- Cleanup messages and logic.

* Typos.
  • Loading branch information
Kinglykrab authored May 7, 2022
1 parent 90725f9 commit 37d5d96
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 15 deletions.
2 changes: 1 addition & 1 deletion zone/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
62 changes: 48 additions & 14 deletions zone/gm_commands/resetaa_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

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();
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;
}
else {
c->Message(Chat::White, "usage: #resetaa_timer [all | timer_id]");

if (sep->IsNumber(1)) {
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);
}
}

0 comments on commit 37d5d96

Please sign in to comment.