View Single Post
  #1  
Old 02-27-2013, 12:19 PM
Drajor's Avatar
Drajor
Developer
 
Join Date: Nov 2012
Location: Halas
Posts: 355
Default Command: #setspawngroup

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.

Code:
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]");
}
__________________
Drajor regards you indifferently -- what would you like your tombstone to say?

Last edited by Drajor; 02-27-2013 at 12:24 PM.. Reason: Error in parameter check
Reply With Quote