Jump to content

Randomly picking a case


Recommended Posts

Posted (edited)

Hey guys, super noob AGAIN.

 

So I'm currently in the process of developing my anti-ban for my scripts, and I want to do the following.

 

 

I want to generate a random number, then using that number, pick an antiban through cases.

 

FOR EXAMPLE:

 

My script CXMonkCurser has done a bunch of curses and it's time to antiban, so we call upon antiban;

 

then antiban generates the number 42.

 

So then it goes into the antiban and checks which antiban it should used based on the number generated "42".

 

Case1-100: do nothing

Case100-200: click a random tab

case300-400: spin camera

 

in this example it would go to case1-100 and do nothing.

 

 

How would I go about turning this idea into useable code?

Edited by creationx
Posted (edited)

How would I go about turning this idea into useable code?

if(number <=100){
   // Do nothing
}else if(number <= 200){
   // Click tab
}else if(number <= 300){
   // Spin camera
}else{
   // Even higher
}
Why not just get a random number from 0-2 ?

switch(number){
   case 1:
   // Click tab
   break;

   case 2:
   // Spin camera
   break;
}
Edited by Khaleesi
  • Like 1
Posted

Thank you, Daenerys Targaryen. It is my pleasure to serve under your wing.

 

Could also do something like this if you're using some sort of event-node state system.

private static final ImmutableList<Event> ANTIBAN = ImmutableList.of(new IdleEvent(), new AntibanEvent1(), new AntibanEvent2());

private static Event getRandomEvent() {
    return ANTIBAN.get((int) Math.random() * ANTIBAN.size());
}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...