[Commands] Cleanup #gm Command. (#1830)

- Cleanup message and logic.
- Cleanup SetGM() message.
This commit is contained in:
Kinglykrab 2021-11-26 10:01:13 -05:00 committed by GitHub
parent 514029a6bb
commit 2dc3ca52db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 19 deletions

View File

@ -2076,7 +2076,13 @@ bool Client::ChangeFirstName(const char* in_firstname, const char* gmname)
void Client::SetGM(bool toggle) {
m_pp.gm = toggle ? 1 : 0;
m_inv.SetGMInventory((bool)m_pp.gm);
Message(Chat::Red, "You are %s a GM.", m_pp.gm ? "now" : "no longer");
Message(
Chat::White,
fmt::format(
"You are {} flagged as a GM.",
m_pp.gm ? "now" : "no longer"
).c_str()
);
SendAppearancePacket(AT_GM, m_pp.gm);
Save();
UpdateWho();

View File

@ -195,7 +195,7 @@ int command_init(void)
command_add("giveitem", "[itemid] [charges] - Summon an item onto your target's cursor. Charges are optional.", AccountStatus::GMMgmt, command_giveitem) ||
command_add("givemoney", "[Platinum] [Gold] [Silver] [Copper] - Gives specified amount of money to you or your player target", AccountStatus::GMMgmt, command_givemoney) ||
command_add("globalview", "Lists all qglobals in cache if you were to do a quest with this target.", AccountStatus::QuestTroupe, command_globalview) ||
command_add("gm", "- Turn player target's or your GM flag on or off", AccountStatus::QuestTroupe, command_gm) ||
command_add("gm", "[On|Off] - Modify your or your target's GM Flag", AccountStatus::QuestTroupe, command_gm) ||
command_add("gmspeed", "[on/off] - Turn GM speed hack on/off for you or your player target", AccountStatus::GMAdmin, command_gmspeed) ||
command_add("gmzone", "[zone_short_name] [zone_version=0] [identifier=gmzone] - Zones to a private GM instance", AccountStatus::GMAdmin, command_gmzone) ||
command_add("goto", "[playername] or [x y z] [h] - Teleport to the provided coordinates or to your target", AccountStatus::Steward, command_goto) ||

View File

@ -2,26 +2,28 @@
void command_gm(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: #gm [On|Off]");
return;
}
bool gm_flag = 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->SetGM(state);
c->Message(Chat::White, "%s is %s a GM.", t->GetName(), state ? "now" : "no longer");
}
else {
c->Message(Chat::White, "Usage: #gm [on/off]");
target->SetGM(gm_flag);
if (c != target) {
c->Message(
Chat::White,
fmt::format(
"{} ({}) is {} flagged as a GM.",
target->GetCleanName(),
target->GetID(),
gm_flag ? "now" : "no longer"
).c_str()
);
}
}
// there's no need for this, as /summon already takes care of it
// this command is here for reference but it is not added to the
// list above
//To whoever wrote the above: And what about /kill, /zone, /zoneserver, etc?
//There is a reason for the # commands: so that admins can specifically enable certain
//commands for their users. Some might want users to #summon but not to /kill. Cant do that if they are a GM