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.

Can't find the problem..

Featured Replies

Hello everyone, how are you all doing?

 

Since the newest OSRS update last Thursday i have a little problem with my script.

 

The problem: 

 

Since the newest OSRS update last Thursday, my script doesn't run flawless anymore.

When i'm at the bank, it selects a bank, open's the bank and then presses the X button (close bank).

It does this for 2 times (or more) and then banks the willow logs. Kinda an EXP waste.

 

I have been editing a lot of things to my BANK case. But everything i do, it doesn't seem to fix the problem.

Eclipse gives no errors. And as i mentioned earlier: The script runned flawless before the OSRS update.

Now i'm kinda new to this, but i really want to proceed my scripting. Have tried to just ignore this problem, but it irritates me a lot that it doesn't do what i want it to do.

 

Java Version and OSbot version: 

 

* Java jdk1.8.0_65

* OSbot 2.4.5.

 

My CASE Bank:

case BANK:
			if (Willows.contains(myPlayer())) {
				if (inventory.isFull()) {
					walkPath(pathToBank);
				}
			} else {
				if (draynorBank.contains(myPlayer())) {
					Entity bankbooth = objects.closest(BANK_BOOTH_ID);

					if (bankbooth != null) {
							if (inventory.isFull()) {
								camera.toEntity(bankbooth);
								bankbooth.interact("Bank");
								sleep(random(500,700));
							}
					}
					if(bank.isOpen()) {
						sleep(random(500,700));
						bank.depositAll("Willow logs");
					}
				}
				if (draynorBank.contains(myPlayer()) && inventory.isEmpty() || draynorBank.contains(myPlayer()) && inventory.isEmptyExcept(1351, 1355, 1357, 1359, 6739)) {
					Entity Willowtrees = objects.closest(Willowtrees_ID);
					walkPath(pathToWillows);
					camera.toEntity(Willowtrees);
				}
			}
			break;

Hope you can help me with this. Its getting kinda anoying.

 

 

Sincerely your's,

 

 

Sebastian.

The problem is pretty obvious if you think about it.

 

1. If the bank booth is not null, you interact with it.

 

2. After interacting with it, you immediately try to withdraw from it, in the case that the bank is open.

The bank however is in many cases not going to be open after 500 milliseconds after clicking, especially if there's distance between you and the object (which there will often be, since 'closest' method doesn't use manhattan distance).

 

3. In the case that the bank was not open after the 500 milliseconds, you try to interact with the bank booth again, but since you cannot interact with object while the bank widget is open, the interact method will close the bank before interacting.

 

^this repeats.

 

You should generally avoid doing multiple interactions in 1 loop cycle, and always evaluate the success of your actions (never assume success).

In this particular case tho, I think you can solve it by adding a check to the case for opening the bank

if (bankbooth != null && !getBank().isOpen() && !myPlayer().isMoving()) {
	//interact
}

Edited by FrostBug

  • Author

Hey! It does click the bank 1 time now! Thanks for that. Only problem is. It doesn't deposit the logs anymore. 

 

EDIT: Trying it with the !myPlayer().isMoving()). Will let you know in a sec.

EDIT EDIT: Nope, it doesn't work. My Logs aren't stored in the bank.

		if (bankbooth != null && !getBank().isOpen() && !myPlayer().isMoving()) {
						if (inventory.isFull()) {
							camera.toEntity(bankbooth);
							bankbooth.interact("Bank");
							bank.depositAll("Willow logs");
							sleep(random(500,700));
						}
				}

Edited by OSRS Sebastian

 

Hey! It does click the bank 1 time now! Thanks for that. Only problem is. It doesn't deposit the logs anymore. 

 

EDIT: Trying it with the !myPlayer().isMoving()). Will let you know in a sec.

			if (bankbooth != null && !getBank().isOpen()) {
						if (inventory.isFull()) {
							camera.toEntity(bankbooth);
							bankbooth.interact("Bank");
							bank.depositAll("Willow logs");
							sleep(random(500,700));
						}
				}

 

There's no sleep time between opening the bank and depositing willow logs. Try adding a conditional sleep after interacting like this:

 

bankbooth.interact("Bank");
new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getBank().isOpen();
                    }

                }.sleep();

 

This means that the bot will sleep for 5000 milliseconds or until the bank is open. Whichever comes first.

 

 

 

You should generally avoid doing multiple interactions in 1 loop cycle, and always evaluate the success of your actions (never assume success).

In this particular case tho, I think you can solve it by adding a check to the case for opening the bank

 

 

You can evaluate the success by adding conditional sleeps.

  • Author

There's no sleep time between opening the bank and depositing willow logs. Try adding a conditional sleep after interacting like this:

bankbooth.interact("Bank");
new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getBank().isOpen();
                    }

                }.sleep();

This means that the bot will sleep for 5000 milliseconds or until the bank is open. Whichever comes first.

 

 

You can evaluate the success by adding conditional sleeps.

 

Wow! This worked! Thanks! 

 

But, can you explain why using a sleep, fixed this problem? just for my own knowledge.

Wow! This worked! Thanks! 

 

But, can you explain why using a sleep, fixed this problem? just for my own knowledge.

 

frostbug above explained why.

 

Hey! It does click the bank 1 time now! Thanks for that. Only problem is. It doesn't deposit the logs anymore. 

 

EDIT: Trying it with the !myPlayer().isMoving()). Will let you know in a sec.

EDIT EDIT: Nope, it doesn't work. My Logs aren't stored in the bank.

		if (bankbooth != null && !getBank().isOpen() && !myPlayer().isMoving()) {
						if (inventory.isFull()) {
							camera.toEntity(bankbooth);
							bankbooth.interact("Bank");
							bank.depositAll("Willow logs");
							sleep(random(500,700));
						}
				}

 

You weren't supposed to move the deposit statement into the open-bank block, would have been fine if left where it was.

 

Glad you solved the problem, tho.

 

Wow! This worked! Thanks! 

 

But, can you explain why using a sleep, fixed this problem? just for my own knowledge.

 

Code runs line by line. Let's say you had something like this:

NPC goblin = getNpcs().closest("Goblin");
goblin.interact("Attack");
getBank().open();

This will first attack the goblin and then open the bank. HOWEVER, there is a delay for game actions that isnt there in code. This means that you will click the goblin and then immediately try and open the bank. Sleeping between code essentially means that you're waiting until the next line.

NPC goblin = getNpcs().closest("Goblin");
goblin.interact("Attack");
sleep(600);
getBank().open();

sleep(600) will wait 600ms (also known as 1 tick in OSRS) and then perform the next line of code.

 

EDIT: There is also something known as asynchronous code, which means that the code runs but still allows the next line(s) to run.

Edited by Bobrocket

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.