[Commands] Cleanup #kill Command. (#2195)

- Cleanup messages and logic.
This commit is contained in:
Kinglykrab 2022-05-22 22:31:08 -04:00 committed by GitHub
parent 5b90d26a33
commit e43538cf73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,11 +2,27 @@
void command_kill(Client *c, const Seperator *sep)
{
if (!c->GetTarget()) {
c->Message(Chat::White, "Error: #Kill: No target.");
auto target = c->GetTarget();
if (!target) {
c->Message(Chat::White, "You must have a target to use this command.");
return;
}
else if (!c->GetTarget()->IsClient() || c->GetTarget()->CastToClient()->Admin() <= c->Admin()) {
c->GetTarget()->Kill();
if (
!target->IsClient() ||
target->CastToClient()->Admin() <= c->Admin()
) {
if (c != target) {
c->Message(
Chat::White,
fmt::format(
"Killing {}.",
c->GetTargetDescription(target)
).c_str()
);
}
target->Kill();
}
}