The client is offline due to RuneScape update. You may see instance errors but this is due to the update and not actual instance errors. This should be resolved soon. Join our Discord for more information.

Proper banking technique?



  • Hey everyone, I'm fairly new to scripting and don't really have a grasp of the best practices to use while banking...
    Currently, I'm trying to make a blast furnace script but I've run into a roadblock.

    if (Bank.contains("Coal")){
                    if (Bank.withdraw("Coal", 14)){
                        Log.fine("Took out the coal");
    

    It runs fine without any errors and it says it took out the coal but it just goes to my main bank tab and doesn't do anything.
    Any ideas? :3


  • Director

    we cant tell anything from a 3 line snippet



  • Post more of the code bro



  • Sorry, my bad!

    It's a TaskScript and this is the banking task.

    @Override
            public int execute() {
                Main.STATUS = "Banking..";
                if (Bank.isOpen()){
                    Bank.depositInventory();
                    Time.sleep(1354, 2532);
                    if (Bank.contains("Coal")){
                        if (Bank.withdraw("Coal", 14)){
                            Log.fine("Took out the coal");
                        }
                    }else{
                        Log.severe("No Coal found");
                    }
                    Time.sleep(1347, 2552);
                    if (Bank.contains("Iron ore")){
                        if (Bank.withdraw("Iron ore", 14)){
                            Log.fine("Took out the iron ore");
                        }
                    }else{
                        Log.severe("No iron ore found");
                    }
                    Bank.close();
                    Time.sleep(1344, 2453);
                    return 300;
                } else {
                    SceneObject BankChest = SceneObjects.getNearest("Bank chest");
                    if (BankChest != null && BankChest.isPositionInteractable()) {
                        Log.info("Clicked bank");
                        BankChest.click();
                        Time.sleepUntil(() -> Bank.isOpen(), 6236);
                        return 300;
    
                    } else {
                        Log.severe("Can't find bank");
                        return -1;
                    }
    
                }
    
        }
    

  • Director

    You sure that node is still executing? Whats the validate on it.



  • yes, it's still executing. I'm still getting the

    Log.fine("Took out the coal");
    

    So

    if (Bank.withdraw("Coal", 14)){
    

    must be successfully executed right?

    The validate is:

    @Override
        public boolean validate() {
            return Inventory.contains(Main.BAR_PREDICATE)
        }
    

    And if you're curious the BAR_PREDICATE is:

    public static final Predicate<Item> BAR_PREDICATE = item -> item.getName().contains("bar");
    

  • Script Writer

    @MyNamesGeph Do you happen to be in resizable mode? If so, resizable mode is not currently supported and you'll need to switch to fixed.

    I tested your code and it seems to work fine. You can also try deleting your RSPeer folder to see if that might help.



  • @Sphiinx No, I'm not in resizable mode. I got pretty excited thinking it would be that easy of a fix haha. I also tried deleting my RSPeer folder but that didn't seem to help.

    Just trying to run it again here it seems to withdraw iron but not coal? Is there a better way to call Bank.withdraw()? Should I be passing a Predicate<Item> instead of a string? I'm not very familiar with Predicates, to be honest...


  • Contributor Script Writer

    Seems like your withdraw() isn't being properly executed. Might be something to do with doing depositInventory() and doing a static sleep, and then withdrawing right after. I recommend you add a condition to depositing inventory.



  • You should work on the execution of the script. Best practice is to do one action every loop instead of doing multiple each loop like you are doing right now (depositing inventory, sleeping and then withdrawing coal). You also seem to be using a lot of magic numbers (numbers based on nothing), for example: "Time.sleep(1354, 2532)" ; "Time.sleep(1347, 2552)" ; "Time.sleepUntil(() -> Bank.isOpen(), 6236)". If you really want random "sleeps" inside your script, you should just stick to digits which are making a bit more sense like Time.sleep(1000, 2500) or just completely scrap those and use a random return value.
    I used the snippet you posted in the thread as an example:

    @Override
        public int execute()  {
            SceneObject bankChest = SceneObjects.getNearest("Bank chest"); //remember, local variables' first letter should not be capitalized.
            Main.STATUS = "Banking..";
    
            if (Bank.isOpen()) {
                if (Inventory.isFull() && Bank.depositInventory()) { //or any other condition when the bot should deposit it's inventory.
                    Time.sleepUntil(() -> Inventory.isEmpty(), 5000);
                } else if (!Inventory.contains("Coal") && Bank.contains("Coal") && Bank.withdraw("Coal", 14)) {
                    Time.sleepUntil(() -> Inventory.contains("Coal"), 5000);
                } else if (!Inventory.contains("Iron ore") && Bank.contains("Iron ore") && Bank.withdraw("Iron ore", 14)) {
                    Time.sleepUntil(() -> Inventory.contains("Iron ore"), 5000);
                } else if (Bank.close()) {
                    Sleep.sleepUntil(() -> !Bank.isOpen());
                }
            } else if (bankChest != null && bankChest.isPositionInteractable() && bankChest.click()) {
                Time.sleepUntil(() -> Bank.isOpen(), 5000);
            } else if (bankChest == null || !bankChest.isPositionInteractable()) { //this could be just an else statement as well but might be handy when adding other stuff.
                Log.severe("Can't find bank");
                return -1;
            }
            return 300;
        }
    

    (If anyone else sees improvements or mistakes, don't hesitate)



  • @The-Undefeated Wow that's much cleaner, thank you!
    so I'm using that in my script but I'm STILL having issues. It's maybe not finding the coal? It seems like when it attempts to execute that line where it withdraws the coal it goes back to my main bank tab then the bank closes then suddenly i have 14 iron ore in my inventory.

    If I make any progress I'll post and let you know what it was. Thanks again.


  • Script Writer

    @MyNamesGeph Can you send us a screenshot of what the client looks like with the bank open? Maybe you have some bank setting that's causing issues?

    Also, try creating a brand-new account and testing the code on there? Perhaps your click options in your game settings are messed up?



  • Got a quick video of it doing a "lap".
    https://streamable.com/sb7f8



  • Okay, so the big conclusion!

    I feel like this may be totally obvious to most of you but..
    I added the line

    || Bank.isOpen()
    

    to the validate of my banking task and it works like magic now.
    Now that everyone knows how bad I am at scripting I'll be on my way!
    Thanks everyone!!


 

55
Online

16.6k
Users

1.4k
Topics

19.2k
Posts