Lilith Posted January 9, 2012 Group: Members Topic Count: 14 Topics Per Day: 0.00 Content Count: 407 Reputation: 159 Joined: 11/18/11 Last Seen: November 15, 2014 Share Posted January 9, 2012 (edited) Hi. How to make so that cases didn't repeat in function 'for() switch()'. Example: for(set .@a,0; .@a<3; set .@a,.@a+1) { switch(rand(1,3)) { case 1: (...); break; case 2: (...); break; case ... case N: (...); break; } } Please, help. Edited January 9, 2012 by Lilith Quote Link to comment Share on other sites More sharing options...
Emistry Posted January 9, 2012 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 January 9, 2012 what mean ? something like dont looping the switch case ??? like this ? for( ..... ){ code here.... } switch( ..... ){ case .. } end; Quote Link to comment Share on other sites More sharing options...
Gepard Posted January 9, 2012 Group: Members Topic Count: 22 Topics Per Day: 0.00 Content Count: 392 Reputation: 285 Joined: 12/19/11 Last Seen: January 23, 2022 Share Posted January 9, 2012 BTW switch(1,3) is not a valid syntax, so it's hard to understand what your code is supposed to do. Quote Link to comment Share on other sites More sharing options...
Lilith Posted January 9, 2012 Group: Members Topic Count: 14 Topics Per Day: 0.00 Content Count: 407 Reputation: 159 Joined: 11/18/11 Last Seen: November 15, 2014 Author Share Posted January 9, 2012 (edited) Gepard, sorry, i mean switch(rand(1,3)). Emistry, with looping, for(...) { switch(rand(1,N)){ case 1: setd ".Ex$",getd(".Ex$")+"First"; break; case 2: setd ".Ex$",getd(".Ex$")+"Second"; break; ... case N: setd ".Ex$",getd(".Ex$")+"N"; break; } } In the end .Ex$ should be approximately so: First, Fifth, Second - It is correct First, Fifth, First -It is not correct, Because repeats... Edited January 9, 2012 by Lilith Quote Link to comment Share on other sites More sharing options...
Emistry Posted January 9, 2012 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 January 9, 2012 KeyWorld has made a function that allow to generate a number without repeating.... Check this Post... http://rathena.org/board/topic/54288-random-number-with-return/page__view__findpost__p__59952 use that function to help you generate a number randomly without repeating ~ 1 Quote Link to comment Share on other sites More sharing options...
Lilith Posted January 9, 2012 Group: Members Topic Count: 14 Topics Per Day: 0.00 Content Count: 407 Reputation: 159 Joined: 11/18/11 Last Seen: November 15, 2014 Author Share Posted January 9, 2012 Thanks ! Quote Link to comment Share on other sites More sharing options...
Question
Lilith
Hi.
How to make so that cases didn't repeat in function 'for() switch()'.
Example:
Please, help.
Edited by LilithLink to comment
Share on other sites
5 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.