Jump to content

World Hopping


lovelypker

Recommended Posts

Hello. I've tried to implement a systematic world hopping feature into my script that will follow a list of worlds. It starts off fine but then after a few hops it will just hop back and forth between two worlds, occasionally hopping to another world on the list. Sometimes it will hop, log in, and then log right back out and hop again. Here is my world hopping code:

 

Ohh and it tends to hop between 381 and 394 mainly.

public int[] worlds = {308, 316, 381, 382, 383, 384, 393, 394};
public int i;
for(i = 1; i < 8;) {
     worldHopper.hop(worlds[i]);
     i++;
     new ConditionalSleep(1000) {
           @Override
            public boolean condition() throws InterruptedException {
                 return myPlayer().isVisible();
            }
      }.sleep();
}
Edited by lovelypker
Link to comment
Share on other sites

Quickly rewrote this for you, let me know if something isn't clear smile.png (derived from your code, it's not how I would do it myself, but this should work ^^)

final int[] worlds = {308, 316, 381, 382, 383, 384, 393, 394};
public int i = 0;
worldHopper.hop(worlds[i]);

 new ConditionalSleep(5000) {
           @Override
            public boolean condition() throws InterruptedException {
                 return myPlayer().isVisible(); // instead of using isVisible you should probably use the client's login state.
            }
      }.sleep();

if (i >= worlds.length) {
i = 0;
}
else {
i++;
}
Edited by Botrepreneur
Link to comment
Share on other sites

this is because your using a for loop, which basically when is executed it starts from the beginning of the array and goes up. But that's bad. Becasue your telling it yo hop world back and fort. You could either have a list of worlds. Use the first index of the list. When you hop there you would remove the first index. you do it until the list is empty. When its empty, you could just readd them.

Link to comment
Share on other sites

 

Quickly rewrote this for you, let me know if something isn't clear smile.png (derived from your code, it's not how I would do it myself, but this should work ^^)

final int[] worlds = {308, 316, 381, 382, 383, 384, 393, 394};
public int i = 0;
worldHopper.hop(worlds[i]);

 new ConditionalSleep(5000) {
           @Override
            public boolean condition() throws InterruptedException {
                 return myPlayer().isVisible(); // instead of using isVisible you should probably use the client's login state.
            }
      }.sleep();

if (i >= worlds.length) {
i = 0;
}
else {
i++;
}

Thanks for your help!  I'll test this out and see how it goes.

 

this is because your using a for loop, which basically when is executed it starts from the beginning of the array and goes up. But that's bad. Becasue your telling it yo hop world back and fort. You could either have a list of worlds. Use the first index of the list. When you hop there you would remove the first index. you do it until the list is empty. When its empty, you could just readd them.

Ohh ok, that makes a lot of sense actually. I think your method sounds very logical, I'll try it out.

Link to comment
Share on other sites

Thanks for your help!  I'll test this out and see how it goes.

 

Ohh ok, that makes a lot of sense actually. I think your method sounds very logical, I'll try it out.

if you have an question, or confused on how to do it. Ask me i could help you out. With a pm or quote me so i get the notification.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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