[Commands] Add #clearxtargets Command (#3833)

# Perl
- Add `$client->ClearXTargets()`.

# Lua
- Add `client:ClearXTargets()`.

# Notes
- Add `#clearxtargets` command for players.
- Allows operators/players to clear their XTargets if something get stuck on it.
This commit is contained in:
Alex King
2024-01-06 23:18:21 -05:00
committed by GitHub
parent 122fe398b4
commit 99d2e3a8b1
10 changed files with 95 additions and 2 deletions
+50
View File
@@ -0,0 +1,50 @@
#include "../client.h"
void command_clearxtargets(Client *c, const Seperator *sep)
{
const int reuse_timer = RuleI(Character, ClearXTargetDelay);
const int arguments = sep->argnum;
if (arguments) {
const bool is_help = !strcasecmp(sep->arg[1], "help");
if (is_help) {
c->Message(Chat::White, "Usage: #clearxtargets");
c->Message(
Chat::White,
"Note: Use this if your Extended Target window is bugged or has lingering targets that are invalid."
);
if (reuse_timer) {
c->Message(
Chat::White,
fmt::format(
"Note: This can only be used every {}.",
Strings::SecondsToTime(reuse_timer)
).c_str()
);
}
return;
}
}
if (reuse_timer) {
const uint32 time_left = c->GetPTimers().GetRemainingTime(pTimerClearXTarget);
if (!c->GetPTimers().Expired(&database, pTimerClearXTarget, false)) {
c->Message(
Chat::White,
fmt::format(
"You must wait {} before using this command again.",
Strings::SecondsToTime(time_left)
).c_str()
);
return;
}
}
c->ClearXTargets();
c->Message(Chat::White, "Extended Target window has been cleared.");
if (reuse_timer) {
c->GetPTimers().Start(pTimerClearXTarget, reuse_timer);
}
}