Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 09-20-2015, 06:26 PM
Trackye
Sarnak
 
Join Date: Feb 2008
Posts: 87
Default NEW Gm command to find model Id's

I was trying to add weapons to my NPC's and was unable to use #npcedit Weapon (ID) command without searching in my database for the modelid...


So i created this GM command that returns the Model ID when you search for an item by itemid. For example.

I type #finditemmodel 14383 and it returns
Innoruuk's Curse - IT145.

Very simple.
The searching by item NAME and working as well but MUCH more reliable to search by item id.

I realize this is not a MAJOR improvement or feature but it made my life MUCH MUCH easier.

I did not provide a Diff because nothing is being removed. Just added.

Command.h
Line 157 I added
Code:
void command_finditemmodel(Client *c, const Seperator *sep);
and Command.cpp
Line 446 I added
Code:
command_add("finditemmodel",  "- #finditemmodel searches for model of an item based on provided item ID",  0, command_finditemmodel) ||
Line 2841 I added
Code:
void command_finditemmodel(Client *c, const Seperator *sep)
{
	if(sep->arg[1][0] == 0) {
		c->Message(0, "Usage: #finditemmodel [search criteria]");
		return;
    }

	std::string query;

	int id = atoi((const char *)sep->arg[1]);
	if (id == 0) // If id evaluates to 0, then search as if user entered a string.
		query = StringFormat("SELECT name, idfile FROM items WHERE name LIKE '%%%s%%'",  sep->arg[1]);
	else // Otherwise, look for just that item id.
		query = StringFormat("SELECT name, idfile FROM items WHERE id = %i",  id);

    auto results = database.QueryDatabase(query);
    if (!results.Success()) {
        c->Message (0, "Error querying database.");
		c->Message (0, query.c_str());
    }

    if (results.RowCount() == 0) // No matches found.
        c->Message (0, "No matches found for %s.",  sep->arg[1]);

    // If query runs successfully.
	int count = 0;
    const int maxrows = 20;

    // Process each row returned.
	for (auto row = results.begin(); row != results.end(); ++row) {
		// Limit to returning maxrows rows.
        if (++count > maxrows) {
            c->Message (0, "%i modelid's shown. Too many results.",  maxrows);
            break;
        }

        c->Message (0, "  %s: %s",  row[0], row[1]);
    }

    // If we did not hit the maxrows limit.
    if (count <= maxrows)
        c->Message (0, "Query complete. %i rows shown.",  count);

}
Thanks!
Reply With Quote
  #2  
Old 09-20-2015, 07:21 PM
AdrianD
Discordant
 
Join Date: Dec 2013
Posts: 297
Default

/cheer

/10char
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 10:31 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3