Jump to content
  • 0

For() Switch()...


Lilith

Question


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  407
  • Reputation:   159
  • Joined:  11/18/11
  • Last Seen:  

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

5 answers to this question

Recommended Posts


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

what mean ?

something like dont looping the switch case ???

like this ?

for( ..... ){
 code here....
}
switch( ..... ){
case ..
}
end;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.00
  • Content Count:  392
  • Reputation:   285
  • Joined:  12/19/11
  • Last Seen:  

BTW

switch(1,3)

is not a valid syntax, so it's hard to understand what your code is supposed to do.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  407
  • Reputation:   159
  • Joined:  11/18/11
  • Last Seen:  

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


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

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 ~

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  407
  • Reputation:   159
  • Joined:  11/18/11
  • Last Seen:  

Thanks !

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...