Jump to content
  • 0

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


Virtue

Question


  • Group:  Members
  • Topic Count:  92
  • Topics Per Day:  0.02
  • Content Count:  354
  • Reputation:   22
  • Joined:  11/17/11
  • Last Seen:  

How do I make NPC to check something in players inventory.

example

if player has an apple in his inventory he can read the next dialog of the NPC.

thanks

Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  92
  • Topics Per Day:  0.02
  • Content Count:  354
  • Reputation:   22
  • Joined:  11/17/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  92
  • Topics Per Day:  0.02
  • Content Count:  354
  • Reputation:   22
  • Joined:  11/17/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  92
  • Topics Per Day:  0.02
  • Content Count:  354
  • Reputation:   22
  • Joined:  11/17/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  69
  • Topics Per Day:  0.02
  • Content Count:  1315
  • Reputation:   372
  • Joined:  12/10/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  92
  • Topics Per Day:  0.02
  • Content Count:  354
  • Reputation:   22
  • Joined:  11/17/11
  • Last Seen:  

alright thanks alot :(

Link to comment
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.   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.

×
×
  • Create New...