EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development: Custom Code (https://www.eqemulator.org/forums/forumdisplay.php?f=665)
-   -   Command: #setspawngroup (https://www.eqemulator.org/forums/showthread.php?t=36574)

Drajor 02-27-2013 12:19 PM

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]");
}



All times are GMT -4. The time now is 04:22 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.