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.

need help finding a good way to make a if statement to a state more reliable.

Featured Replies

  • Author

Had no idea getInteracting was a method, that should fix this actually.

 

Nope, didn't fix it. Still having the issue where it will use the steel bar on the furnace every 10-20 seconds depending on when the sleep ends.

Will not work.

getInteracting() returns a Character.

 

Welp im an idiot lol could have sworn that said isInteracting, well like acted the same way.

Nope, didn't fix it. Still having the issue where it will use the steel bar on the furnace every 10-20 seconds depending on when the sleep ends.

if animation = -1, start a timer. If the timer exceeds 20 seconds, interact.
  • Author

More than likely you're doing this because the player stops animating in between smelting and the bot goes and attempts to smelt again? Just monitor your last smithing xp gain and if it was over a certain threshold then you know you have to smith.

 

this post did not show up for me for some reason! did not mean to ignore it. This is exactly what I meant, how would I go about doing that? I make an integer of my smithing experience and then what? kind of lost of what to do there.

this post did not show up for me for some reason! did not mean to ignore it. This is exactly what I meant, how would I go about doing that? I make an integer of my smithing experience and then what? kind of lost of what to do there.

I have moderated content on here cause I'm an asshole so my posts need to be approved by mods.

import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;

/**
 * Created with IntelliJ IDEA
 * User: Anthony
 * Date: 6/8/2014
 */

public class XPListener extends Thread {

	private boolean running;
	private int lastXpGain;
	private long lastXpGainTime;
	private Script sI;
	private Skill skill;

	public XPListener(Script sI, Skill skill) {
		this.running = true;
		this.sI = sI;
		this.skill = skill;
	}

	@Override
	public void run() {
		while (running) {
			int oldXp = sI.skills.getExperience(skill);
			try {
				Thread.sleep(600);
			}
			catch (InterruptedException e) {
			}
			int newXp = sI.skills.getExperience(skill);
			if (oldXp != newXp) {
				lastXpGain = newXp - oldXp;
				lastXpGainTime = System.currentTimeMillis();
			}
		}
	}

	public void setRunning(boolean running) {
		this.running = running;
	}

	public Skill getSkill() {
		return skill;
	}

	public int getLastXpGain() {
		return lastXpGain;
	}

	public long getLastXpGainTime() {
		return lastXpGainTime;
	}

}
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * Created with IntelliJ IDEA
 * User: Anthony
 * Date: 6/8/2014
 */

public class XPTracker {

	private Script sI;
	private Set<XPListener> xpListeners;

	public XPTracker(Script sI) {
		this.sI = sI;
		this.xpListeners = new HashSet<>();
	}

	public void startTrackingSkills(Skill... skills) {
		for (Skill s : skills) {
			XPListener listener = new XPListener(sI, s);
			listener.start();
			xpListeners.add(listener);
		}
	}

	public void stopTrackingSkills(Skill... skills) {
		Iterator<XPListener> iterator = xpListeners.iterator();
		for (Skill s : skills) {
			while (iterator.hasNext()) {
				XPListener l = iterator.next();
				if (l.getSkill() == s) {
					l.setRunning(false);
					iterator.remove();
					break;
				}
			}
		}
	}

	public int getLastXpGainForSkill(Skill skill) {
		int returnValue = -1;
		for (XPListener l : xpListeners) {
			if (l.getSkill() == skill) {
				returnValue = l.getLastXpGain();
				break;
			}
		}
		return returnValue;
	}

	public long getLastXpGainTimeForSkill(Skill skill) {
		long returnValue = -1;
		for (XPListener l : xpListeners) {
			if (l.getSkill() == skill) {
				returnValue = l.getLastXpGainTime();
				break;
			}
		}
		return returnValue;
	}

	public Set<XPListener> getXpListeners() {
		return xpListeners;
	}

}

Code is shit I wrote it awhile ago (it's not even a listener lol idk why I called it that). Create and register like so:

XPTracker tracker = new XPTracker(this);

tracker.startTrackingSkills(Skill.FLETCHING);

The check using tracker methods:

tracker.getLastXpGainTimeForSkill(Skill.FLETCHING) // returns milliseconds since last xp gain
  • Author

 

I have moderated content on here cause I'm an asshole so my posts need to be approved by mods.

import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;

/**
 * Created with IntelliJ IDEA
 * User: Anthony
 * Date: 6/8/2014
 */

public class XPListener extends Thread {

	private boolean running;
	private int lastXpGain;
	private long lastXpGainTime;
	private Script sI;
	private Skill skill;

	public XPListener(Script sI, Skill skill) {
		this.running = true;
		this.sI = sI;
		this.skill = skill;
	}

	@Override
	public void run() {
		while (running) {
			int oldXp = sI.skills.getExperience(skill);
			try {
				Thread.sleep(600);
			}
			catch (InterruptedException e) {
			}
			int newXp = sI.skills.getExperience(skill);
			if (oldXp != newXp) {
				lastXpGain = newXp - oldXp;
				lastXpGainTime = System.currentTimeMillis();
			}
		}
	}

	public void setRunning(boolean running) {
		this.running = running;
	}

	public Skill getSkill() {
		return skill;
	}

	public int getLastXpGain() {
		return lastXpGain;
	}

	public long getLastXpGainTime() {
		return lastXpGainTime;
	}

}
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * Created with IntelliJ IDEA
 * User: Anthony
 * Date: 6/8/2014
 */

public class XPTracker {

	private Script sI;
	private Set<XPListener> xpListeners;

	public XPTracker(Script sI) {
		this.sI = sI;
		this.xpListeners = new HashSet<>();
	}

	public void startTrackingSkills(Skill... skills) {
		for (Skill s : skills) {
			XPListener listener = new XPListener(sI, s);
			listener.start();
			xpListeners.add(listener);
		}
	}

	public void stopTrackingSkills(Skill... skills) {
		Iterator<XPListener> iterator = xpListeners.iterator();
		for (Skill s : skills) {
			while (iterator.hasNext()) {
				XPListener l = iterator.next();
				if (l.getSkill() == s) {
					l.setRunning(false);
					iterator.remove();
					break;
				}
			}
		}
	}

	public int getLastXpGainForSkill(Skill skill) {
		int returnValue = -1;
		for (XPListener l : xpListeners) {
			if (l.getSkill() == skill) {
				returnValue = l.getLastXpGain();
				break;
			}
		}
		return returnValue;
	}

	public long getLastXpGainTimeForSkill(Skill skill) {
		long returnValue = -1;
		for (XPListener l : xpListeners) {
			if (l.getSkill() == skill) {
				returnValue = l.getLastXpGainTime();
				break;
			}
		}
		return returnValue;
	}

	public Set<XPListener> getXpListeners() {
		return xpListeners;
	}

}

Code is shit I wrote it awhile ago (it's not even a listener lol idk why I called it that). Create and register like so:

XPTracker tracker = new XPTracker(this);

tracker.startTrackingSkills(Skill.FLETCHING);

The check using tracker methods:

tracker.getLastXpGainTimeForSkill(Skill.FLETCHING) // returns milliseconds since last xp gain

I'm getting a weird error where smithXP.startTrackingSkills(Skill.SMITHING); is saying that it wants an @ before start and and @ sign instead of a semi colon, other than that everything looks good, Thanks for this by the way! I would have had no clue on how to write a class/method for something like that.

 

Create an account or sign in to comment

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.