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 help creating a new dropping method

Featured Replies

Due to the current inbuilt methods being a bit too "botlike", i decided to have a crack and tried to code my own, but introducing common human errors.

 

Here is what I have:

package com.ggplugins.osFisher;

import java.util.ArrayList;

import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.script.Script;

public class Powerfish{
	private Script instance;
	public Powerfish(Script instance){
		this.instance = instance;
	}

	public void clearInventory(ArrayList<Item> safelist) throws InterruptedException{
		for(Item i : instance.inventory.getItems()){
			if(!safelist.contains(i)){
				switch(MethodProvider.random(0, 200)){
				case 25:

					instance.inventory.interact("Examine", i.getName());
					MethodProvider.sleep(MethodProvider.random(300,600));
					instance.inventory.drop(i.getName());
					break;
				case 50:
					instance.inventory.interact("Use", i.getName());
					MethodProvider.sleep(MethodProvider.random(300,600));
					//Deselect item
					instance.inventory.drop(i.getName());
					break;
				default:

					instance.inventory.drop(i.getName());
					break;

				}

				MethodProvider.sleep(MethodProvider.random(350,750));
			}
		}
	}

}

So what happens is, occasionally it will skip items, then it will jump back to them a few drops later, and once it gets down to the last 8 items in the inventory it decides to throw a null pointer on 

instance.inventory.drop(i.getName());

In the default case.

 

So instead of staring at it for another 2 hours, I decided another pair of eyes might just be what I need so I've posted it here.

 

Any help is appreciated, thanks.


private void dropAllExcept(String... names) throws InterruptedException {

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

Item item = sI.inventory.getItemInSlot(i);

if (item != null) {

boolean drop = true;

for (String name : names) {

if (item.getName().equals(name)) {

drop = false;

break;

}

}

if (drop) {

if(sI.getInventory().interact(i, "Drop")) {

MethodProvider.sleep(MethodProvider.gRandom(50, 25));

}

else continue;

}

}

}

}

Edited by Novak

  • Author
private void dropAllExcept(String... names) throws InterruptedException {
        for (int i = 0; i < 28; i++) {
            Item item = sI.inventory.getItemInSlot(i);
            if (item != null) {
                boolean drop = true;
                for (String name : names) {
                    if (item.getName().equals(name)) {
                        drop = false;
                        break;
                    }
                }
                if (drop) {
                    if(sI.getInventory().interact(i, "Drop")) {
                    	MethodProvider.sleep(MethodProvider.gRandom(50, 25));
                }
                    else continue;
                }
            }
        }
    }

This isn't quite the solution I'm looking for, but I will try the use of using inventory slot numbers rather than looping through the items in the inventory. That should help isolate my problem with items being dropped twice.

 

Thanks!

This isn't quite the solution I'm looking for, but I will try the use of using inventory slot numbers rather than looping through the items in the inventory. That should help isolate my problem with items being dropped twice.

 

Thanks!

all you have to do is c+p your switch statement for dropping under the if(drop)

  • Author

all you have to do is c+p your switch statement for dropping under the if(drop)

 Yeah i've pretty much adjusted it now to work with my switch. Testing it now, will post back.

 

@Novak works like a charm mate, thanks

 

Now ive only gotta fix deselecting, which seems to be bugged

Edited by Mykindos

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.