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.

Help needed with Script :D " Y NO WERK!"

Featured Replies

Hey guys I'm new to java, trying to create a Yew Cutter & bank in seers ,

any ways of improving or any mistakes in code please point out. I am eager to learn and improve

I am using Oracle and this script was written on one 'Class' page in IDE.

Do i need to create other pakages,enum or class pages to support this code?

will this layout even work?

Thanks Guys

-NightChillz

 

 

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;

@ScriptManifest(author = "NightChillz", info = "WC", name = "WC", version = 0, logo = "")
public class WC extends Script {
    private Position[] path = {
             new Position(2710, 3462, 0),
             new Position(2717, 3463, 0),
             new Position(2719, 3469, 0),
             new Position(2719, 3476, 0),
             new Position(2718, 3483, 0),
             new Position(2725, 3488, 0),
             new Position(2724, 3493, 0),
                 
       };
    private static final Area TREE_AREA = new Area(2716, 3458, 2704, 3464);
    private static final Area BANK_AREA = new Area(2721, 3493, 2729, 3490);
    
    @Override
    public void onStart() {
        "script under development"
    }

    private enum State {
        CHOP, WALK_TO_BANK, BANK, WALK_TO_TREES,
    };

    private State getState() {
        if (inventory.isFull() && TREE_AREA.contains(myPlayer()))
            return State.WALK_TO_BANK;
        if (!inventory.isFull() && BANK_AREA.contains(myPlayer()))
            return State.WALK_TO_TREES;
        if (inventory.isFull() && BANK_AREA.contains(myPlayer()))
            return State.BANK;
        return State.CHOP;
    }
    private boolean walkTile(Position p) throws InterruptedException {
        client.moveMouse(new MinimapTileDestination(bot, p), false);
        sleep(random(150, 250));
        client.pressMouse();
        int failsafe = 0;
        while (failsafe < 10 && myPlayer().getPosition().distance(p) > 2) {
            sleep(200);
            failsafe++;
            if (myPlayer().isMoving())
                failsafe = 0;
        }
        if (failsafe == 10)
            return false;
        return true;
    }
            

}

    @Override
    public boolean execute()
            throws java.lang.InterruptedException {
        switch (getState()) {
        case CHOP:
            if (!myPlayer().isAnimating()) {
                RS2Object tree = objects.closest(YEW);
                if (tree != null) {
                    if (tree.interact("Chop-Down"))
                        sleep(random(1000, 1500));
                }
            }
            break;
        case WALK_TO_BANK:
            traversePath(path, false);
            sleep(random(1500, 2500));
            break;
        case WALK_TO_TREES:
            traversePath(path, true);
            sleep(random(1500, 2500));
            break;
        case BANK:
            RS2Object bankBooth = objects.closest("Bank booth");
            if (bankBooth != null) {
                if (bankBooth.interact("Bank")) {
                    while (!bank.isOpen())
                        sleep(250);
                    bank.depositAll();
                }
            }
            break;

    }
    return random(200, 700);
}
    @Override
    public void onExit() {
        
    }

    @Override
    public void onPaint(Graphics2D g) {

    }

}

Edited by Nightchillz

 

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;

@ScriptManifest(author = "NightChillz", info = "WC", name = "WC", version = 0, logo = "")
public class WC extends Script {
    private Position[] path = {
             new Position(2710, 3462, 0),
             new Position(2717, 3463, 0),
             new Position(2719, 3469, 0),
             new Position(2719, 3476, 0),
             new Position(2718, 3483, 0),
             new Position(2725, 3488, 0),
             new Position(2724, 3493, 0),
                 
       };
    private static final Area TREE_AREA = new Area(2716, 3458, 2704, 3464);
    private static final Area BANK_AREA = new Area(2721, 3493, 2729, 3490);
    
    @Override
    public void onStart() {
        "script under development"
    }

    private enum State {
        CHOP, WALK_TO_BANK, BANK, WALK_TO_TREES, WAIT,
    };

