integral Posted March 17, 2013 Group: Members Topic Count: 51 Topics Per Day: 0.01 Content Count: 167 Reputation: 4 Joined: 02/01/12 Last Seen: August 20, 2017 Share Posted March 17, 2013 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. Quote Link to comment Share on other sites More sharing options...
Emistry Posted March 17, 2013 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted March 17, 2013 like this ? for( .@i = 0; .@i < getarraysize( .mvp ); .@i++ ) if( .monster == .mvp[.@i] ){ mes "It's MVP.."; close; } mes "It's not MVP."; close; 1 Quote Link to comment Share on other sites More sharing options...
integral Posted March 17, 2013 Group: Members Topic Count: 51 Topics Per Day: 0.01 Content Count: 167 Reputation: 4 Joined: 02/01/12 Last Seen: August 20, 2017 Author Share Posted March 17, 2013 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. Quote Link to comment Share on other sites More sharing options...
Question
integral
How do I check if a value that is randomized is equal to an element in an array?
For example, monster and mvp IDs.
Then I will randomize a number.
Then let's say,
Then there will be a comparison.
Thanks a lot.
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.