Jump to content
  • 0
RiverStyx

Little help with an if function.

Question

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!

Edited by RiverStyx

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

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.

Share this post


Link to post
Share on other sites
  • 0
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:

 

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 

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.