mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
command_qglobal converted to QueryDatabase
This commit is contained in:
parent
6be2f6a7e4
commit
a61b930bd9
@ -7309,56 +7309,58 @@ void command_nologs(Client *c, const Seperator *sep)
|
|||||||
|
|
||||||
void command_qglobal(Client *c, const Seperator *sep) {
|
void command_qglobal(Client *c, const Seperator *sep) {
|
||||||
//In-game switch for qglobal column
|
//In-game switch for qglobal column
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
if(sep->arg[1][0] == 0) {
|
if(sep->arg[1][0] == 0) {
|
||||||
c->Message(0, "Syntax: #qglobal [on/off/view]. Requires NPC target.");
|
c->Message(0, "Syntax: #qglobal [on/off/view]. Requires NPC target.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Mob *t = c->GetTarget();
|
|
||||||
if(!t || !t->IsNPC()) {
|
Mob *target = c->GetTarget();
|
||||||
|
|
||||||
|
if(!target || !target->IsNPC()) {
|
||||||
c->Message(13, "NPC Target Required!");
|
c->Message(13, "NPC Target Required!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!strcasecmp(sep->arg[1], "on"))
|
|
||||||
{
|
if(!strcasecmp(sep->arg[1], "on")) {
|
||||||
if(!database.RunQuery(query, MakeAnyLenString(&query, "UPDATE npc_types SET qglobal=1 WHERE id='%i'", t->GetNPCTypeID()), errbuf, 0))
|
std::string query = StringFormat("UPDATE npc_types SET qglobal = 1 WHERE id = '%i'",
|
||||||
{
|
target->GetNPCTypeID());
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
|
if(!results.Success()) {
|
||||||
c->Message(15, "Could not update database.");
|
c->Message(15, "Could not update database.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
c->LogSQL(query.c_str());
|
||||||
c->LogSQL(query);
|
c->Message(15, "Success! Changes take effect on zone reboot.");
|
||||||
c->Message(15, "Success! Changes take effect on zone reboot.");
|
return;
|
||||||
}
|
|
||||||
safe_delete(query);
|
|
||||||
}
|
}
|
||||||
else if(!strcasecmp(sep->arg[1], "off"))
|
|
||||||
{
|
if(!strcasecmp(sep->arg[1], "off")) {
|
||||||
if(!database.RunQuery(query, MakeAnyLenString(&query, "UPDATE npc_types SET qglobal=0 WHERE id='%i'", t->GetNPCTypeID()), errbuf, 0))
|
std::string query = StringFormat("UPDATE npc_types SET qglobal = 0 WHERE id = '%i'",
|
||||||
{
|
target->GetNPCTypeID());
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
|
if(!results.Success()) {
|
||||||
c->Message(15, "Could not update database.");
|
c->Message(15, "Could not update database.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
c->LogSQL(query.c_str());
|
||||||
c->LogSQL(query);
|
c->Message(15, "Success! Changes take effect on zone reboot.");
|
||||||
c->Message(15, "Success! Changes take effect on zone reboot.");
|
return;
|
||||||
}
|
|
||||||
safe_delete(query);
|
|
||||||
}
|
}
|
||||||
else if(!strcasecmp(sep->arg[1], "view"))
|
|
||||||
{
|
if(!strcasecmp(sep->arg[1], "view")) {
|
||||||
const NPCType *type = database.GetNPCType(t->GetNPCTypeID());
|
const NPCType *type = database.GetNPCType(target->GetNPCTypeID());
|
||||||
if(!type) {
|
if(!type)
|
||||||
c->Message(15, "Invalid NPC type.");
|
c->Message(15, "Invalid NPC type.");
|
||||||
} else if(type->qglobal) {
|
else if(type->qglobal)
|
||||||
c->Message(15, "This NPC has quest globals active.");
|
c->Message(15, "This NPC has quest globals active.");
|
||||||
} else {
|
else
|
||||||
c->Message(15, "This NPC has quest globals disabled.");
|
c->Message(15, "This NPC has quest globals disabled.");
|
||||||
}
|
return;
|
||||||
} else {
|
|
||||||
c->Message(15, "Invalid action specified.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c->Message(15, "Invalid action specified.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void command_path(Client *c, const Seperator *sep)
|
void command_path(Client *c, const Seperator *sep)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user