PDA

View Full Version : Command: #setspawngroup


Drajor
02-27-2013, 12:19 PM
My apologies if this already exists. I searched the source and the forums but found nothing related.
Due to the way I populate zones I needed to be able to target an NPC and set the spawn group. The following command can be added to achieve this.

void command_setspawngroup(Client* pClient, const Seperator* pSep) {
if ( !pClient ) return;
// Test: Valid Target (NPC)
if ( !pClient->GetTarget() || !pClient->GetTarget()->IsNPC() ) {
pClient->Message(13, "You must target an NPC to use this command.");
return;
}
// Test: Valid Command Parameter
if ( pSep->arg[1][0] ) {
const NPC* npc = pClient->GetTarget()->CastToNPC();
const uint32 sp2ID = npc->GetSpawnPointID();
const uint32 newSGID = atoi(pSep->arg[1]);

// DB Changes.
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
database.RunQuery(query, MakeAnyLenString(&query, "UPDATE spawn2 SET spawngroupID=%i WHERE id=%i", newSGID, sp2ID), errbuf);
safe_delete_array(query);

return;
}
pClient->Message(13, "Usage: #setspawngroup [spawngroupID]");
}