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.

Problem running program

Featured Replies

I seem to have to errors in my code however when I add my .jar file to the scripts folder I am unable to run it from the client. I know its an issue with my code but can't seem to figure out what the problem is. I am new to this whole thing but would appreciate any help I can get!

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(version = 1.0, logo = "", info = "Combat", author = "P", name = "bot")

public class Main extends Script{

    public long maxSleep = 1234;

    @Override
    public void onStart() throws InterruptedException {
        super.onStart();
        log("Script Started");

    }

    @Override
    public int onLoop() throws InterruptedException {
        combat combat = new combat();
        combat.findMonster();
        Eat eat = new Eat();
        eat.eat();
        eat.dropInv();
        return 432;
    }

    @Override
    public void onExit() throws InterruptedException {
        super.onExit();
        log("Script Ended");
    }
}
import org.osbot.rs07.api.model.Entity;

public class combat extends Main {

    public void findMonster() throws InterruptedException {
        Entity monster = getNpcs().closest("Cow", "Chicken");

        if(monster != null){
            monster.interact("Attack");
            if((monster == null) && !myPlayer().isAttackable()){
                sleep(343);
            }
        } else {
            sleep(maxSleep);
        }
    }

}
import org.osbot.rs07.api.GroundItems;
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.model.Character;

public class Eat {
    private Inventory inventory;
    private Character myChar;
    private GroundItems pickUp;

    public void eat() {
        int health = myChar.getHealthPercent();
        if(health < 20){
            inventory.getItem("Beef").interact("Eat");
            if(!inventory.contains("Beef") && !inventory.isFull()){
                pickUp.closest("Raw Beef").interact("Pick Up");

            }
        }

    }

    public void dropInv(){
        if(inventory.isFull()){
            inventory.dropAll("Bones", "Cow Hide");
        }
    }
}

 

I think you forgot to put them in a package.

I compiled and ran your code but... It froze my client

 

---------------------------------------------------------------------------------

Edit found your error.

You need to pass a MethodProvider to all class or echange context ... so things like 

inventory.getItem("Beef").interact("Eat"); 

can work

Edited by Nbacon

  • Author

Thank you! managed to get it working passing a method provider to the classes. Testing for bugs now but seems everything works as it should!

  • Author

just in case anyone is experiencing the same issue, in order to utilize other classes you need to first pass the method provider as a field then create a constructor from that field in the new class. Example:

public class PickUp {
//the class field
    public final MethodProvider methods;
//the constructor
    public PickUp(MethodProvider methods) {
        this.methods = methods;
    }
//implementation of the MethodProvider field in order to access the OSBot Api class
    public void itemCheck(){
        if(methods.inventory.isFull()){
            
        }
    }
}

 

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.