Jump to content
  • 0
HyperSonic2097

Item check in a npc help

Question

Hi all,

anyone know how I make this work?

 

    if (countitem (501) > 1) {
    mes "you have the requested item";
    delitem 501,1;
    getitem 502,1;
    close;
    } else {
    mes "you don't have anything";
    close;
    }

 

What I am doing wrong? This gave me "you don't have anything" even I have the correct item.

Thanks!

 

EDIT: nevermind, I have forgot an = in the code :D

 

correct code:

 

    if (countitem (501) >= 1) {
    mes "you have the requested item";
    delitem 501,1;
    getitem 502,1;
    close;
    } else {
    mes "you don't have anything";
    close;
    }

Edited by HyperSonic2097

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

remove the space between countitem and the opening parenthesis

countitem ()     =>    countitem()

Share this post


Link to post
Share on other sites
  • 0

Also, don't forget to check if the item can be carried by the player:

if (countitem(501) >= 1) {
	mes("you have the requested item");
	if (!checkweight(502, 1)) {
		mes("...but you can't carry it!");
	} else {
		delitem(501, 1);
		getitem(502, 1);
	}
} else {
	mes("you don't have anything");
}

close;

And instead of 501 / 502 you should use constants

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×
×
  • Create New...

Important Information

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