Yusi Posted May 11, 2023 Share Posted May 11, 2023 Hello, i'm tryng to make a counter while webwalk but it never works. I guess no other process is running until the webwalk is finished. Can anyone tell me how can i make a counter while walking? Here's the code example: int count = 0; int counterRandom = random(1,15); @Override public int onLoop() throws InterruptedException { if (myPlayer().isMoving()) { count += 1; sleep(1000); log(count); } if (count == counterRandom) { log("Done"); counterRandom = random(1,15); count = 0; } return 0; } Quote Link to comment Share on other sites More sharing options...
Malcolm Posted May 11, 2023 Share Posted May 11, 2023 Just do it on a separate thread. The main thread will be executing the webwalkevent. 1 Quote Link to comment Share on other sites More sharing options...
Gunman Posted May 11, 2023 Share Posted May 11, 2023 Wtf why???? 1 1 Quote Link to comment Share on other sites More sharing options...
FushigiBot Posted May 11, 2023 Share Posted May 11, 2023 ASYNC 1 Quote Link to comment Share on other sites More sharing options...
Zackaery Posted May 11, 2023 Share Posted May 11, 2023 3 hours ago, Yusi said: Hello, i'm tryng to make a counter while webwalk but it never works. I guess no other process is running until the webwalk is finished. Can anyone tell me how can i make a counter while walking? Here's the code example: int count = 0; int counterRandom = random(1,15); @Override public int onLoop() throws InterruptedException { if (myPlayer().isMoving()) { count += 1; sleep(1000); log(count); } if (count == counterRandom) { log("Done"); counterRandom = random(1,15); count = 0; } return 0; } int count = 0; int counterRandom = random(1, 15); ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); @Override public int onLoop() throws InterruptedException { if (myPlayer().isMoving()) { count += 1; sleep(1000); log(count); } if (count == counterRandom) { log("Done"); counterRandom = random(1, 15); count = 0; } return 0; } // separate thread public void startCounter() { executor.scheduleAtFixedRate(new Runnable() { public void run() { if (!myPlayer().isMoving()) { count = 0; } } }, 0, 1, TimeUnit.SECONDS); } // stop counter public void stopCounter() { executor.shutdown(); } // call start counter method before starting webwalking startCounter(); // perform webwalk // call stop counter method after webwalking is finished stopCounter(); So basically, what you need to do is start a counter before you begin the webwalk. This counter will run in the background while you're moving. It will keep track of the count every second. If your player stops moving, the counter will reset back to zero. 1 Quote Link to comment Share on other sites More sharing options...
Yusi Posted May 11, 2023 Author Share Posted May 11, 2023 4 hours ago, Gunman said: Wtf why???? For random events while walking Quote Link to comment Share on other sites More sharing options...
FushigiBot Posted May 11, 2023 Share Posted May 11, 2023 You don't have to count for that. Just write a separate thread where you check for random events and sleep every 5 secs or so. Quote Link to comment Share on other sites More sharing options...
Yusi Posted May 11, 2023 Author Share Posted May 11, 2023 10 minutes ago, FushigiBot said: You don't have to count for that. Just write a separate thread where you check for random events and sleep every 5 secs or so. random events especially for walking like customized camera movements or missclicks Quote Link to comment Share on other sites More sharing options...
Yusi Posted May 11, 2023 Author Share Posted May 11, 2023 3 hours ago, Zackaery said: int count = 0; int counterRandom = random(1, 15); ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); @Override public int onLoop() throws InterruptedException { if (myPlayer().isMoving()) { count += 1; sleep(1000); log(count); } if (count == counterRandom) { log("Done"); counterRandom = random(1, 15); count = 0; } return 0; } // separate thread public void startCounter() { executor.scheduleAtFixedRate(new Runnable() { public void run() { if (!myPlayer().isMoving()) { count = 0; } } }, 0, 1, TimeUnit.SECONDS); } // stop counter public void stopCounter() { executor.shutdown(); } // call start counter method before starting webwalking startCounter(); // perform webwalk // call stop counter method after webwalking is finished stopCounter(); So basically, what you need to do is start a counter before you begin the webwalk. This counter will run in the background while you're moving. It will keep track of the count every second. If your player stops moving, the counter will reset back to zero. Thank you ill try it out Quote Link to comment Share on other sites More sharing options...
FushigiBot Posted May 11, 2023 Share Posted May 11, 2023 (edited) 3 hours ago, Yusi said: random events especially for walking like customized camera movements or missclicks ah, you mean randomized actions. You can do those in a timer and execute them regardless if it's walking or not. It doesm't do anything to reduce bans just so you know. Create various timers for the actions and couple the action with the timer reset. Run these on separate threads. Edited May 11, 2023 by FushigiBot 1 Quote Link to comment Share on other sites More sharing options...
ExtraBotz Posted May 11, 2023 Share Posted May 11, 2023 Declare a timestamp variable before you execute the web walk. This will record the current time when you start the web walk. Then in the web walking conditional event do a comparison between your timestamp and the current timestamp. ORIGINAL_TIMESTAMP - CURRENT_TIMESTAMP = TOTAL ELAPSED TIME IN MILLISECONDS. In the conditional event if the total elapsed time equals whatever value you want, then exit the web walking event and using the same logic you can create a statement (or method) to compare the timestamps again before executing the web walk. If the timestamps equal the amount of time you want elapsed, then execute your code. Otherwise continue walking. To improve the functionality you can use a class in its entirety to handle all of this. You could use a singleton design pattern for a class called "RANDOMIZER" and handle all of the code in this special class. 1 Quote Link to comment Share on other sites More sharing options...