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.

Getting / Setting Bank Quantity (27th Sep Update)

Featured Replies

import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.api.util.CachedWidget;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.utility.ConditionalSleep;

public class BankQuantity extends MethodProvider {

    private static final int CONFIG_ID = 1666;
    private static final int BANK_WIDGET_ROOT_ID = 12;

    private CachedWidget quantityLabelWidget;

    /*
    1666: 0 -> ONE
    1666: 4 -> FIVE
    1666: 8 -> TEN
    1666: 12 -> X
    1666: 16 -> ALL
     */
    public Quantity getQuantity() {
        return Quantity.values()[getConfigs().get(CONFIG_ID) / 4];
    }

    public boolean setQuantity(final Quantity quantity) {
        if (quantity == getQuantity()) {
            return true;
        }

        if (!getWidgets().isVisible(BANK_WIDGET_ROOT_ID)) {
            return false;
        }

        if (quantityLabelWidget == null || !quantityLabelWidget.initialized()) {
            quantityLabelWidget = new CachedWidget(this, w -> w != null && w.getMessage().equals("Quantity:"), BANK_WIDGET_ROOT_ID);
            quantityLabelWidget.cache();
        }

        if (quantityLabelWidget.initialized()) {
            int rootID = quantityLabelWidget.getRootId();
            int secondLevelID = quantityLabelWidget.getSecondLevelId();

            if (quantity == Quantity.ONE) {
                secondLevelID += 1;
            } else {
                secondLevelID += (quantity.ordinal() + 1) * 2;
            }

            RS2Widget quantityWidget = getWidgets().get(rootID, secondLevelID);

            if (quantityWidget != null && quantityWidget.interact()) {
                new ConditionalSleep(1800, 600) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getQuantity() == quantity;
                    }
                }.sleep();
                return true;
            }
        }

        return false;
    }

    enum Quantity {
        ONE,
        FIVE,
        TEN,
        X,
        ALL
    }
}

 

Usage:

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

@ScriptManifest(author = "Explv", name = "Example", version = 0.1, logo = "", info = "")
public class Example extends Script {

    private BankQuantity bankQuantity = new BankQuantity();

    @Override
    public void onStart() {
        bankQuantity.exchangeContext(getBot());
    }

    @Override
    public int onLoop() throws InterruptedException {
        if (!getBank().isOpen()) {
            getBank().open();
        } else if (bankQuantity.getQuantity() != BankQuantity.Quantity.ALL) {
            bankQuantity.setQuantity(BankQuantity.Quantity.ALL);
        } else {
            getBank().withdrawAll("Yew logs");
        }
        return 600;
    }
}



@Alek add to API?

Edited by Explv

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.