Item check in a npc help

HyperSonic2097

New member
Messages
50
Points
0
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;
    }

 
Last edited by a moderator:
remove the space between countitem and the opening parenthesis

countitem ()     =>    countitem()

 
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

 
Back
Top