Jump to content
  • 0

Variables/Array Elements


Question

Posted

How do I check if a value that is randomized is equal to an element in an array?

 

For example, monster and mvp IDs.

 

setarray .mvp[0],1038,1039,1046;

 

Then I will randomize a number.

 

set .monster, 1000+rand(1,1308);

 

Then let's say,

.monster == 1038

Then there will be a comparison.

 
if (.monster == .mvp ) {
    mes "That is an MVP";
}
else { //If they are not equal, proceed
    mes "That is a normal monster";
}

 

Thanks a lot.

2 answers to this question

Recommended Posts

Posted

like this ?

for( .@i = 0; .@i < getarraysize( .mvp ); .@i++ )
	if( .monster == .mvp[.@i] ){
		mes "It's MVP..";
		close;
	}
mes "It's not MVP.";
close;
  • Upvote 1
Posted

like this ?

for( .@i = 0; .@i < getarraysize( .mvp ); .@i++ )
	if( .monster == .mvp[.@i] ){
		mes "It's MVP..";
		close;
	}
mes "It's not MVP.";
close;

 

 

I see, using the for loop in order to check each and every element.

Thank you.

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...