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.

Need someone to give feedback

Featured Replies

I wrote a constructor for banking. I need one because the script i'm going to write requires a lot of banking. I just need someone to give me feedback because it is really messy. I'm also not that advanced in Java so the way I wrote it is probably really basic. 

 

Spoiler

	public Banking(Script sI, int depositMode, String[] depositFilter, String item1, int quantity1, BankMode mode1, String item2, int quantity2, BankMode mode2) throws InterruptedException {
		
		if(!sI.getBank().isOpen()) {
			sI.getBank().open();
			
			new ConditionalSleep(2000) {
				
				@Override
				public boolean condition() throws InterruptedException {
					return sI.getBank().isOpen();
				}
			}.sleep();
		} else {
			if(depositMode == 1) {
				sI.getBank().depositAll();
				new ConditionalSleep(2000) {
					
					@Override
					public boolean condition() throws InterruptedException {
						return sI.getInventory().isEmpty();
					}
				}.sleep();
			} else if (depositMode == 2){
				sI.getBank().depositAllExcept(depositFilter);
				new ConditionalSleep(2000) {
					
					@Override
					public boolean condition() throws InterruptedException {
						return !sI.getInventory().contains(depositFilter);
					}
				}.sleep();
			}
			
			if(item1 != null) {
				if(sI.getBank().contains(item1)) {
				if(!sI.getBank().getWithdrawMode().equals(mode1)) {
					sI.getBank().enableMode(mode1);
					new ConditionalSleep(2000) {
						
						@Override
						public boolean condition() throws InterruptedException {
							return sI.getBank().getWithdrawMode().equals(mode1);
						}
					}.sleep();
				}
				if(quantity1 > 0) {
				sI.getBank().withdraw(item1, quantity1);
				new ConditionalSleep(2000) {
					
					@Override
					public boolean condition() throws InterruptedException {
						return sI.getInventory().contains(item1);
					}
				}.sleep();	
				} else {
					sI.getBank().withdrawAll(item1);
					new ConditionalSleep(2000) {
						
						@Override
						public boolean condition() throws InterruptedException {
							return sI.getInventory().contains(item1);
						}
					}.sleep();
				}
			} else {
				sI.log("The bank is missing: " + item1);
			}
			}
			
			if(item2 != null) {
				if(sI.getBank().contains(item2)) {
				if(!sI.getBank().getWithdrawMode().equals(mode2)) {
					sI.getBank().enableMode(mode2);
					new ConditionalSleep(2000) {
						
						@Override
						public boolean condition() throws InterruptedException {
							return sI.getBank().getWithdrawMode().equals(mode2);
						}
					}.sleep();
				}
				if(quantity2 > 0) {
				sI.getBank().withdraw(item2, quantity2);
				new ConditionalSleep(2000) {
					
					@Override
					public boolean condition() throws InterruptedException {
						return sI.getInventory().contains(item2);
					}
				}.sleep();	
				} else {
					sI.getBank().withdrawAll(item2);
					new ConditionalSleep(2000) {
						
						@Override
						public boolean condition() throws InterruptedException {
							return sI.getInventory().contains(item2);
						}
					}.sleep();
				}
			} else {
				sI.log("The bank is missing: " + item2);
			}
			}
			
			if(sI.getBank().isOpen()) {
				sI.getBank().close();
				new ConditionalSleep(2000) {
					
					@Override
					public boolean condition() throws InterruptedException {
						return !sI.getBank().isOpen();
					}
				}.sleep();
			}
		}
		
	}

 

 

I'd start by making a banking class, breaking down each type of interaction with the bank. For example I'd have a method for both withdrawing and depositing - that's a good start.

Here's a quick example I use for withdrawing items from the bank on a script I'm currently working on:

MethodProvider api;
Area bank;
Settings settings; // Custom class - not part of the api

public void withdraw(HashMap<String, Integer> items) throws InterruptedException {
      if (!bank.contains(api.myPosition())) {
          api.getWalking().webWalk(bank);
      } else {
          if (!api.getBank().isOpen()) {
              if (api.getBank().open()) {
                  Sleep.sleepUntil(() -> api.getBank().isOpen(), 5000);
              }
          } else {
              for(Map.Entry<String, Integer> entry : items.entrySet()) {
                  String key = entry.getKey();
                  Integer amount = entry.getValue();
                  if (api.getBank().getAmount(key) >= amount) {
                      if (api.getBank().withdraw(key, amount)) {
                          Sleep.sleepUntil(() -> api.getInventory().getAmount(key) == amount, 5000);
                      }
                  } else {
                      settings.setQuit(true);
                  }
              }
          }
      }
  }

 

Edited by Ragnar Lothbrok

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.