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
  • Basic banking snippet


    crazykid080

    Recommended Posts

    I'm not 100% sure this works with how it acts when in the banking state but I want to share it and ask if I'm doing something wrong. For this I'm using the lumbridge bank at the top of the stairs.

     

    case BANKING:
    			while (bankArea.contains(Players.localPlayer().getTile())) {
    				Walking.walk(bankArea.getRandomTile());
    				sleepUntil(new Condition() {
    
    					@Override
    					public boolean verify() {
    						return Players.localPlayer().isMoving();
    					}
    				}, 3000);
    			}
    			Bank.openClosest();
    			sleepUntil(new Condition() {
    
    				@Override
    				public boolean verify() {
    					return Bank.isOpen();
    				}
    			}, 1000);
    			Bank.depositAllItems();
    			Bank.close();
    			Walking.walk(stairsTile);
    			Walking.walk(workingArea.getRandomTile());
    			return Calculations.random(300, 600);

    And to decide to bank is simply a Inventory.isFull() check.

    I probably haven't done something correctly and that's part of why I'm posting it. Please let me know what I'm doing wrong (constructively) so I can improve this and learn more

    Link to comment
    Share on other sites

    the walking always has to be looped. You can't just call Walking.walk once and expect it to get there. This is to allow u ur own loop implementation (think wildy walking). You might be able to turn lots of these into lambdas. Should have a sleep between bank deposit and close i think. Also u want to walk to the bank if it doesn't contain the player. Right now u are walking if it does.

    Link to comment
    Share on other sites

    I would stay away from using while loops, it makes stopping script hard, and can cause scripts to get stuck if you don't have a fail safe implemented.

    A script is already a loop, with your while loop you are limiting what you can do as the while loop will keep going until the player is in the banking area, what happens if the player never gets there?

    I would structure is that as;

    - Check to see if the player is in the bank area,

        - If not should I walk to the next tile in the path to the bank? (Hint, look at Walking#shouldWalk())

            - If I should, walk to the next tile

    - Else if the player is in the bank are

        - Open Bank, etc.

     

    Even then I would split that case up to multiple cases, one for walking to the bank, one for opening the bank, one for depositing items, one for withdrawing items. That will make the script a bit more reliable overall, and make troubleshooting a little bit eaiser.

    Link to comment
    Share on other sites

    21 minutes ago, LordJashin32 said:

     Also u want to walk to the bank if it doesn't contain the player. Right now u are walking if it does.

    Shoot. Well that explains the weird behavior that looked like it was indecisive about what it wanted to do!

     

    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.