Jump to content
Sign in to follow this  
GmOcean

*getcartinventory & *getinventorylist

Recommended Posts

Okay, so 2 suggestions.

First, I think we should modify *getinventorylist; to push the equip-slot the item is equipped on rather than just passing 1 (equipped) or 0 (not-equipped).

Reason:

1) It'll still be compatible with existing scripts that use a boolean check to see if the item is equipped or not.

2) Currently using existing commands, you'd have to do several more checks + a loop just to confirm that the item in question is equipped on ' X ' slot.

3) It's just more beneficial to do so.

Below is a working src code for the changes, but I'm sure someone could write it better D:

 

BUILDIN(getinventorylist){	TBL_PC *sd=script->rid2sd(st);	char card_var[NAME_LENGTH];	struct item_data *item;	int id;	int i,j=0,k,l;	if(!sd) return true;		for(i=0;i<MAX_INVENTORY;i++) {			if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].amount > 0) {				pc->setreg(sd,reference_uid(script->add_str("@inventorylist_id"), j),sd->status.inventory[i].nameid);				pc->setreg(sd,reference_uid(script->add_str("@inventorylist_amount"), j),sd->status.inventory[i].amount);				if(sd->status.inventory[i].equip) {					for (k = 0; k < ARRAYLENGTH(script->equip); k++) {						id = pc->checkequip(sd,script->equip[k]);						item = sd->inventory_data[id];						if( item != 0 ){							if(item->nameid == sd->status.inventory[i].nameid) {								pc->setreg(sd,reference_uid(script->add_str("@inventorylist_equip"), j),k+1);							}						}					}				} else {					pc->setreg(sd,reference_uid(script->add_str("@inventorylist_equip"), j),0);				}				pc->setreg(sd,reference_uid(script->add_str("@inventorylist_refine"), j),sd->status.inventory[i].refine);				pc->setreg(sd,reference_uid(script->add_str("@inventorylist_identify"), j),sd->status.inventory[i].identify);				pc->setreg(sd,reference_uid(script->add_str("@inventorylist_attribute"), j),sd->status.inventory[i].attribute);				for (l = 0; l < MAX_SLOTS; l++) {					sprintf(card_var, "@inventorylist_card%d",l+1);					pc->setreg(sd,reference_uid(script->add_str(card_var), j),sd->status.inventory[i].card[l]);				}				pc->setreg(sd,reference_uid(script->add_str("@inventorylist_expire"), j),sd->status.inventory[i].expire_time);				pc->setreg(sd,reference_uid(script->add_str("@inventorylist_bound"), j),sd->status.inventory[i].bound);				j++;			}		}	pc->setreg(sd,script->add_str("@inventorylist_count"),j);	return true;}

 

 

 

Second, I think it's about time we got a command for checking cart_inventory. I just don't see why we don't have one O.o; There's just no downside except having 1 extra command in script_commands.txt

Again, here's a write-up that's basically a copy+paste of *getinventorylist; (without the equip-slot modifications since equip will just return 0 anyways).

 

BUILDIN(getcartinventorylist){	TBL_PC *sd=script->rid2sd(st);	char card_var[NAME_LENGTH];	int i,j=0,k;	if(!sd) return true;		for(i=0;i<MAX_CART;i++) {			if(sd->status.cart[i].nameid > 0 && sd->status.cart[i].amount > 0) {				pc->setreg(sd,reference_uid(script->add_str(".@cartinventorylist_id"), j),sd->status.cart[i].nameid);				pc->setreg(sd,reference_uid(script->add_str(".@cartinventorylist_amount"), j),sd->status.cart[i].amount);				pc->setreg(sd,reference_uid(script->add_str(".@cartinventorylist_equip"), j),sd->status.cart[i].equip);				pc->setreg(sd,reference_uid(script->add_str(".@cartinventorylist_refine"), j),sd->status.cart[i].refine);				pc->setreg(sd,reference_uid(script->add_str(".@cartinventorylist_identify"), j),sd->status.cart[i].identify);				pc->setreg(sd,reference_uid(script->add_str(".@cartinventorylist_attribute"), j),sd->status.cart[i].attribute);				for (k = 0; k < MAX_SLOTS; k++) {					sprintf(card_var, ".@cartinventorylist_card%d",k+1);					pc->setreg(sd,reference_uid(script->add_str(card_var), j),sd->status.cart[i].card[k]);				}				pc->setreg(sd,reference_uid(script->add_str(".@cartinventorylist_expire"), j),sd->status.cart[i].expire_time);				pc->setreg(sd,reference_uid(script->add_str(".@cartinventorylist_bound"), j),sd->status.cart[i].bound);				j++;			}		}	pc->setreg(sd,script->add_str(".@cartinventorylist_count"),j);	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.