Lilith Posted January 9, 2012 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
Emistry Posted January 9, 2012 Posted January 9, 2012 what mean ? something like dont looping the switch case ??? like this ? for( ..... ){ code here.... } switch( ..... ){ case .. } end; Quote
Gepard Posted January 9, 2012 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
Lilith Posted January 9, 2012 Author 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
Emistry Posted January 9, 2012 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
Question
Lilith
Hi.
How to make so that cases didn't repeat in function 'for() switch()'.
Example:
Please, help.
Edited by Lilith5 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.