Jump to content
Sign in to follow this  
Angelmelody

[script cmd] cartcountitem

Recommended Posts

*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 by Angelmelody

Share this post


Link to post
Share on other sites

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;}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.