[Commands] Cleanup #setstartzone Command. (#1853)

- Add a message when setting start zone.
- Cleanup logic.
This commit is contained in:
Kinglykrab 2021-12-08 18:18:06 -05:00 committed by GitHub
parent 0f4f5d7046
commit 1a1c3abc24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 22 deletions

View File

@ -337,7 +337,7 @@ int command_init(void)
command_add("setpvppoints", "[Amount] - Set your or your player target's PVP points", AccountStatus::GMAdmin, command_setpvppoints) ||
command_add("setskill", "[skillnum] [value] - Set your target's skill skillnum to value", AccountStatus::Guide, command_setskill) ||
command_add("setskillall", "[value] - Set all of your target's skills to value", AccountStatus::Guide, command_setskillall) ||
command_add("setstartzone", "[zoneid] - Set target's starting zone. Set to zero to allow the player to use /setstartcity", AccountStatus::QuestTroupe, command_setstartzone) ||
command_add("setstartzone", "[Zone ID|Zone Short Name] - Sets your or your target's starting zone (Use '0' or 'Reset' to allow the player use of /setstartcity)", AccountStatus::QuestTroupe, command_setstartzone) ||
command_add("setstat", "- Sets the stats to a specific value.", AccountStatus::Max, command_setstat) ||
command_add("setxp", "[value] - Set your or your player target's experience", AccountStatus::GMAdmin, command_setxp) ||
command_add("showbonusstats", "[item|spell|all] Shows bonus stats for target from items or spells. Shows both by default.", AccountStatus::Guide, command_showbonusstats) ||

View File

@ -2,34 +2,59 @@
void command_setstartzone(Client *c, const Seperator *sep)
{
uint32 startzone = 0;
Client *target = nullptr;
if (c->GetTarget() && c->GetTarget()->IsClient() && sep->arg[1][0] != 0) {
target = c->GetTarget()->CastToClient();
}
else {
c->Message(Chat::White, "Usage: (needs PC target) #setstartzone zonename");
int arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Usage: #setstartzone [Zone ID|Zone Short Name]");
c->Message(
Chat::White,
"Optional Usage: Use '#setstartzone reset' or '#setstartzone 0' to clear a starting zone. Player can select a starting zone using /setstartcity"
"Optional Usage: Use '#setstartzone Reset' or '#setstartzone 0' to clear a starting zone. Player can select a starting zone using /setstartcity"
);
return;
}
if (sep->IsNumber(1)) {
startzone = atoi(sep->arg[1]);
}
else if (strcasecmp(sep->arg[1], "reset") == 0) {
startzone = 0;
}
else {
startzone = ZoneID(sep->arg[1]);
if (startzone == 0) {
c->Message(Chat::White, "Unable to locate zone '%s'", sep->arg[1]);
return;
}
auto target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
target = c->GetTarget()->CastToClient();
}
target->SetStartZone(startzone);
auto zone_id = (
sep->IsNumber(1) ?
std::stoul(sep->arg[1]) :
ZoneID(sep->arg[1])
);
target->SetStartZone(zone_id);
bool is_reset = (
!strcasecmp(sep->arg[1], "reset") ||
zone_id == 0
);
c->Message(
Chat::White,
fmt::format(
"Start Zone {} for {} |{}",
is_reset ? "Reset" : "Changed",
(
c == target ?
"Yourself" :
fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
)
),
(
zone_id ?
fmt::format(
" {} ({}) ID: {}",
ZoneLongName(zone_id),
ZoneName(zone_id),
zone_id
) :
""
)
).c_str()
);
}