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.

Struggeling with GE prices

Featured Replies

I'm using this snippet for getting the prices of items from Osbot

Spoiler

public class GrandExchange {

	private static final String BASE = "https://api.rsbuddy.com/grandExchange?a=guidePrice&i=";

	/**
	 * Default Constructor
	 * 
	 */
	public GrandExchange() {

	}
	
	/**
	 * Gets the overall price of an item.
	 * 
	 * @param itemID
	 * @return itemPrice
	 * @throws IOException
	 */
	public static int getOverallPrice(final int itemID) throws IOException {
		return parse(itemID,"overall");
	}

	
	/**
	 * Gets the buying price of an item.
	 * 
	 * @param itemID
	 * @return itemPrice
	 * @throws IOException
	 */
	public static int getBuyingPrice(final int itemID) throws IOException {
		return parse(itemID,"buying");
	}
	

	public static int getSellingPrice(final int itemID) throws IOException {
		return parse(itemID,"selling");
	}


	/**
	 * Retrieves the price of an item.
	 * 
	 * @param itemID
	 * @return itemPrice
	 * @throws IOException
	 */
	private static int parse(final int itemID, String choice) throws IOException {
		final URL url = new URL(BASE + itemID);
		BufferedReader file = new BufferedReader(new InputStreamReader(url.openStream()));
		String line;
		String price = null;
		while ((line = file.readLine()) != null) {
			if (line.contains("{")) {
				price = (line).trim();
			}
		}
		if (choice.equals("buying")){
			price = price.substring(price.indexOf(",") + 10, nthOccurrence(price, ',', 1)).trim();
		} else if(choice.equals("selling")) {
			price = price.substring(nthOccurrence(price, ',', 2)  + 11 , price.indexOf("sellingQuantity") - 2).trim();
		} else {
			price = price.substring(price.indexOf(":") + 1, price.indexOf(",")).trim();
		}
		file.close();
		return Integer.parseInt(price);
	}

	private static int nthOccurrence(String str, char c, int n) {
		int pos = str.indexOf(c, 0);
		while (n-- > 0 && pos != -1)
			pos = str.indexOf(c, pos + 1);
		return pos;
	}

}

 

Im trying to get the best margin of making the potions. So i came up with this. But because of the IOexception in the snippet it doesnt work. Can someone please help me how to fix this? Im still a beginner at scripting and java.

Spoiler

public enum Potion {
        IRIT(259, 101),
        TOADFLAX(2998, 3002),
        AVENTOE(261, 103),
        KWUARM(263, 105),
        CANDENTINE(265, 107),
        LANTADYME(2481, 2483);

        public final int HerbPrice;
        public final int Margin;
        public final int UnfinishedPrice;
        public final String Name;
        public final int HerbId;
        public final int UnfinishedId;
        private final String UnfinishedName;

        Potion(int herbId, int unfinishedId) throws IOException {
            Name = name().substring(0,1).toUpperCase() + name().substring(1).toLowerCase();
            UnfinishedName = Name + " potion (unf)";
            HerbId = herbId;
            UnfinishedId = unfinishedId;
			HerbPrice = Math.max(GrandExchange.getSellingPrice(herbId), GrandExchange.getBuyingPrice(herbId));
			UnfinishedPrice = Math.min(GrandExchange.getSellingPrice(unfinishedId), GrandExchange.getBuyingPrice(UnfinishedId));
            Margin = UnfinishedPrice - HerbPrice;
        }
    }

 

 

Please copy the NPE you got and note which line it came from.

 

Edited by Canidae

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.