Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Bank withdraw X amount


    Sicilian7

    Recommended Posts

    Currently the Bank API allows setting things like

    Bank.setWithdrawMode(BankMode.NOTE)
    Bank.setRearrangeMode(BankMode.SWAP)

    It would be really nice if the API also had support for something like follows:

    Bank.setWithdrawAmount(BankMode.ONE)
    Bank.setWithdrawAmount(BankMode.FIVE)
    Bank.setWithdrawAmount(BankMode.TEN)
    Bank.setWithdrawAmount(BankMode.ALL)
    Bank.setWithdrawAmount(BankMode.X,14)

    Shouldn't be too hard to add. The widgets are:

    Widgets.getWidgetChild(12,27); //1
    Widgets.getWidgetChild(12,29); //5
    Widgets.getWidgetChild(12,31); //10
    Widgets.getWidgetChild(12,33); //X
    Widgets.getWidgetChild(12,35); //ALL

    I can provide more code for the devs, but this really should be part of the API due to its usefulness. The only tricky part might be setting the X widget, since it asks you to input an amount if no amount has been entered before.

    Link to comment
    Share on other sites

    public enum WithdrawQuantity {
    
        ONE(0, "1"),
        FIVE(1, "5"),
        TEN(2, "10"),
        CUSTOM(3, "X"),
        ALL(4, "All");
    
        private static final int PLAYER_SETTING_QUANTITY = 1666;
        private static final int PLAYER_SETTING_CUSTOM_QUANTITY_VALUE = 304;
        private static final int WIDGET_ID = 12;
        private final int settingValue;
        private final String widgetText;
    
        WithdrawQuantity(int settingValue, String widgetText) {
            this.settingValue = settingValue;
            this.widgetText = widgetText;
        }
    
        private static int getPlayerSettingValue() {
            return ((PlayerSettings.getConfig(PLAYER_SETTING_QUANTITY) >> 2) & 0b111);
        }
    
        public static int getCustomQuantityValue() {
            return ((PlayerSettings.getConfig(PLAYER_SETTING_CUSTOM_QUANTITY_VALUE) >> 1));
        }
    
        public static WithdrawQuantity getCurrentSetting() {
            WithdrawQuantity[] all = WithdrawQuantity.values();
            int value = getPlayerSettingValue();
            return Arrays.stream(all).filter(i -> i.getSettingValue() == value).findFirst().orElse(null);
        }
    
        private int getSettingValue() {
            return this.settingValue;
        }
    
        private String getWidgetText() {
            return widgetText;
        }
    
        private WidgetChild getButton() {
            String text = this.getWidgetText();
            Widget bank = Widgets.getWidget(WIDGET_ID);
            if (bank != null && bank.isVisible()) {
                List<WidgetChild> childList = bank.getChildren();
                for (WidgetChild c : childList) {
                    if (c != null && c.isVisible() && c.getText().equalsIgnoreCase(text)) {
                        int id = c.getID();
                        WidgetChild p = childList.stream().filter(i -> i != null && i.isVisible() && i.getID() == (id - 1)
                                && i.getActions() != null && i.getActions().length > 0).findFirst().orElse(null);
                        if (p != null && p.isVisible()) {
                            String[] actions = p.getActions();
                            for (String a : actions) {
                                if (a.trim().toLowerCase().contains("default quantity")) {
                                    return c;
                                }
                            }
                        }
                    }
                }
            }
    
            return null;
        }
    
        public static boolean setWithdrawQuantity(WithdrawQuantity quantity) {
            if (getCurrentSetting() == quantity) {
                return true;
            }
    
            WidgetChild widget = quantity.getButton();
            if (widget != null && widget.isVisible()) {
                return widget.interact();
            }
    
            return false;
        }
    
        public static boolean setWithdrawXValue(int value) {
            if(getCustomQuantityValue() == value){
                return true;
            }
    
            WidgetChild xWidget = WithdrawQuantity.CUSTOM.getButton();
            if (xWidget != null && xWidget.isVisible()) {
                if (xWidget.interact("Set custom quantity")) {
                    Keyboard.type(String.valueOf(value), true);
                    SleepProvider.sleep(2500);
                }
            }
    
            return WithdrawQuantity.getCustomQuantityValue() == value;
        }
    
    }

     

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.