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.

Script wont start

Featured Replies

Hey can anyone help me here I made a simple script and when I start to the script it doesnt start.

package core;


import org.osbot.rs07.api.Objects;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import static core.PestControl.State.*;

@ScriptManifest(version = 0, info = "Pest Control :D", logo = "", author = "Nimmogel", name = "Pest Control")
public class PestControl extends Script {

    final State state = getState();

    Area onBoatArea = new Area(2637, 2647, 2641, 2641);
    Area pcArea = new Area(2623, 2622, 2689, 2561);
    Area killArea = new Area(2627, 2596, 2640, 2587);
    Area outsideBoat = new Area(2644, 2646, 2644, 2642);

    String[] pestControlMonsters = {"Brawler","Defiler","Ravager","Shifter","Spinner","Torcher"};

    public void onStart() throws InterruptedException {
        log("Pest Control has started :D");
    }

    public enum State {
        ATTACK,
        ONBOAT,
        BOAT,
        WALKTOSPOT
    }

    private State getState() {

        if (!pcArea.contains(myPlayer()) && !onBoatArea.contains(myPlayer())) {
            return BOAT;
        }
        if (onBoatArea.contains(myPlayer())) {
            return ONBOAT;
        }
        if (pcArea.contains(myPlayer()) && !killArea.contains(myPlayer())) {
            return WALKTOSPOT;
        }
        if (killArea.contains(myPlayer())) {
            return ATTACK;
        }
        return null;
    }


    @Override
    public int onLoop() throws InterruptedException {

        switch (getState()) {

            case ATTACK:
                NPC monster = npcs.closest(pestControlMonsters);
                log("atack monsters");

                if (monster != null) {
                    if (monster.isVisible()) {
                        if (monster.interact("Attack")) {
                            new ConditionalSleep(5000) {
                                @Override
                                public boolean condition() throws InterruptedException {
                                    return !myPlayer().isAnimating();
                                }
                            }.sleep();
                        }
                    }
                }
                break;

            case ONBOAT:

                log("onBoat");

                new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return pcArea.contains(myPlayer());
                    }
                }.sleep();

                break;

            case BOAT:
                RS2Object plank = new Objects().closest("Gangplank");

                log("boat case");

                if (plank != null) {
                    if (plank.isVisible()) {
                        if (plank.interact("Cross")) {
                            new ConditionalSleep(5000) {
                                @Override
                                public boolean condition() throws InterruptedException {
                                    return onBoatArea.contains(myPlayer());
                                }
                            }.sleep();
                        }
                    }
                } else {
                    getWalking().walk(outsideBoat);
                    sleep(random(650,900));
                }

                break;

            case WALKTOSPOT:
                log("walking to kill area");
                getWalking().webWalk(killArea);
                sleep(random(650,900));

                break;

        }
        return 120;
    }
    @Override
    public void onExit() {
        log("Thanks for running my Pest Control");
    }
}

 


    final State state = getState();

 

try putting that  (getState() part) in onStart

also dont make it final

Edited by Stimpack

  • Author
5 minutes ago, Stimpack said:


    final State state = getState();

 

try putting that  (getState() part) in onStart

also dont make it final

oh no, that part is not used, i just forgot to delete it

edit - took out now scripts starts but my script doesnt do anything and uses a shit ton of cpu and mem

Edited by Nimmogel

You should use what I do.

private enum BotState {
 BANKING, LOOTING
}

private BotState getState()
{
 return getInventory.isFull ? BotState.BANKING : BotState.LOOTING;
}

then just call the getState() in the switch. Read some of my script releases for demo on this. Becomes a little cleaner and easy to read for everyone.

Edited by Booleans YAY

new Objects().closest("Gangplank");

I suppose should be:

getObjects().closest("Gangplank");

 

  • Author

Found the issue, just simple stuff, used to a differen't api. Sorry and thanks for the help :D

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.