Well, that was WAY easier than I thought it would be lol (took like 5 minutes to do). I am going to add this to the SVN right now
command.cpp - Replace the old itemsearch command with this (changes are in
RED):
Code:
void command_itemsearch(Client *c, const Seperator *sep)
{
if (sep->arg[1][0] == 0)
c->Message(0, "Usage: #itemsearch [search string]");
else
{
const char *search_criteria=sep->argplus[1];
const Item_Struct* item = 0;
if (Seperator::IsNumber(search_criteria)) {
item = database.GetItem(atoi(search_criteria));
if (item)
c->Message(0, " %i: %c%06X000000000000000000000000000000000000000%s%c",(int) item->ID,0x12, item->ID, item->Name, 0x12);
else
c->Message(0, "Item #%s not found", search_criteria);
return;
}
#ifdef SHAREMEM
int count=0;
//int iSearchLen = strlen(search_criteria)+1;
char sName[64];
char sCriteria[255];
strn0cpy(sCriteria, search_criteria, sizeof(sCriteria));
strupr(sCriteria);
char* pdest;
int32 it = 0;
while ((item = database.IterateItems(&it))) {
strn0cpy(sName, item->Name, sizeof(sName));
strupr(sName);
pdest = strstr(sName, sCriteria);
if (pdest != NULL) {
c->Message(0, " %i: %c%06X000000000000000000000000000000000000000%s%c",(int) item->ID,0x12, item->ID, item->Name, 0x12);
count++;
}
if (count == 50)
break;
}
if (count == 50)
c->Message(0, "50 items shown...too many results.");
else
c->Message(0, "%i items found", count);
#endif
}
}
I am going to add the #fi alias for finditem as well. This command is awesome! Thanks CD for the idea lol. I don't know why no one thought of this before now!
EDIT: The more I play with this command, the more I love it! It's just so freakin cool! This is now in Revision 237. Lemme know how you like it, or if there are any changes/fixes that are needed.