Angelmelody 221 Posted June 18, 2014 (edited) *cartcountitem( <item id> or "<item name>" )*cartcountitem2(<item id> or "<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>) This cmd will return the number of items for the specified item ID that the invoking character has in the cart inventory download: cartcountitem.c Edited June 19, 2014 by Angelmelody 2 Napster and Legend reacted to this Quote Share this post Link to post Share on other sites
Jasc 1 Posted June 18, 2014 Great plugin, I always used query sql to do it before, nice to see a command now Quote Share this post Link to post Share on other sites
Angelmelody 221 Posted June 19, 2014 update, add cartcountitem2 Quote Share this post Link to post Share on other sites
Helena 0 Posted June 20, 2014 I happen to have a old hercules version were plugins arent supported yet. I have too many src mods to update, Is it just a matter of pasting the following in pc.h to make it work? BUILDIN(cartcountitem){ int nameid, i; int count = 0; struct item_data* id = NULL; TBL_PC* sd = script->rid2sd(st); if (!sd) { script_pushint(st,0); return false; } if( script_isstringtype(st, 2) ) //item name id = itemdb->search_name(script_getstr(st, 2)); else //item id id = itemdb->exists(script_getnum(st, 2)); if( id == NULL ) { ShowError("buildin_cartcountitem: Invalid item '%s'.n", script_getstr(st,2)); // returns string, regardless of what it was script_pushint(st,0); return false; } nameid = id->nameid; for(i = 0; i < MAX_CART; i++) if(sd->status.cart[i].nameid == nameid) count += sd->status.cart[i].amount; script_pushint(st,count); return true;} BUILDIN(cartcountitem2){ int nameid, iden, ref, attr, c0, c1, c2, c3; int count = 0; int i; struct item_data* id = NULL; TBL_PC* sd = script->rid2sd(st); if (!sd) { script_pushint(st,0); return false; } if( script_isstringtype(st, 2) ) //item name id = itemdb->search_name(script_getstr(st, 2)); else //item id id = itemdb->exists(script_getnum(st, 2)); if( id == NULL ) { ShowError("buildin_cartcountitem2: Invalid item '%s'.n", script_getstr(st,2)); // returns string, regardless of what it was script_pushint(st,0); return false; } nameid = id->nameid; iden = script_getnum(st,3); ref = script_getnum(st,4); attr = script_getnum(st,5); c0 = (short)script_getnum(st,6); c1 = (short)script_getnum(st,7); c2 = (short)script_getnum(st,8); c3 = (short)script_getnum(st,9); for(i = 0; i < MAX_CART; i++) { if(sd->status.cart[i].nameid > 0 && sd->status.cart[i].nameid == nameid && sd->status.cart[i].identify == iden && sd->status.cart[i].refine == ref && sd->status.cart[i].attribute == attr && sd->status.cart[i].card[0] == c0 && sd->status.cart[i].card[1] == c1 && sd->status.cart[i].card[2] == c2 && sd->status.cart[i].card[3] == c3 ) count += sd->status.cart[i].amount; } script_pushint(st,count); return true;} Quote Share this post Link to post Share on other sites