Jump to content

Some banking methods


Swizzbeat

Recommended Posts

The OSBot methods are slow and unreliable so I wrote my own. Thanks to @TheScrub for cluing me in on what interface in the bank had the items! smile.png

public boolean bankContains(int item) {
	for (Item i : sI.client.getInterface(12).getItems(6)) {
		if (i != null && i.getId() == item) {
			return true;
		}
	}
	return false;
}

public boolean bankContains(String item) {
	for (Item i : sI.client.getInterface(12).getItems(6)) {
		if (i != null && i.getName().equalsIgnoreCase(item.toLowerCase())) {
			return true;
		}
	}
	return false;
}

public boolean rightClickBankItem(int item) throws InterruptedException {
	if (!bankContains(item)) {
		return false;
	}
	int slot = sI.client.getBank().getSlotForId(item);
	if (!sI.client.getBank().isSlotVisible(slot)) {
		sI.client.getBank().scrollToSlot(slot);
	}
	Rectangle rect = sI.client.getBank().getAbsoluteSlotPosition(slot);
	sI.client.moveMouseTo(new RectangleDestination((int) rect.getX(), (int) rect.getY(), (int) rect.getWidth(), (int) rect.getHeight()), false, true, true);
	return sI.client.isMenuOpen();
}

public boolean rightClickBankItem(String item) throws InterruptedException {
	if (!bankContains(item)) {
		return false;
	}
	int slot = sI.client.getBank().getSlotForId(sI.client.getBank().getItemForName(item).getId());
	if (!sI.client.getBank().isSlotVisible(slot)) {
		sI.client.getBank().scrollToSlot(slot);
	}
	Rectangle rect = sI.client.getBank().getAbsoluteSlotPosition(slot);
	sI.client.moveMouseTo(new RectangleDestination((int) rect.getX(), (int) rect.getY(), (int) rect.getWidth(), (int) rect.getHeight()), false, true, true);
	return sI.client.isMenuOpen();
}

public boolean selectOpenMenuOption(String option) throws InterruptedException {
	if (sI.client.isMenuOpen()) {
		List<Option> options = sI.client.getMenu();
		for (int i= 0; i < options.size(); i++) {
			if (options.get(i).action.equalsIgnoreCase(option.toLowerCase())) {
				return sI.client.moveMouse(new RectangleDestination(sI.client.getMenuX(), sI.client.getMenuY()+19+(i*15), sI.client.getMenuWidth(), 15), false);
			}
		}
	}
	return false;
}

public boolean withdraw(int id, int amount) throws InterruptedException {
	if (!bankContains(id)) {
		return false;
	}
	if (rightClickBankItem(id)) {
		if (sI.client.isMenuOpen()) {
			List<Option> options = sI.client.getMenu();
			for (int i= 0; i < options.size(); i++) {
				if (options.get(i).action.equalsIgnoreCase("withdraw-" + amount)) {
					return sI.client.moveMouse(new RectangleDestination(sI.client.getMenuX(), sI.client.getMenuY()+19+(i*15), sI.client.getMenuWidth(), 15), false);
				}
				else if (options.get(i).action.equalsIgnoreCase("withdraw-x")) {
					sI.client.moveMouseTo(new RectangleDestination(sI.client.getMenuX(), sI.client.getMenuY()+21+i*14, sI.client.getMenuWidth(), 10), false, true, false);
					sI.sleep(MethodProvider.random(615, 963));
					sI.client.typeString(Integer.toString(amount));
					return true;
				}
			}
		}
	}
	return false;
}

public boolean withdraw(String name, int amount) throws InterruptedException {
	if (!bankContains(name)) {
		return false;
	}
	if (rightClickBankItem(name)) {
		if (sI.client.isMenuOpen()) {
			List<Option> options = sI.client.getMenu();
			for (int i= 0; i < options.size(); i++) {
				if (options.get(i).action.equalsIgnoreCase("withdraw-" + amount)) {
					return sI.client.moveMouseTo(new RectangleDestination(sI.client.getMenuX(), sI.client.getMenuY()+21+i*14, sI.client.getMenuWidth(), 10), false, true, false);
				}
				else if (options.get(i).action.equalsIgnoreCase("withdraw-x")) {
					sI.client.moveMouse(new RectangleDestination(sI.client.getMenuX(), sI.client.getMenuY()+19+(i*15), sI.client.getMenuWidth(), 15), false);
					sI.sleep(MethodProvider.random(615, 963));
					sI.client.typeString(Integer.toString(amount));
					return true;
				}
			}
		}
	}
	return false;
}
Edited by Swizzbeat
  • Like 3
Link to comment
Share on other sites

Hmm let me try tongue.png I'll tell you. Could be that I'm just withdrawing too many items too

You might get a bug where it will miss-click the option, I have that fixed in the local version I'm using but still have to update the one here :p it's just a small miscalculation of the option rectangle.

Link to comment
Share on other sites

2 things,

1. You need to use absoluteSlotPosition

2. It withdraws stuff really fast tongue.png

 

 

But anyways thanks for this! Used this as a base for my own bank api tongue.png

Yeah I changed that in my local version! But the mouse destination in this snippet is actually wrong and will missclick sometimes, here's the updated one:

sI.client.moveMouse(new RectangleDestination(sI.client.getMenuX(), sI.client.getMenuY()+19+(i*15), sI.client.getMenuWidth(), 15), false);
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...