Little help with an if function.

RiverStyx

New member
Messages
9
Points
0
So, essentially I want to check some things out, can I use the same label for 2 callsubs with a different number of getargs?

case 1: callsub Create2,7136,7129,713,929,7137;case 2: callsub Create2,7139,7137,713,950,970,1044;
.....

later on.....

......

if ((countitem(getarg(1)) >= @input) && (countitem(getarg(2)) >= @input) && (countitem(getarg(3)) >= @input) && (countitem(getarg(4)) >= @input) && (countitem(getarg(5)) >= @input) && (countitem(getarg(6)) >= @input) && (countitem(getarg(7)) < @input)) {
 
So if only 5 getargs are set with a variable, is there a way to use the if function to check? or is it just going to be a bunch of } else { within an if function?(not sure if it's even doable.. lol)

thanks in advance!

 
Last edited by a moderator:
getargcount()
Above function returns the number of arguments passed to a function via callfunc, or to callsub.

if you want to pass all getarg() through same condition, you can use for loop in the Create2 Label:

Code:
for (.@i=0; .@i<getargcount(); .@i++){    if (countitem(getarg(.@i))<@input){@error = 1;}}if (@error==1){ mes "You do not have enough items"; close;}//Do anything here 
 
Okay, thanks a ton with that, and as an additional question, is there a way to make it let you know what arguments failed the check? (let the player know)

 
Okay, thanks a ton with that, and as an additional question, is there a way to make it let you know what arguments failed the check? (let the player know)
for (.@i=0; .@i<getargcount(); .@i++){ if (countitem(getarg(.@i))<@input){@error = 1;} mes "You Need ["+countitem(getarg(.@i))+"/"+@input+"] "+getitemname(getarg(.@i));}if (@error==1){ mes "You do not have enough items"; close;}//Do anything here
This way, it would show "You Need [x/y] ItemName" for every item required.

 
Back
Top