[Commands] Cleanup #permaclass Command. (#1777)

- Cleanup message and logic.
This commit is contained in:
Kinglykrab 2021-11-21 09:56:10 -05:00 committed by GitHub
parent 7559732408
commit 7c12c5d5ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 19 deletions

View File

@ -274,7 +274,7 @@ int command_init(void)
command_add("path", "- view and edit pathing", AccountStatus::GMMgmt, command_path) ||
command_add("peekinv", "[equip/gen/cursor/poss/limbo/curlim/trib/bank/shbank/allbank/trade/world/all] - Print out contents of your player target's inventory", AccountStatus::GMAdmin, command_peekinv) ||
command_add("peqzone", "[zonename] - Go to specified zone, if you have > 75% health", AccountStatus::Player, command_peqzone) ||
command_add("permaclass", "[classnum] - Change your or your player target's class (target is disconnected)", AccountStatus::QuestTroupe, command_permaclass) ||
command_add("permaclass", "[Class ID] - Change your or your player target's class, changed client is disconnected", AccountStatus::QuestTroupe, command_permaclass) ||
command_add("permagender", "[gendernum] - Change your or your player target's gender (zone to take effect)", AccountStatus::QuestTroupe, command_permagender) ||
command_add("permarace", "[racenum] - Change your or your player target's race (zone to take effect)", AccountStatus::QuestTroupe, command_permarace) ||
command_add("petitioninfo", "[petition number] - Get info about a petition", AccountStatus::ApprenticeGuide, command_petitioninfo) ||

View File

@ -2,27 +2,39 @@
void command_permaclass(Client *c, const Seperator *sep)
{
Client *t = c;
int arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #permaclass [Class ID]");
return;
}
Client *target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
t = c->GetTarget()->CastToClient();
target = c->GetTarget()->CastToClient();
}
if (sep->arg[1][0] == 0) {
c->Message(Chat::White, "Usage: #permaclass <classnum>");
}
else if (!t->IsClient()) {
c->Message(Chat::White, "Target is not a client.");
}
else {
c->Message(Chat::White, "Setting %s's class...Sending to char select.", t->GetName());
LogInfo("Class change request from [{}] for [{}], requested class:[{}]",
c->GetName(),
t->GetName(),
atoi(sep->arg[1]));
t->SetBaseClass(atoi(sep->arg[1]));
t->Save();
t->Kick("Class was changed.");
auto class_id = std::stoi(sep->arg[1]);
LogInfo("Class changed by {} for {} to {} ({})",
c->GetCleanName(),
target->GetCleanName(),
GetClassIDName(class_id),
class_id
);
target->SetBaseClass(class_id);
target->Save();
target->Kick("Class was changed.");
if (c != target) {
c->Message(
Chat::White,
fmt::format(
"Class changed for {} to {} ({}).",
target->GetCleanName(),
GetClassIDName(class_id),
class_id
).c_str()
);
}
}