whipz Posted February 23, 2017 Share Posted February 23, 2017 Hey guys; I need to be able to hop to worlds basically everytime; for some reason the Hopper supplied by OSbot is a tad buggy and sometimes doesnt actually go hop worlds or hops to a world it cant EG 500 lvl or members if f2p account is used; I have tried to come up with something that could possibly help me; but Im not sure how to prevent it from trying to log into the world it currently is if the random lands on that world; int rand = random(10); if (rand == 1) { hopper.hop(1, () -> false); } if (rand == 2) { hopper.hop(8, () -> false); } if (rand == 3) { hopper.hop(16, () -> false); } if (rand == 4) { hopper.hop(26, () -> false); } if (rand == 5) { hopper.hop(35, () -> false); } if (rand == 6) { hopper.hop(82, () -> false); } if (rand == 7) { hopper.hop(83, () -> false); } if (rand == 8) { hopper.hop(84, () -> false); } if (rand == 9) { hopper.hop(93, () -> false); } if (rand == 10) { hopper.hop(94, () -> false); } any feedback would be sweet (: or if someone else has a snippet that could be useful here please post (: Quote Link to comment Share on other sites More sharing options...
Sphiinx Posted February 23, 2017 Share Posted February 23, 2017 (edited) Check if the player is already in that world, if true, don't log into that world. If this doesn't make sense to you, let me know. Edited February 23, 2017 by Sphiinx 1 Quote Link to comment Share on other sites More sharing options...
whipz Posted February 23, 2017 Author Share Posted February 23, 2017 25 minutes ago, Sphiinx said: Check if the player is already in that world, if true, don't log into that world. If this doesn't make sense to you, let me know. it does but will I need to add to every line ? or can I do it to before the first random ? Quote Link to comment Share on other sites More sharing options...
Adept Posted February 23, 2017 Share Posted February 23, 2017 (edited) So far I've haven't experienced any issues with the hopper. Are you sure you're making use of the correct methods? Also, consider using a switch instead of multiple if statements. You should use something of this sort: int hopTo = -1; int rand = random(1,10); switch (rand) { case 1: hopTo = 1; break; case 2: hopTo = 8; break; //add remaining cases } if (hopTo != -1 && hopTo != getWorlds().getCurrentWorld){ getWorlds().hop(hopTo); } Here's an even better solution with an array instead of a switch int hopTo = -1; int[] worlds = {1,8,16}; //add your worlds here int rand = random(0, worlds.length - 1); //arrays start from index 0 hopTo = worlds[rand]; if (hopTo != -1 && hopTo != getWorlds().getCurrentWorld){ getWorlds().hop(hopTo); } Edited February 23, 2017 by Adept 2 Quote Link to comment Share on other sites More sharing options...
Zappster Posted February 23, 2017 Share Posted February 23, 2017 @FrostBug did something with this a couple of years ago. Please see: Quote Link to comment Share on other sites More sharing options...
whipz Posted February 23, 2017 Author Share Posted February 23, 2017 18 minutes ago, Adept said: So far I've haven't experienced any issues with the hopper. Are you sure you're making use of the correct methods? Also, consider using a switch instead of multiple if statements. You should use something of this sort: int hopTo = -1; int rand = random(1,10); switch (rand) { case 1: hopTo = 1; break; case 2: hopTo = 8; break; //add remaining cases } if (hopTo != -1 && hopTo != getWorlds().getCurrentWorld){ getWorlds().hop(hopTo); } Here's an even better solution with an array instead of a switch int hopTo = -1; int[] worlds = {1,8,16}; //add the other worlds (make sure sure you have as much elements as the maximum value of the random) int rand = random(0,9); //arrays start from index 0 hopTo = worlds[rand]; if (hopTo != -1 && hopTo != getWorlds().getCurrentWorld){ getWorlds().hop(hopTo); } Thanks mate Ill give it a try ! 9 minutes ago, Zappster said: @FrostBug did something with this a couple of years ago. Please see: That could be the one I was looking for I saw houses which was a remake of this one I think Quote Link to comment Share on other sites More sharing options...
whipz Posted February 23, 2017 Author Share Posted February 23, 2017 1 hour ago, Adept said: So far I've haven't experienced any issues with the hopper. Are you sure you're making use of the correct methods? Also, consider using a switch instead of multiple if statements. You should use something of this sort: int hopTo = -1; int rand = random(1,10); switch (rand) { case 1: hopTo = 1; break; case 2: hopTo = 8; break; //add remaining cases } if (hopTo != -1 && hopTo != getWorlds().getCurrentWorld){ getWorlds().hop(hopTo); } Here's an even better solution with an array instead of a switch int hopTo = -1; int[] worlds = {1,8,16}; //add the other worlds (make sure sure you have as much elements as the maximum value of the random) int rand = random(0,9); //arrays start from index 0 hopTo = worlds[rand]; if (hopTo != -1 && hopTo != getWorlds().getCurrentWorld){ getWorlds().hop(hopTo); } The case switches worked better; the bottom one seems to skip world hoping (: thanks so much mate; it doesnt go to wrong worlds now; and if it gets stuck I can set it to continue (: Quote Link to comment Share on other sites More sharing options...
Adept Posted February 23, 2017 Share Posted February 23, 2017 (edited) 6 minutes ago, whipz said: The case switches worked better; the bottom one seems to skip world hoping (: thanks so much mate; it doesnt go to wrong worlds now; and if it gets stuck I can set it to continue (: I'd recommend using the bottom one. I edited the code so that all you have to do is add world to the "worlds" array. Copy the code again from the original reply and try again. Edited February 23, 2017 by Adept 1 Quote Link to comment Share on other sites More sharing options...
whipz Posted February 23, 2017 Author Share Posted February 23, 2017 Just now, Adept said: I'd recommend using the bottom one. Did you add the worlds in the worlds array? It's probably why it's not working. i did ): still didnt work just skipped it all together it said it was going to but didnt I had 10 worlds in total so 0 - 9 is 10 im sure? Quote Link to comment Share on other sites More sharing options...