eqemu-server/zone/gm_commands/clearxtargets.cpp
Alex King 99d2e3a8b1
[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.
2024-01-06 22:18:21 -06:00

51 lines
1.2 KiB
C++

#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);
}
}