View Single Post
  #11  
Old 09-06-2014, 12:33 AM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

Assign Grid code is completely weird to me.. using X and Y to find an NPC when the NPC already has a Spawn2 ID ... (much easier to find an npc this way)


waypoint.cpp - replace the whole function with this...
Code:
void ZoneDatabase::AssignGrid(Client *client, int grid, int spawn2id) {
	std::string query = StringFormat("UPDATE spawn2 SET pathgrid = %d WHERE id = %d", grid, spawn2id);
	auto results = QueryDatabase(query);
	if (!results.Success())
	{
		LogFile->write(EQEMuLog::Error, "Error updating spawn2 '%s': '%s'", query.c_str(), results.ErrorMessage().c_str());
		return;
    }
    if (results.RowsAffected() != 1) {
        client->Message(0, "ERROR: found spawn2 id %d but the update query failed", spawn2id);
        return;
    }
    if(client)
        client->LogSQL(query.c_str());

    client->Message(0, "Grid assign: spawn2 id = %d updated", spawn2id);
}
zonedb.h - fix the header...

Code:
void	AssignGrid(Client *client, int grid, int spawn2id);

command.cpp -- replace the whole function..

Code:
void command_gassign(Client *c, const Seperator *sep) {
	if (sep->IsNumber(1) && c->GetTarget() && c->GetTarget()->IsNPC() && c->GetTarget()->CastToNPC()->GetSpawnPointID() > 0) {
		int spawn2id =  c->GetTarget()->CastToNPC()->GetSpawnPointID();
		database.AssignGrid(c, atoi(sep->arg[1]), spawn2id);
	}
	else
		c->Message(0,"Usage: #gassign [num] - must have an npc target!");
}
Reply With Quote