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

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

×
×
  • Create New...

Important Information

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