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.

Scripting Help

Featured Replies

So I'm having issues with world hopping, It seems it still tries to hop to p2p worlds even though I've given it set worlds to hop to and basically at this point it just causes the script to break.


import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import com.sun.glass.events.KeyEvent;

import java.awt.*;
import java.util.Random;

@ScriptManifest(name = "Rune Pack Buyer", author = "01053", version = 1.0, info = "", logo = "")

public class Shopping extends Script {

	public Timer timer;
	private long buyDelay;
	private State state;

	private int npcId = 637;
	private int packId = 12732;
	private int buying;

	private int[] worlds = {

			1, 8, 16, 26, 35, 82, 83, 84, 93, 94

	};

	Random random = new Random();

	public enum State {
		TRADING, BUYING, OPENING
	}

	public State getState() {
		if (!getStore().isOpen() && buying <= 0) {
			return State.TRADING;
		}
		if (getStore().isOpen()) {
			return State.BUYING;
		}
		if (!getStore().isOpen() && getInventory().contains(packId) && buying > 0) {
			return State.OPENING;
		}
		return State.TRADING;
	}

	private boolean hop;

	public void execute() throws InterruptedException {
		state = getState();
		switch (state) {
		case TRADING:
			/*if (getStore().getAmount(packId) <= 57) {
				int randomWorld = random.nextInt(worlds.length);
				getWorlds().hop(randomWorld);
				buying = 0;
				hop = false;
			}*/
			NPC npc = (NPC) getNpcs().closest(npcId);
			if (npc != null) {
				if (npc.interact(new String[] { "Trade" })) {
					log("Trading shopkeeper");
					new ConditionalSleep(5500, 6000) {
						public boolean condition() throws InterruptedException {
							return getStore().isOpen();
						}
					}.sleep();
				}
			}
			break;
		case BUYING:
			if (System.currentTimeMillis() - buyDelay < 1000) {
				return;
			}
			if (getStore().getAmount(12732) <= 57 && !getInventory().contains(12732)) {
				int randomWorld = random.nextInt(worlds.length);
				getWorlds().hop(randomWorld);
				buying = 0;
				hop = false;
			}
			if (getInventory().isFull()) {
				getKeyboard().pressKey(KeyEvent.VK_ESCAPE);
				buying++;
			}
			Item rune = getStore().getItem(packId);
			if ((rune != null) && (getStore().getAmount(packId) > 54)) {
				getStore().buy(packId, 10);
				log("Buying Rune Packs");
				hop = false;
				buyDelay = System.currentTimeMillis();
			}
			break;
		case OPENING:
			if (hop && getStore().getAmount(12732) <= 57 && !getInventory().contains(12732)) {
				int randomWorld = random.nextInt(worlds.length);
				getWorlds().hop(randomWorld);
				buying = 0;
				hop = false;
			}
			if (getInventory().contains(packId) && !getTabs().open(Tab.INVENTORY)) {
				getKeyboard().pressKey(KeyEvent.VK_F1);
			}
			for (int i = 1; i < 28; i++) {
				getMouse().click(getInventory().getMouseDestination(i + 1));
				hop = true;
			}
			break;
		}
	}

	@[member='Override']
	public void onStart() {
		timer = new Timer(0L);
		log("Rune Pack BUYING Script Initiating.");
	}

	@[member='Override']
	public int onLoop() throws InterruptedException {
		execute();
		return 100;
	}

	Color color = new Color(0, 0, 0, 85);

	@[member='Override']
	public void onPaint(Graphics2D gr) {
		gr.setColor(this.color);
		gr.fillRect(56, 355, 198, 100);
		gr.setColor(Color.GREEN);
		gr.setFont(new Font("Ariel", 0, 20));
		gr.drawString("Script by: 01053", 75, 436);
		gr.setFont(new Font("Ariel", 0, 14));
		gr.drawString("Time Elapsed: " + Timer.format(timer.getElapsed()), 61, 372);
		gr.drawString("State: " + getState(), 62, 397);
		gr.setColor(Color.BLACK);
	}
}

Edited by 01053

95% that you ripped this code :D

 

Look here

if (System.currentTimeMillis() - openDelay < 1000) {
return;
}
Item pack = getInventory().getItem(12732);
if ((pack != null)) {
openDelay = System.currentTimeMillis();
pack.interact("Open");
opened++;
log("" + opened);
  • Author

 

95% that you ripped this code biggrin.png

 

Look here

if (System.currentTimeMillis() - openDelay < 1000) {
return;
}
Item pack = getInventory().getItem(12732);
if ((pack != null)) {
openDelay = System.currentTimeMillis();
pack.interact("Open");
opened++;
log("" + opened);

Lol if your talking about the openDelay I added that because it was spam clicking boxes and I didn't like it. so no that has nothing to do with it thank you though.

  • Author

use #interactWithSlot or whatever it was called

Thank you I'll look into it.

 

If anyone needs to do this also:

for (int i = 1; i < 28; i++) {
				getMouse().click(getInventory().getMouseDestination(i + 1));
			} 
works probably a better way of doing it though but yeah.
 
Edit:
 
Edited op with a new question.

Edited by 01053

  • Author
int randomWorld = random.nextInt(worlds.length);

????

 

It chooses a random index# from 

	private int[] worlds = {

			1, 8, 16, 26, 35, 82, 83, 84, 93, 94

	};

And hops to whatever world it chooses I've also tried using the 

getWorlds().HopToF2PWorld();

function and that too sometimes goofs like as if it 'clicks' the world but doesn't hop and then it just sits there.

It chooses a random index# from 

	private int[] worlds = {

			1, 8, 16, 26, 35, 82, 83, 84, 93, 94

	};

And hops to whatever world it chooses I've also tried using the 

getWorlds().HopToF2PWorld();

function and that too sometimes goofs like as if it 'clicks' the world but doesn't hop and then it just sits there.

 

you should probably take another look at the code m8. that wasnt me asking what the line does. that was me telling you theres a problem in that line lol.

Edited by Imateamcape

  • Author

you should probably take another look at the code m8. that wasnt me asking what the line does. that was me telling you theres a problem in that line lol.

After looking over it I found one issue not relevant to that code but care to explain? thanks :)

int randomWorld = random.nextInt(worlds.length);
				getWorlds().hop(randomWorld);

Should have been

int randomWorld = random.nextInt(worlds.length);
				getWorlds().hop(worlds[randomWorld]);

Was tired when I did this last night :o

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.