mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 00:46:46 +00:00
[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:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user