Jump to content
  • 0

How do I make a NPC check if an item is in players inv.


Question

8 answers to this question

Recommended Posts

Posted

use the countitem() command

usage :

countitem( itemID )

Example :

if( countitem(512 ) < 10 ){
  mes "You have less than 10 Apple in your Inventory.";
}
close;

  • Upvote 2
Posted (edited)

alright so if i am not mistaken this should work

if( countitem(512 ) < 10 ){
  mes "You have less than 10 Apple in your Inventory.";
}
close;
else( countitem(512) => 10){
 mes "You have the right items.";
 next;
 switch(select("Use:Drop:Nothing")){
 (fucntions would be here)
}
close;

Edited by mnjfx
Posted

like this

if( countitem( 512 ) < 10 ){
  mes "You didnt have 10 Apple";
}else{
  mes "You have the items.";
  switch( select("Use:Drop:Nothing") ){
 Case 1:
 Case 2:
 Case 3:
   etc....
 }
}

  • Upvote 2
Posted (edited)

yup that was what i was thinking. just a little lazy to type since im eating. I also could use it like thi right?

if( countitem( 512 ) > 9 ){
  mes "You have the items.";
  switch( select("Use:Drop:Nothing") ){
 Case 1:
 Case 2:
 Case 3:
etc....
if( countitem(512) > 9){
  mes "You have something.";
switch( select("Die:Fly:Soar")){
 case 1:
 case 2:
 case 3:
}else{
  mes "You Have Nothing";
 }
}

Edited by mnjfx
Posted
prontera,155,181,5 script Sample 757,{
if( countitem( 512 ) > 9 ){
mes "You have the items.";
switch( select("Use:Drop:Nothing") ){
 Case 1:
 Case 2:
 Case 3:
}
}else if( countitem(512) < 9){
mes "You have something.";
switch( select("Die:Fly:Soar")){
 case 1:
 case 2:
 case 3:
}
}else{
  mes "You Have Nothing";
 }
close;
}

  • Upvote 1
Posted

so if I want to put more than 2? will it be like If.. else if.. else if.. else if.. etc.. then else? right?

Yes, if the dialogue for each item is going to be different but if you want different items for the same dialogue this would suffice

if( countitem( 512 ) > 9 || countitem( 512 ) > 9 || countitem( 512 ) > 9){

Just change the ID and the amount.

  • Upvote 1

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...