[Commands] Cleanup #hideme Command (#3043)

# Notes
- Cleanup messages and logic.
This commit is contained in:
Alex King
2023-03-05 22:35:30 -05:00
committed by GitHub
parent 457e800c73
commit 22d7ef6763
2 changed files with 25 additions and 10 deletions
+24 -9
View File
@@ -1,16 +1,31 @@
#include "../client.h"
#include "../string_ids.h"
void command_hideme(Client *c, const Seperator *sep)
{
bool state = atobool(sep->arg[1]);
const auto arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Usage: #hideme [On|Off]");
c->Message(Chat::White, "Usage: #hideme [0|1]");
return;
}
if (sep->arg[1][0] == 0) {
c->Message(Chat::White, "Usage: #hideme [on/off]");
}
else {
c->SetHideMe(state);
c->MessageString(Chat::Broadcasts, c->GetHideMe() ? NOW_INVISIBLE : NOW_VISIBLE, c->GetName());
auto t = c;
if (c->GetGM() && c->GetTarget() && c->GetTarget()->IsClient()) {
t = c->GetTarget()->CastToClient();
}
const auto is_hidden = Strings::ToBool(sep->arg[1]);
t->SetHideMe(is_hidden);
c->Message(
Chat::White,
fmt::format(
"{} {} now {} to players below a status level of {}.",
c->GetTargetDescription(t, TargetDescriptionType::UCYou),
c == t ? "are" : "is",
is_hidden ? "invisible" : "visible",
t->Admin()
).c_str()
);
}