Jump to content

Best Way To Optimize Your Scripts!

Recommended Posts

Hello fellow scripters,


you know that "int onLoop()" method you guys like to use a lot? Well depending on how much logic you handle within this method call, you could be making your bot use more CPU. The best way to reduce this CPU usage is to raise the value given to it. In essence, you shouldn't be looping at less than 150 ms because it's a complete waste of CPU power and makes your script more detectable!


Do you really think your brain makes concious decesions about the game your playing at 20 times a second (assuming your using return values of 50 ms)? No... in fact heres some data:




They're median response time for humans on their study is 215 ms.


I'm not exactly sure to what extent some scripters do this, but the more instructions you run per second, the more power your CPU needs to allocate to the script.


Additionally, if your script for some reason needs to spam click or something, then make sure that your script doesn't execute many instructions when its looping at higher speeds. In essence, if you made it only do this...

public int onLoop() {
   return 50;

... than your not going to be using much CPU. But if you have an onLoop() method FILLED with hundreds of if-statements and conditionals everywhere, you're going to be using MUCH MUCH more!



So tl;dr; Use a sleep time like gRandom(215, 80). That method uses a mean of 215 with a standard deviation of 80ms.


Additionally, RuneScape's servers loop exactly every 600ms. What does this mean? It means that for every step you take in RS while walking, it takes roughly 600ms. If you're running, the steps get sent twice every 600ms. When you click on an object, it takes approximately 600ms for it to open. Etc. Etc.



Hopefully you guys learned something.

  • Like 3
Link to comment
Share on other sites

This topic is now closed to further replies.

  • Recently Browsing   0 members

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