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 when starting script?

Featured Replies

[ERROR][01/22 08:08:24 PM]: Failed to start script [FlaxSpinner]

java.lang.reflect.InvocationTargetException

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at org.osbot.coM1.run(ve:146)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.NullPointerException

at Main.<init>(Main.java:18)

... 8 more

 

 

Prints this out when I try to start a script I've been working on. Do I need to post my script up here also?

  • Author


import org.osbot.rs07.api.map.Position;

import org.osbot.rs07.api.model.Player;

import org.osbot.rs07.api.model.RS2Object;

import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;

import org.osbot.rs07.utility.Area;

import org.osbot.rs07.api.Client;

import org.osbot.rs07.api.Interfaces;

import java.awt.*;

@ScriptManifest(author = "ME", info = "My second script", name = "FlaxSpinner", version = 0, logo = "")

public class Main extends Script {

@Override

public void onStart() {

log("Let's get started!");

}

final int BANK_BOOTH_ID = 18491;

RS2Object bankBooth = objects.closest("Bank booth");

private static final Area SPIN_AREA = new Area(3208, 3212, 3211, 3216);

RS2Object Spinning_wheel = objects.closest("Spinning wheel");

Interfaces Inter = objects.getInterfaces();

Client client = objects.getClient();

Player player = myPlayer();

RS2Object Stair_Case = objects.closest("Staircase");

RS2Object Door = objects.closest("Door");

private enum State{

SPIN, BANK, WALK_TO_WHEEL, WALK_TO_BANK;

}

private State getState() {

if (inventory.contains("Flax") && SPIN_AREA.contains(player.getPosition())){

return State.SPIN;

}

else if(!inventory.contains("Flax") && SPIN_AREA.contains(player.getPosition())){

return State.BANK;

}

else if(inventory.contains("Flax") && !SPIN_AREA.contains(player.getPosition())){

return State.WALK_TO_WHEEL;

}

else{

return State.WALK_TO_BANK;

}

}

private boolean checkDoorIsOpen(){

if(Door != null) {

for(String actions: Door.getDefinition().getActions()) {

if(actions.contains("Open")) {

return true;

}

}

}

return false;

}

@Override

public int onLoop() throws InterruptedException {

switch(getState()){

case SPIN:

outerIf:

if(!myPlayer().isAnimating()){

sleep(random(500, 1000));

if(!inventory.contains("Flax")){

sleep(random(600, 800));

break outerIf;

}

while(!player.isAnimating()){

sleep(random(50, 100));

Spinning_wheel.interact("Spin");

Inter.interactWithChild(459, 91, "Make X");

if (Inter.containingText("Enter amount:") != null){

sleep(random(1000,2000));

keyboard.typeString("99");

break outerIf;

}

}

}

break;

case BANK:

if(bankBooth != null){

if(bankBooth.interact("Bank")){

while(!bank.isOpen()){

sleep(random(250, 400));

}

bank.depositAll("Bow string");

if(bank.contains("Flax")){

bank.withdraw("Flax", 28);

}

else{

stop();

}

bank.close();

}

}

break;

case WALK_TO_BANK:

localWalker.walk(new Position(3208, 3214, 1));

if(checkDoorIsOpen()){

String status = "Opening the door";

Door.interact("Open");

}else if(!checkDoorIsOpen()){

sleep(random(500,700));

localWalker.walk(new Position(3205,3209,1));

if (Stair_Case != null){

Stair_Case.interact("Climb");

sleep(random(200,300));

Inter.interactWithChild(459, 91, "Climb up the stairs.");

localWalker.walk(new Position(3208,3220,2));

}

}

break;

case WALK_TO_WHEEL:

localWalker.walk(new Position(3205, 3209, 2));

if(Stair_Case != null){

Stair_Case.interact("Climb-down");

if(checkDoorIsOpen()){

String status = "Opening the door";

Door.interact("Open");

}else if(!checkDoorIsOpen()){

localWalker.walk(new Position(3209, 3213, 1));

}

}

break;

}

return random(200, 300);

}

@Override

public void onExit() {

log("Thanks for running my FlaxSpinner!");

}

@Override

public void onPaint(Graphics2D g) {

}

}

Just reposted this - so it doesn't come up with that horrible white between the lines  ( http://gyazo.com/e58de3ce3ac286d198cb906a22e03d71 ) - Apologies if this is a problem just for me. 

import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.Area;
import org.osbot.rs07.api.Client;
import org.osbot.rs07.api.Interfaces;
import java.awt.*;
 
 
@ScriptManifest(author = "ME", info = "My second script", name = "FlaxSpinner", version = 0, logo = "")
public class Main extends Script {
 
	
    @Override
    public void onStart() {
        log("Let's get started!");
    }
    
    final int BANK_BOOTH_ID = 18491;
	RS2Object bankBooth = objects.closest("Bank booth");
    private static final Area SPIN_AREA = new Area(3208, 3212, 3211, 3216);
    RS2Object Spinning_wheel = objects.closest("Spinning wheel");
	Interfaces Inter = objects.getInterfaces();
	Client client = objects.getClient();
	Player player = myPlayer();
	RS2Object Stair_Case = objects.closest("Staircase");
	RS2Object Door = objects.closest("Door");
    
