Jump to content
  • 0
Sign in to follow this  
MrSky

How to check all items?

Question

Hey guys, how can i check if player have only one item in inventory? I.e he can do something only if he have only Apple in his inventory.

Or restrict all itens expect one?

Edited by MrSky

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I don't know if this is what you mean, but you can find similar commands by reading the fine manual for this (which is doc/script_commands.txt):

 

*countitem(<item id>)*countitem("<item name>")This function will return the number of items for the specified item IDthat the invoking character has in the inventory.mes "[Item Checker]";mes "Hmmm, it seems you have "+countitem(502)+" apples";close;Like 'getitem', this function will also accept an 'english name' from thedatabase as an argument.If you want to state the number at the end of a sentence, you can do it byadding up strings:mes "[Item Checker]";mes "Hmmm, the total number of apples you are holding is "+countitem("APPLE");close;

 

Edit: Dang, if you're allowed to have apples only you should check this other function:

*getinventorylist;This command sets a bunch of arrays with a complete list of whatever the invoking character has in its inventory, including all the data needed to recreate these items perfectly if they are destroyed. Here's what you get:@inventorylist_id[]        - array of item ids.@inventorylist_amount[]    - their corresponding item amounts.@inventorylist_equip[]     - whether the item is equipped or not.@inventorylist_refine[]    - for how much it is refined.@inventorylist_identify[]  - whether it is identified.@inventorylist_attribute[] - whether it is broken.@inventorylist_card1[]     - These four arrays contain card data for the@inventorylist_card2[]       items. These data slots are also used to store@inventorylist_card3[]       names inscribed on the items, so you can@inventorylist_card4[]       explicitly check if the character owns an item                             made by a specific craftsman.@inventorylist_expire[]    - expire time (Unix time stamp). 0 means never                              expires.@inventorylist_count       - the number of items in these lists.@inventorylist_bound       - whether it is an account bounded item or not.This could be handy to save/restore a character's inventory, since no other command returns such a complete set of data, and could also be theonly way to correctly handle an NPC trader for carded and named items who could resell them - since NPC objects cannot own items, so they have to store item data in variables and recreate the items.Notice that the variables this command generates are all temporary, attached to the character, and integer.Be sure to use @inventorylist_count to go through these arrays, and not 'getarraysize', because the arrays are not automatically cleared between runs of 'getinventorylist'.

 

Just check that @inventorylist_count is 1 and that @inventorylist_id[0] is the Apple item ID.

Share this post


Link to post
Share on other sites
  • 0

Like this?

prontera,154,180,4    script    Item Checker    123,{if( !countitem(501) ){    mes "You don't have a Red Potion.";} else {    mes "You have a Red Potion, I can tell.";}close;}

Share this post


Link to post
Share on other sites
  • 0

No, its he can have only Red Potions in inventory to do something... if he have something that is not Red Potion, he cant enter

Share this post


Link to post
Share on other sites
  • 0

I don't know if this is what you mean, but you can find similar commands by reading the fine manual for this (which is doc/script_commands.txt):

Edit: Dang, if you're allowed to have apples only you should check this other function:

Thats it man! thnks !! i dont know how i didnt see it haha

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
Answer this question...

×   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.