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.

Custom quick dropping method [Req]

Featured Replies

Hey guys,

I was hoping that somebody is able to provide me/us of a snippet that codes for a fast dropping method. Quicker that the regular one.

Im sorry, im a hopeless coder and want to setup a script that works properly without breaking..

  • Author

Only know how to code in osbot 1 so far

	public void dropAll(Script script, ArrayList<String> exceptionList) throws InterruptedException {
		Item[] i = script.inventory.getItems();
		for (Item inventoryItem : i) {
			if ((exceptionList == null || !exceptionList.contains(inventoryItem.getName())) && Arrays.asList(inventoryItem.getDefinition().getActions()).contains("Drop")) {
				int s = script.inventory.getSlot(inventoryItem);
				Timer failsafe = new Timer();
				while (script.inventory.getSlot(inventoryItem) == s && failsafe.getElapsed() < 5000L) {
					inventoryItem.interact("Drop");
					Script.sleep(Script.random(600, 1200));
				}
			}
			if (script.inventory.isItemSelected()) {
				script.inventory.deselectItem();
			}
		}
	}

Not sure if it's faster considering it relies on the API's interaction method.

  • Author
	public void dropAll(Script script, ArrayList<String> exceptionList) throws InterruptedException {
		Item[] i = script.inventory.getItems();
		for (Item inventoryItem : i) {
			if ((exceptionList == null || !exceptionList.contains(inventoryItem.getName())) && Arrays.asList(inventoryItem.getDefinition().getActions()).contains("Drop")) {
				int s = script.inventory.getSlot(inventoryItem);
				Timer failsafe = new Timer();
				while (script.inventory.getSlot(inventoryItem) == s && failsafe.getElapsed() < 5000L) {
					inventoryItem.interact("Drop");
					Script.sleep(Script.random(600, 1200));
				}
			}
			if (script.inventory.isItemSelected()) {
				script.inventory.deselectItem();
			}
		}
	}

Not sure if it's faster considering it relies on the API's interaction method.

 

Good looking man,

Thanks

Just revisited the class in question:

	public static void wholeInventory(Script script, ArrayList<String> exceptionList, boolean dropCondition) throws InterruptedException {
		if (dropCondition) {
			Item[] i = script.inventory.getItems();
			for (Item inventoryItem : i) {
				if (!dropCondition) {
					break;
				}
				if ((exceptionList == null || !exceptionList.contains(inventoryItem.getName())) && Arrays.asList(inventoryItem.getDefinition().getActions()).contains("Drop")) {
					int s = script.inventory.getSlot(inventoryItem);
					Timer failsafe = new Timer();
					while (script.inventory.getSlot(inventoryItem) == s && failsafe.getElapsed() < 5000L) {
						inventoryItem.interact("Drop");
						Script.sleep(Script.random(600, 1200));
					}
				}
				if (script.inventory.isItemSelected()) {
					script.inventory.deselectItem();
				}
			}
		}
	}

	public static void inventoryItems(Script script, ArrayList<String> itemList, boolean dropCondition) throws InterruptedException {
		if (dropCondition) {
			Item[] i = script.inventory.getItems();
			for (Item inventoryItem : i) {
				if (!dropCondition) {
					break;
				}
				if (itemList != null) {
					if (itemList.contains(inventoryItem.getName()) && Arrays.asList(inventoryItem.getDefinition().getActions()).contains("Drop")) {
						int s = script.inventory.getSlot(inventoryItem);
						Timer failsafe = new Timer();
						while (script.inventory.getSlot(inventoryItem) == s && failsafe.getElapsed() < 5000L) {
							inventoryItem.interact("Drop");
							Script.sleep(Script.random(600, 1200));
						}
					}
				}
				if (script.inventory.isItemSelected()) {
					script.inventory.deselectItem();
				}
			}
		}
	}

You can also change the itemName to drop, to exception if you'd prefer that. Should be fairly easy to change.

	public void dropAll(String itemName) throws InterruptedException {
		Inventory inv = client.getInventory();
		if (inv.contains(itemName)) {
			for (Item item : inv.getItems()) {
				if (item.getName().equalsIgnoreCase(itemName)) {
					MouseDestination slotDestination = new RectangleDestination(
							inv.getDestinationForSlot(inv
									.getSlotForName(itemName)));
					if (client
							.moveMouseTo(slotDestination, false, false, false)) {
						client.clickMouse(true);
						int i = findOption("Drop");
						if (i > 0) {
							if (client.moveMouseTo(new RectangleDestination(
									client.getMenuX(), client.getMenuY() + 5
											+ (i * 15),
									client.getMenuWidth() - 3, 6), false, true,
									false)) {
								sleep(random(150, 300));
							}
						}
					}
				}
			}
		}
	}
	
	public int findOption(String option) {
		int i = 0;
		Iterator<Option> it1 = client.getMenu().iterator();
		while (it1.hasNext()) {
			++i;
			Option temp = it1.next();
			if (temp.action.equalsIgnoreCase(option)) {
				return i;
			}
		}
		return 0;
	}

Edited by Nitrousek


private void dropAll() throws InterruptedException {

        for (int slot = 0; slot < 28; slot++) {

            Item item = client.getInventory().getItems()[slot];

                if (item == null)

                    continue;

                    client.getInventory().interactWithSlot(slot, "Drop");

        }

    }

Edited by Pseudo

  • Author

How would this code differ from osbot 2

Guest
This topic is now closed to further replies.

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.