To add $count(id,xxx), update the following in EQLib_MacroParser.cpp
Code: Select all
[color=red]
DWORD parmCount(PCHAR szVar, PCHAR szOutput, PSPAWNINFO pChar)
{
DWORD i=0;
PCONTENTS pContainer = 0;
PCHARINFO pCharInfo = NULL;
if (NULL == (pCharInfo = GetCharInfo())) return PMP_ERROR_BADPARM;
if (!strstr(szVar,")")) {
DebugSpew("PMP - Bad $count() '%s'",szVar);
return PMP_ERROR_BADPARM;
[/color]
// $count(id,xxx)
} else if (!strncmp("count(id,",szVar,9)) {
CHAR szArg[MAX_STRING] = {0};
CHAR szTemp[MAX_STRING] = {0};
DWORD a,b,c=0;
DWORD argSize=(strstr(szVar,")")-szVar);
i += argSize;
strncpy(szArg,szVar+9,argSize-9);
GetArg(szTemp,szArg,1);
for (a=0;a<8;a++) {
if (!pCharInfo->Inventory[22+a]) continue;
DebugSpew("Inventory->ItemNumber %d, looking for %s",(*pCharInfo->Inventory[22+a])->ItemNumber,szTemp);
if ((int)(*pCharInfo->Inventory[22+a])->ItemNumber==atoi(szTemp)) {
if (((*pCharInfo->Inventory[22+a])->Type != ITEMTYPE_NORMAL) || ((*pCharInfo->Inventory[22+a])->Common.Stackable!=1)) {
c++;
} else {
c+=((PCONTENTS)pCharInfo->Inventory[22+a])->StackCount;
}
}
// Parse through the containers
if ((*pCharInfo->Inventory[22+a])->Type == ITEMTYPE_PACK) {
pContainer = (PCONTENTS)(pCharInfo->Inventory[22+a]);
for (b=0;b<(*pCharInfo->Inventory[22+a])->Container.Slots;b++) {
if (!pContainer->Contents[b]) continue;
DebugSpew("Container[%d]->Contents[%d]->Item->ItemNumber %d, looking for %s",a,b,pContainer->Contents[b]->Item->ItemNumber,szTemp);
if ((int)pContainer->Contents[b]->Item->ItemNumber==atoi(szTemp)) {
if ((pContainer->Contents[b]->Item->Type != ITEMTYPE_NORMAL) || (pContainer->Contents[b]->Item->Common.Stackable!=1)) {
c++;
} else {
c+=pContainer->Contents[b]->StackCount;
}
}
}
}
}
itoa(c, szTemp, 10);
strcat(szOutput,szTemp);
[color=red]
// $count(itemname)
} else {
CHAR szArg[MAX_STRING] = {0};
CHAR szTemp[MAX_STRING] = {0};
DWORD a,b,c=0;
DWORD argSize=(strstr(szVar,")")-szVar);
i += argSize;
strncpy(szArg,szVar+6,argSize-6);
GetArg(szTemp,szArg,1,FALSE,FALSE,FALSE,')');
for (a=0;a<8;a++) {
if (!pCharInfo->Inventory[22+a]) continue;
if (!stricmp(szTemp,(*pCharInfo->Inventory[22+a])->Name)) {
if (((*pCharInfo->Inventory[22+a])->Type != ITEMTYPE_NORMAL) || ((*pCharInfo->Inventory[22+a])->Common.Stackable!=1)) {
c++;
} else {
c+=((PCONTENTS)pCharInfo->Inventory[22+a])->StackCount;
}
}
if ((*pCharInfo->Inventory[22+a])->Type == ITEMTYPE_PACK) {
pContainer = (PCONTENTS)(pCharInfo->Inventory[22+a]);
for (b=0;b<(*pCharInfo->Inventory[22+a])->Container.Slots;b++) {
if (!pContainer->Contents[b]) continue;
if (!stricmp(szTemp,pContainer->Contents[b]->Item->Name)) {
if ((pContainer->Contents[b]->Item->Type != ITEMTYPE_NORMAL) || (pContainer->Contents[b]->Item->Common.Stackable!=1)) {
c++;
} else {
c+=pContainer->Contents[b]->StackCount;
}
}
}
}
}
itoa(c, szTemp, 10);
strcat(szOutput,szTemp);
}
return i;
}
[/color]Code: Select all
[color=red]// ***************************************************************************
// Function: FindItem
// Description: Our '/finditem' command
// Brings the named item onto the cursor.
// Usage: /finditem itemname
// ***************************************************************************
VOID FindItem(PSPAWNINFO pChar, PCHAR szLine)
{
bRunNextCommand = TRUE;
UCHAR PriSlot;
CHAR szSearch[MAX_STRING] = {0};
CHAR szBuffer[MAX_STRING] = {0};
BOOL Exact= TRUE;[/color]
BOOL ByID=FALSE;
[color=red] gLastFind = LASTFIND_NOTFOUND;
PCHARINFO pCharInfo = NULL;
if (NULL == (pCharInfo = GetCharInfo())) return;
if (szLine[0] == 0) {
[/color] WriteChatBuffer("Usage: /finditem [similar|id] \"item name\"|\"item id\"",USERCOLOR_DEFAULT);
[color=red] strcpy(gLastError,"FIND_NOTFOUND");
return;
}
if (pCharInfo->Cursor) {
WriteChatBuffer("Your hands must be empty to find an item.",CONCOLOR_RED);
strcpy(gLastError,"FIND_HANDSFULL");
return;
}
GetArg(szSearch,szLine,1);
if (!stricmp(szSearch,"similar")) {
Exact=FALSE;
GetArg(szSearch,szLine,2);
}
[/color] if (!stricmp(szSearch,"id")) {
ByID=TRUE;
GetArg(szSearch,szLine,2);
}
[color=red] _strlwr(szSearch);
for (PriSlot=0;PriSlot<8;PriSlot++) {
PITEMINFO pSlot = pCharInfo->Inventory[22+PriSlot];
CHAR szTemp[MAX_STRING] = {0};
if (!pSlot) continue;
_strlwr(strcpy(szTemp,pSlot->Name));
if (
(
(!Exact) &&
(strstr(szTemp,szSearch))
) || (
(Exact) &&
(!strcmp(szTemp,szSearch))
[/color] ) || (
(ByID) &&
((int)pSlot->ItemNumber == atoi(szSearch))
[color=red] )
) {
CHAR szBuf[MAX_STRING] = {0};
gLastFind = LASTFIND_PRIMARY;
DebugSpew("FindItem - Found '%s' in primary inventory slot %d",pSlot->Name,PriSlot);
sprintf(szBuf,"left inv %d",PriSlot);
Click(pChar,szBuf);
gLastError[0]=0;
return;
}
if (pSlot->Type == ITEMTYPE_PACK) {
UCHAR BagSlot;
DebugSpew("FindItem - Looking inside pack %d: '%s'",PriSlot,pSlot->Name);
for (BagSlot=0;BagSlot < (DWORD)pSlot->Container.Slots;BagSlot++) {
PITEMINFO pItem = pSlot->Container.Contents[BagSlot];
if (!pItem) continue;
_strlwr(strcpy(szTemp,pItem->Name));
if (
(
(!Exact) &&
(strstr(szTemp,szSearch))
) || (
(Exact) &&
(!strcmp(szTemp,szSearch))
[/color] ) || (
(ByID) &&
((int)pItem->ItemNumber == atoi(szSearch))
[color=red] )
) {
CHAR szBuf[MAX_STRING] = {0};
BOOL WasOpen = FALSE;
DebugSpew("FindItem - Found '%s' in slot %d of '%s' (primary slot %d)",pItem->Name,BagSlot,pSlot->Name,PriSlot);
gLastFind = PriSlot;
if (pSlot->Container.Open == 0) {
sprintf(szBuf,"right inv %d",PriSlot);
Click(pChar,szBuf);
WasOpen = TRUE;
}
if (pSlot->Container.Open == 0) {
strcpy(gLastError,"FIND_PACKNOTOPEN");
return;
}
sprintf(szBuf,"left pack %d %d",PriSlot,BagSlot);
Click(pChar,szBuf);
if (WasOpen) {
sprintf(szBuf,"left pack %d done",PriSlot);
Click(pChar,szBuf);
}
gLastError[0]=0;
return;
}
}
}
}
sprintf(szBuffer,"Couldn't find a '%s'",szSearch);
strcpy(gLastError,"FIND_NOTFOUND");
WriteChatBuffer(szBuffer,CONCOLOR_RED);
}
[/color]
*Edited to use the updated PMP for $count(id,xxx)


donations for this month's patches.