mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 11:31:30 +00:00
[Commands] Cleanup #qglobal Command. (#2115)
- Cleanup messages and logic.
This commit is contained in:
parent
1e45ffa24d
commit
78d44440eb
@ -281,7 +281,7 @@ int command_init(void)
|
||||
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 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("qglobal", "[On|Off|View] - Toggles quest global functionality for your NPC target", 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) ||
|
||||
command_add("raidloot", "[All|GroupLeader|RaidLeader|Selected] - Sets your Raid Loot Type if you have permission to do so.", AccountStatus::Player, command_raidloot) ||
|
||||
|
||||
@ -2,61 +2,128 @@
|
||||
|
||||
void command_qglobal(Client *c, const Seperator *sep)
|
||||
{
|
||||
//In-game switch for qglobal column
|
||||
if (sep->arg[1][0] == 0) {
|
||||
c->Message(Chat::White, "Syntax: #qglobal [on/off/view]. Requires NPC target.");
|
||||
int arguments = sep->argnum;
|
||||
if (!arguments) {
|
||||
c->Message(Chat::White, "Usage: #qglobal on - Enables target NPC's ability to view quest globals");
|
||||
c->Message(Chat::White, "Usage: #qglobal off - Disables target NPC's ability to view quest globals");
|
||||
c->Message(Chat::White, "Usage: #qglobal view - View target NPC's ability to view quest globals");
|
||||
return;
|
||||
}
|
||||
|
||||
Mob *target = c->GetTarget();
|
||||
|
||||
if (!target || !target->IsNPC()) {
|
||||
c->Message(Chat::Red, "NPC Target Required!");
|
||||
if (!c->GetTarget() || !c->GetTarget()->IsNPC()) {
|
||||
c->Message(Chat::White, "You must target an NPC to use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "on")) {
|
||||
std::string query = StringFormat(
|
||||
"UPDATE npc_types SET qglobal = 1 WHERE id = '%i'",
|
||||
target->GetNPCTypeID());
|
||||
auto results = content_db.QueryDatabase(query);
|
||||
auto target = c->GetTarget()->CastToNPC();
|
||||
|
||||
bool is_off = !strcasecmp(sep->arg[1], "off");
|
||||
bool is_on = !strcasecmp(sep->arg[1], "on");
|
||||
bool is_view = !strcasecmp(sep->arg[1], "view");
|
||||
if (
|
||||
!is_off &&
|
||||
!is_on &&
|
||||
!is_view
|
||||
) {
|
||||
c->Message(Chat::White, "Usage: #qglobal on - Enables target NPC's ability to view quest globals");
|
||||
c->Message(Chat::White, "Usage: #qglobal off - Disables target NPC's ability to view quest globals");
|
||||
c->Message(Chat::White, "Usage: #qglobal view - View target NPC's ability to view quest globals");
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_off) {
|
||||
auto query = fmt::format(
|
||||
"UPDATE npc_types SET qglobal = 0 WHERE id = {}",
|
||||
target->GetNPCTypeID()
|
||||
);
|
||||
auto results = content_db.QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
c->Message(Chat::Yellow, "Could not update database.");
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Failed to disable quest global flag for {} ({}).",
|
||||
target->GetCleanName(),
|
||||
target->GetID()
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(Chat::Yellow, "Success! Changes take effect on zone reboot.");
|
||||
return;
|
||||
}
|
||||
auto repop_link = EQ::SayLinkEngine::GenerateQuestSaylink(
|
||||
"#repop",
|
||||
false,
|
||||
"repop"
|
||||
);
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} ({}) will no longer be able to view quest globals, {} them to apply this change.",
|
||||
target->GetCleanName(),
|
||||
target->GetID(),
|
||||
repop_link
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
} else if (is_on) {
|
||||
auto query = fmt::format(
|
||||
"UPDATE npc_types SET qglobal = 1 WHERE id = {}",
|
||||
target->GetNPCTypeID()
|
||||
);
|
||||
auto results = content_db.QueryDatabase(query);
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "off")) {
|
||||
std::string query = StringFormat(
|
||||
"UPDATE npc_types SET qglobal = 0 WHERE id = '%i'",
|
||||
target->GetNPCTypeID());
|
||||
auto results = content_db.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
c->Message(Chat::Yellow, "Could not update database.");
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Failed to enable quest global flag for {} ({}).",
|
||||
target->GetCleanName(),
|
||||
target->GetID()
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(Chat::Yellow, "Success! Changes take effect on zone reboot.");
|
||||
return;
|
||||
}
|
||||
auto repop_link = EQ::SayLinkEngine::GenerateQuestSaylink(
|
||||
"#repop",
|
||||
false,
|
||||
"repop"
|
||||
);
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "view")) {
|
||||
const NPCType *type = content_db.LoadNPCTypesData(target->GetNPCTypeID());
|
||||
if (!type) {
|
||||
c->Message(Chat::Yellow, "Invalid NPC type.");
|
||||
}
|
||||
else if (type->qglobal) {
|
||||
c->Message(Chat::Yellow, "This NPC has quest globals active.");
|
||||
}
|
||||
else {
|
||||
c->Message(Chat::Yellow, "This NPC has quest globals disabled.");
|
||||
}
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} ({}) will now be able to view quest globals, {} them to apply this change.",
|
||||
target->GetCleanName(),
|
||||
target->GetID(),
|
||||
repop_link
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
} else if (!strcasecmp(sep->arg[1], "view")) {
|
||||
const NPCType *npc_type = content_db.LoadNPCTypesData(target->GetNPCTypeID());
|
||||
if (!npc_type) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"NPC ID {} was not found.",
|
||||
target->GetNPCTypeID()
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(Chat::Yellow, "Invalid action specified.");
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} ({}) {} view quest globals.",
|
||||
target->GetCleanName(),
|
||||
target->GetID(),
|
||||
npc_type->qglobal ? "can" : "cannot"
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user