    private enum State{
		SPIN, BANK, WALK_TO_WHEEL, WALK_TO_BANK;
	}
    
    
	private State getState() {
    	if (inventory.contains("Flax") && SPIN_AREA.contains(player.getPosition())){
    		return State.SPIN;
    	}
    	else if(!inventory.contains("Flax") && SPIN_AREA.contains(player.getPosition())){
    		return State.BANK;
    	}
    	else if(inventory.contains("Flax") && !SPIN_AREA.contains(player.getPosition())){
    		return State.WALK_TO_WHEEL;
    	}
    	else{
    		return State.WALK_TO_BANK;
    	}
	}
	
	private boolean checkDoorIsOpen(){ 
 
        if(Door != null) {
            for(String actions: Door.getDefinition().getActions()) {
                if(actions.contains("Open")) {
                    return true;
                }
            }
        }
        return false;
    }
 
    @Override
    public int onLoop() throws InterruptedException {
    	
    	switch(getState()){
    	
    	case SPIN:
    		outerIf:
    			if(!myPlayer().isAnimating()){
    				sleep(random(500, 1000));
    				if(!inventory.contains("Flax")){
    					sleep(random(600, 800));
    					break outerIf;
    				}
    				while(!player.isAnimating()){
    					sleep(random(50, 100));
    					Spinning_wheel.interact("Spin");
    	    			Inter.interactWithChild(459, 91, "Make X");
    	    			if (Inter.containingText("Enter amount:") != null){
    	    				sleep(random(1000,2000));
    	    				keyboard.typeString("99");
    	    				break outerIf;
    	    				}
    					}
    				}
    			
    		break;
    	case BANK:
    		
    		if(bankBooth != null){
    			if(bankBooth.interact("Bank")){
    				while(!bank.isOpen()){
    					sleep(random(250, 400));
    				}
    				bank.depositAll("Bow string");
    				if(bank.contains("Flax")){
    					bank.withdraw("Flax", 28);
    				}
    				else{
    					stop();
    				}
    				bank.close();
    			}
    		}
    		break;
    	case WALK_TO_BANK:
    		localWalker.walk(new Position(3208, 3214, 1));
    		if(checkDoorIsOpen()){
    			String status = "Opening the door";
    			Door.interact("Open");
    		}else if(!checkDoorIsOpen()){
    			sleep(random(500,700));
    			localWalker.walk(new Position(3205,3209,1));
    			if (Stair_Case != null){
    				Stair_Case.interact("Climb");
    				sleep(random(200,300));
    				Inter.interactWithChild(459, 91, "Climb up the stairs.");
    				localWalker.walk(new Position(3208,3220,2));
    			}
    			
    		}
    		break;
    	case WALK_TO_WHEEL:
    		localWalker.walk(new Position(3205, 3209, 2));
    		if(Stair_Case != null){
    			Stair_Case.interact("Climb-down");
    			if(checkDoorIsOpen()){
    				String status = "Opening the door";
    				Door.interact("Open");
    			}else if(!checkDoorIsOpen()){
    				localWalker.walk(new Position(3209, 3213, 1));
    			}
    			
    		}
    		break;
    	}
    	return random(200, 300);
    	
    }
    	
    	
    
    
 
    @Override
    public void onExit() {
        log("Thanks for running my FlaxSpinner!");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
    
	
 
}

Edited by Roar

  • Author

Heh, Thank you. I wasn't quite sure how to get rid of those every-other white line.

No problem ^^ - if you use the code snippet (the two blue < > symbols)  and click java then paste your code in it should work ^^ 

or you can quote me and just put it into your post - then I can edit mine :) 

 

[ERROR][01/22 08:08:24 PM]: Failed to start script [FlaxSpinner]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.osbot.coM1.run(ve:146)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at Main.<init>(Main.java:18)
... 8 more
 
 
Prints this out when I try to start a script I've been working on. Do I need to post my script up here also?

 

 

 

 

Just reposted this - so it doesn't come up with that horrible white between the lines  ( http://gyazo.com/e58de3ce3ac286d198cb906a22e03d71 ) - Apologies if this is a problem just for me. 


    final int BANK_BOOTH_ID = 18491;
	RS2Object bankBooth = objects.closest("Bank booth");
    private static final Area SPIN_AREA = new Area(3208, 3212, 3211, 3216);
    RS2Object Spinning_wheel = objects.closest("Spinning wheel");
	Interfaces Inter = objects.getInterfaces();
	Client client = objects.getClient();
	Player player = myPlayer();
	RS2Object Stair_Case = objects.closest("Staircase");
	RS2Object Door = objects.closest("Door");
    
    

I feel like something is wrong here.

 

edit: i'm assuming you removed something before posting the script, a few lines somewhere, otherwise that error makes no sense

Edited by Isolate

  • Author

I don't recall removing anything from the script before posting ithuh.png What does the error mean?

I don't recall removing anything from the script before posting ithuh.png What does the error mean?

 

Well the issue is that you are instantiating objects before the script even loads. You need to declare them in the scope then instantiate them in the onLoop()/onStart(). Something to this effect if you don't get what I mean:

class FlaxSpinner extends Script{

   public Player myPlayer;
   
   public void onLoop(){
        myPlayer = getPlayer(); //or whatever you call the method
   }

}

Hopefully you get the idea, you need to do this for all the objects created. This is bad practice assigning a new object every call of the loop so I would recommend you put it in a statement block where if you reach a certain area lets say then it will create the object.

if(myPlayer.isInArea(BANK)){
   bankBooth = objects.closest("bank booth");

   if(bankBooth != null){
      bankBooth.interact("Use");
   }
}

Don't copy n paste pulled the API from my head and it's not doubt wrong tongue.png

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.