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 some help

Featured Replies

Im trying to make the piece of script to sell all the clean herbs i have in my inventory. I have an enum with all the herbs data. I've been trying to do it with a for loop but for some reason it doesn't work. If anyone could help me out that would be great

 

Quote

for(Herbs h : Herbs.values()) {
                if(mp.getInventory().contains(h.cleanName)) {
                    if(mp.getGrandExchange().sellItem(h.cleanId, h.getCleanHerbPrice(), (int) mp.getInventory().getAmount(h.cleanName))) new ConditionalSleep(5000) {
                        
                        @Override
                        public boolean condition() throws InterruptedException {
                            return !mp.getGrandExchange().isOfferScreenOpen();
                        }
                    }.sleep();
                }
            }

 

MethodProvider

You've got a variable for what I assume is the MethodProvider. You need to make sure that, before you use it, you call:

mp.exchangeContext(bot)

With the "bot" being passed in from the script.

 

Herb enum

Can you post your enum code? On the one hand, you have:

h.getCleanHerbPrice()

But on the other hand you're also doing:

h.cleanName
h.cleanId

So it would be good to check to make sure you're calling stuff correctly.

 

Script loop v.s. for-loop

Your script already loops over and over again. It's safer to pick one herb per loop cycle and to just deal with that. That way, you avoid problems like having the bot try to drop a bunch of items in one go, only to then end up trying to drop an item that no longer exists.

Look up the api, it says that you just specify an amount, no need to loop over them. That way you just sell one at a time.

Also I would say change the if statement that checks if the inventory contains a clean herb and just do an inverse in the bank. So if the bank does not contain anymore dirty herbs, then widthdraw all clean herbs as noted, get the noted id for the herbs and sell them on the GE.

I can give more specfic code examples if you need more help. :) 

  • Author
15 minutes ago, liverare said:

Can you post your enum code? On the one hand, you have

This is the enum im using. It uses a snippet to gather the prices for the items

 

Quote

public enum Herbs {

    GUAM_LEAF("Guam leaf", 3, 199, 249),
    MARRENTILL("Marrentill" , 5, 201, 251),
    TARROMIN ("Tarromin", 11, 203, 253),
    HARRALANDER ("Harralander", 20, 205, 255),
    RANARR_WEED ("Ranarr weed", 25, 207, 257),
    TOADFLAX ("Toadflax", 30, 3049, 2998),
    IRIT_LEAF ("Irit leaf", 40, 209, 259),
    AVANTOE ("Avantoe", 48, 211, 261),
    KWUARM ("Kwuarm", 54, 213, 263),
    SNAPDRAGON ("Snapdragon", 59, 3051, 3000),
    CADANTINE ("Cadantine", 65, 215, 265),
    LANTADYME ("Lantadyme", 67, 2485, 2481),
    DWARF_WEED ("Dwarf weed", 70, 217, 267),
    TORSTOL ("Torstol", 75, 219, 269);
    
    public String grimyName;
    public String cleanName;
    public int margin;
    public int lvl;
    public int grimyId;
    public int cleanId;
    
    Herbs(String herbName, int lvl, int grimy, int clean) {
        grimyName = "Grimy " + herbName.toLowerCase();
        cleanName = herbName;
        this.lvl = lvl;
        margin = getCleanHerbPrice() - getGrimyHerbPrice();
        grimyId = grimy;
        cleanId = clean;
    }
    
    public int getGrimyHerbPrice() {
        int price = 0;
        
        try {
            price = Math.max(ItemLookup.get(grimyName, Property.BUY_AVERAGE).map(Integer::parseInt).get(), ItemLookup.get(grimyName, Property.SELL_AVERAGE).map(Integer::parseInt).get());
        } catch (Exception e) {
            price = -1;
        }
        return price;
    }
    
    public int getCleanHerbPrice() {
        int price = 0;
        
        try {
            price = Math.min(ItemLookup.get(cleanName, Property.BUY_AVERAGE).map(Integer::parseInt).get(), ItemLookup.get(cleanName, Property.SELL_AVERAGE).map(Integer::parseInt).get());
        } catch (Exception e) {
            price = -1;
        }
        return price;
    }
    
}

 

Use a dynamic snippet instead so that you don't hardcode the prices.

3 hours ago, MarWo22 said:

This is the enum im using. It uses a snippet to gather the prices for the items

Okay, so the enum isn't the problem. :)

What about exchanging the bot context with the MethodProvider?

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.