    private State getState() {
        if (inventory.isFull() && TREE_AREA.contains(myPlayer()))
            return State.WALK_TO_BANK;
        if (!inventory.isFull() && BANK_AREA.contains(myPlayer()))
            return State.WALK_TO_TREES;
        if (inventory.isFull() && BANK_AREA.contains(myPlayer()))
            return State.BANK;
        return State.CHOP;
    }
    private boolean walkTile(Position p) throws InterruptedException {
        client.moveMouse(new MinimapTileDestination(bot, p), false);
        sleep(random(150, 250));
        client.pressMouse();
        int failsafe = 0;
        while (failsafe < 10 && myPlayer().getPosition().distance(p) > 2) {
            sleep(200);
            failsafe++;
            if (myPlayer().isMoving())
                failsafe = 0;
        }
        if (failsafe == 10)
            return false;
        return true;
    }
            
         
         
       
            return State.CHOP;
}

    @Override
    public boolean execute()
            throws java.lang.InterruptedException {
        switch (getState()) {
        case CHOP:
            if (!myPlayer().isAnimating()) {
                RS2Object tree = objects.closest(YEW);
                if (tree != null) {
                    if (tree.interact("Chop-Down"))
                        sleep(random(1000, 1500));
                }
            }
            break;
        case WALK_TO_BANK:
            traversePath(path, false);
            sleep(random(1500, 2500));
            break;
        case WALK_TO_TREES:
            traversePath(path, true);
            sleep(random(1500, 2500));
            break;
        case BANK:
            RS2Object bankBooth = objects.closest("Bank booth");
            if (bankBooth != null) {
                if (bankBooth.interact("Bank")) {
                    while (!bank.isOpen())
                        sleep(250);
                    bank.depositAll();
                }
            }
            break;

    }
    return random(200, 700);
}
    @Override
    public void onExit() {
        
    }

    @Override
    public void onPaint(Graphics2D g) {

    }

}

Formatted so its readable

Umm you should make it try open the bank if its not open only otheriwse it'll keep trying even if open.

and use bank.open();

Also i dunno if interact method supports camera turning does it?

if it doesn't you might want to check if the object is on the screen before interacting with it

waaiiiiiit a minute -.-

How old is the jar you're using as a library?

execute isnt an inherent method of script, you should have onLoop()

Execute IS a method inheritable from Script; but it should never be overridden, since it's what we use to execute events. Altho the method signature seems wrong.

 

The main issues I see with your code, though, is that you seem to cut off your class early, and attempt to return a value outside of a method. here:

            return State.CHOP;
}

^ these should probably be removed. But I can't really tell if the indentation is correct; so I'm not entirely certain. In any case, you cannot return a value outside of methods.

Also you should not override execute(), like Isolate said.

The main script loop method should be called onLoop, and return an integer value indicating the number of milliseconds to sleep for, until the next loop cycle begins.

Edited by FrostBug

  • Author

@ Isolate

Formatted so its readable
Umm you should make it try open the bank if its not open only otheriwse it'll keep trying even if open.
and use bank.open();

Also i dunno if interact method supports camera turning does it?
if it doesn't you might want to check if the object is on the screen before interacting with it


waaiiiiiit a minute -.-
How old is the jar you're using as a library?


execute isnt an inherent method of script, you should have onLoop()

 

 

yo Iso,

Soz about format wacko.png I'm using java SE 1.7

Thanks for help again dude ill keep tweaking it

will post a revised version tomorrow.

 

@ Isolate

yo Iso,

Soz about format wacko.png I'm using java SE 1.7

Thanks for help again dude ill keep tweaking it

will post a revised version tomorrow.

 

He didn't ask your java version, how old is the OSBot.jar your using? Hes saying its probably ancient and ya need to update.

  • Author

2.3.44 ?  I thought older versions are unsupported?

2.3.44 ?  I thought older versions are unsupported?

I was thrown off by you using execute instead of onLoop is all

Edited by Isolate

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.