Jump to content
  • 0

Variables/Array Elements


integral

Question


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  167
  • Reputation:   4
  • Joined:  02/01/12
  • Last Seen:  

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.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  167
  • Reputation:   4
  • Joined:  02/01/12
  • Last Seen:  

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.

Link to comment
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.   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.

×
×
  • Create New...