[Commands] Cleanup #pvp Command. (#1800)

- Cleanup messages and logic.
This commit is contained in:
Kinglykrab 2021-11-21 10:12:23 -05:00 committed by GitHub
parent b9214bfdee
commit 6a42639386
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 15 deletions

View File

@ -2613,10 +2613,11 @@ void Client::SetPVP(bool toggle, bool message) {
m_pp.pvp = toggle ? 1 : 0;
if (message) {
if(GetPVP())
this->MessageString(Chat::Shout,PVP_ON);
else
Message(Chat::Red, "You no longer follow the ways of discord.");
if(GetPVP()) {
MessageString(Chat::Shout, PVP_ON);
} else {
Message(Chat::Shout, "You now follow the ways of Order.");
}
}
SendAppearancePacket(AT_PVP, GetPVP());

View File

@ -283,7 +283,7 @@ int command_init(void)
command_add("profanity", "Manage censored language.", AccountStatus::GMLeadAdmin, command_profanity) ||
command_add("push", "Lets you do spell push", AccountStatus::GMLeadAdmin, command_push) ||
command_add("proximity", "Shows NPC proximity", AccountStatus::GMLeadAdmin, command_proximity) ||
command_add("pvp", "[on/off] - Set your or your player target's PVP status", AccountStatus::GMAdmin, command_pvp) ||
command_add("pvp", "[On|Off] - Set you or your player target's PVP status", AccountStatus::GMAdmin, command_pvp) ||
command_add("qglobal", "[on/off/view] - Toggles qglobal functionality on an NPC", AccountStatus::GMAdmin, command_qglobal) ||
command_add("questerrors", "Shows quest errors.", AccountStatus::GMAdmin, command_questerrors) ||
command_add("race", "[racenum] - Change your or your target's race. Use racenum 0 to return to normal", AccountStatus::Guide, command_race) ||

View File

@ -2,19 +2,27 @@
void command_pvp(Client *c, const Seperator *sep)
{
bool state = atobool(sep->arg[1]);
Client *t = c;
int arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Usage: #pvp [On|Off]");
return;
}
bool pvp_state = atobool(sep->arg[1]);
Client* target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
t = c->GetTarget()->CastToClient();
target = c->GetTarget()->CastToClient();
}
if (sep->arg[1][0] != 0) {
t->SetPVP(state);
c->Message(Chat::White, "%s now follows the ways of %s.", t->GetName(), state ? "discord" : "order");
}
else {
c->Message(Chat::White, "Usage: #pvp [on/off]");
target->SetPVP(pvp_state);
if (c != target) {
c->Message(
Chat::White,
fmt::format(
"{} now follows the ways of {}.",
target->GetCleanName(),
pvp_state ? "Discord" : "Order"
).c_str()
);
}
}