Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Paint Data Updater

Featured Replies

Hello OSBot.

Recently, I've been working with paints and noticed that with paints that require large calculations and things of that nature, the paint actually lags the bot.

The solution is to use a thread which updates the data periodically.

For instance, say you want to display range xp:

One might calculate how much range xp is gained per paint update. BAD.

public void onPaint(Graphics g) {
   drawString("Range XP Gained: " + this.client.getSkills().getExperience(Skill.RANGED) - this.INITIAL_RANGE_XP,0,0);
}
You can see that it calculates this EVERY time paint is called. I believe it is based on the current FPS.

The correct way to do it is using a thread.

Here is your onLoop() -

 

public void onLoop() {
   if (this.start == false) {
      this.paintUpdater = new PaintUpdater(this.client, this);
      this.paintThread = new Thread(this.paintUpdater);
      this.paintThread.start();
      this.start = true;
   }
   return 1000;
}
Here is your thread class -

 

public class PaintUpdater implements Runnable {
   public Client client;
   public Script script;
   public int INITIAL_RANGE_XP;
   public int range_xp_gained;
   public boolean run = true;
   public PaintUpdater(Client c, Script s) {
      this.client = c;
      this.script = s;
      this.INITIAL_RANGE_XP = c.getSkills().getExperience(Skill.RANGED);
   }
   public void run() {
      while (this.run) {
         try {
            update();
            Thread.sleep(200);
         } catch (InterruptedException e) { }
      }
   }
   public void update() {
      this.range_xp_gained = this.client.getSkills().getExperience(Skill.RANGED) - this.INITIAL_RANGE_XP;
   }
   public int getRangeXPGained() {
      return this.range_xp_gained;
   }
   public void stop() {
      this.run = false;
   }
} 
and here is your paint -

 

public void onPaint(Graphics g) {
   drawString("Range XP Gained: " + this.paintUpdater.getRangeXPGained(),0,0);
}
The rest is up to you to make it work how you please!

Edited by dreamliner

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.