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.

Error in script executor! java.lang.NullPointerException

Featured Replies

When i start the script this error comes:

[ERROR][Bot #1][08/19 08:04:33 PM]: Error in script executor!
java.lang.NullPointerException
	at org.osbot.rs07.api.map.Area.contains(kn:165)
	at flourMaker.Grind.grinder(Grind.java:92)
	at flourMaker.Main.onLoop(Main.java:24)
	at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(qn:254)
	at java.lang.Thread.run(Unknown Source)

And as far as I understood it I have to do some sort of null check but dont know how to do it

The code:

package flourMaker;

import org.osbot.rs07.api.Bank;
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.script.MethodProvider;

public class Grind extends MethodProvider{
	
	final Area BANK_AREA = new Area(3183, 34405, 3185, 3444);
	final Area GUILD_TRAY = new Area(3142, 3449, 3146, 3446);
	final Area GUILD_HOPPER = new Area(3140, 3452, 3143, 3450).setPlane(2);
	
	final int BANK_BOTH_ID = 10583;
	final int GRAIN_ID = 1947;
	
	final String HOPPER_NAME = "Hopper";
	final String CONTROLS_NAME = "Hopper controls";
	
	boolean tray = false;
	boolean con = false;
	boolean shouldGrain;
	boolean finishedGrain;
	
	Inventory inv;
	Player player;
	Bank bank;
	
		public void starter() {
			exchangeContext(getBot());
			inv = getInventory();
			player = myPlayer();
			bank = getBank();
		}

	public void grinder() throws InterruptedException {
		
		if (inventory.isFull() && inventory.contains(GRAIN_ID)) {
			shouldGrain = true;
		}

		Entity hopper = getObjects().closest(HOPPER_NAME);
		Entity controller = getObjects().closest(CONTROLS_NAME);
		Entity bankbooth = getObjects().closest(BANK_BOTH_ID);

		if (shouldGrain) {
			if (GUILD_HOPPER.contains(player)) {
				if (inventory.contains(GRAIN_ID)) {
					if (!con) {
						if (hopper != null) {
							if (hopper.isVisible()) {
								if (!player.isAnimating()) {
									if (!player.isMoving()) {
										hopper.interact("Fill");
										sleep(random(1500, 2000));
										con = true;
									}
								}
							} else {
								getCamera().toEntity(hopper);
							}
						}
					} else {
						if (controller != null) {
							if (controller.isVisible()) {
								if (!player.isAnimating()) {
									if (!player.isMoving()) {
										controller.interact("Operate");
										sleep(random(1500, 2000));
										con = false;
									}
								}
							}
						}
					}
				} else {
					tray = true;
					shouldGrain = false;
					controller.interact("Operate");
					sleep(random(1500, 2000));

				}
			} else {
				getWalking().webWalk(GUILD_HOPPER);
			}
		} else {
			if (BANK_AREA.contains(player)) {
				if (bank.isOpen()) {
					bank.withdrawAll(GRAIN_ID);
				} else {
					if (bankbooth != null) {
						if (bankbooth.isVisible()) {
							bankbooth.interact("Bank");
							sleep(random(2000, 3000));
						} else {
							getCamera().toEntity(bankbooth);
						}
					}
				}
			} else {
				getWalking().webWalk(BANK_AREA);
			}
		}
	}
}

AS far as I understood it the problem is something to do with the areas but dont know what to do

exchangeContext(getBot()); 

Is in script not the class itself.

 

public class TopLevel extends Script {

	Grind grind;
	public void onStart() throws InterruptedException {
		grind = 	new Grind();
		grind.exchangeContext(getBot());
		grind.starter() ;
...
    }

...
public class Grind extends MethodProvider{
	...
		public void starter() {
			inv = getInventory();
			player = myPlayer();
			bank = getBank();
		}
...

 

Edited by Nbacon

  • Author
9 minutes ago, Nbacon said:

exchangeContext(getBot()); 

Is in script not the class itself.

Did this and something else VERY important that i forgot is i forgot to "call" starter on the onStart function. *FACEPALM* thanks dude you helped me a lot today

1 minute ago, TorRS said:

*FACEPALM*

P.S. also move/remove the exchangeContext(getBot());  so its in the right place.

Edited by Nbacon

  • Author
32 minutes ago, Nbacon said:

P.S. also move/remove the exchangeContext(getBot());  so its in the right place.

oke, again thanks a lot sir :)

Edited by TorRS

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.