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.

Shop Interface (just like Bank but then for shops!)

Featured Replies

I think he leaked a trade interface snippet that didn't belong to him

Wow really...

Then he complains I'm a douchebag because apparently I didn't wrote my code... and i used adfly for some of them ...

Well this is really awkward then -_-

 

grtz

H0ppy

i get this error when i try to start script

java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.osbot.script.engine.ScriptManager.startScript(ci:115)
	at org.osbot.xB.run(vg:4)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
	at Shop.isOpen(Shop.java:36)
	at Shop.getAllShopItems(Shop.java:80)
	at Buyer.<init>(Buyer.java:39)
	... 9 more

I've just started to try out some bot programming. I've got a little bit of programming knowledge, but I'm finding it kind of hard to get going. I don't understand how to set up a new shop, or what a script object even is. I tried looking at the API but even that I'm having trouble understanding. If anybody could help explain some of these things to me that would be awesome. 

I've just started to try out some bot programming. I've got a little bit of programming knowledge, but I'm finding it kind of hard to get going. I don't understand how to set up a new shop, or what a script object even is. I tried looking at the API but even that I'm having trouble understanding. If anybody could help explain some of these things to me that would be awesome. 

 

Create a global instance of shop in your script.

 

To do so, place this above your onStart method:

Shop shop = new Shop(this);

 

Here is an example of how you can use the shop after you have have created the global instance:

 

if (shop.isOpen()) {
    ShopItem fireRune = shop.getShopItem(FIRE_RUNE_ID); //FIRE_RUNE_ID is a global int with value of 554
    if (fireRune != null && fireRune.getAmount() > 0) {
        fireRune.buy10();
    }
}

 

I've just started to try out some bot programming. I've got a little bit of programming knowledge, but I'm finding it kind of hard to get going. I don't understand how to set up a new shop, or what a script object even is. I tried looking at the API but even that I'm having trouble understanding. If anybody could help explain some of these things to me that would be awesome. 

 

Create a global instance of shop in your script.

 

To do so, place this above your onStart method:

Shop shop = new Shop(this);

Here is an example of how you can use the shop after you have have created the global instance:

if (shop.isOpen()) {
    ShopItem fireRune = shop.getShopItem(FIRE_RUNE_ID); //FIRE_RUNE_ID is a global int with value of 554
    if (fireRune != null && fireRune.getAmount() > 0) {
        fireRune.buy10();
    }
}

Thank you, this helps a lot, time to start coding :D

 

In my experience, getting the amount from the ShopItem and keeping the item up to date can be a bit tricky depending on connection quality and other performance factors. I personally use the slotId to get the amount of items in the slot using this method:

public int getAmountForSlot(int slotId) throws InterruptedException
{
        return this.scr.client.getInterface(this.parentID).getChild(this.childID).getInvStackSizes()[slotId];
}

This will return the correct data even when shop.isOpen() returns false. I was running into a lot of problems when refreshing ShopItems and they would become null due to what I could only conclude was networking issues. This took care of it nicely.

 

And with this you could also do something like this:

public int getAmountForItemId(int itemId) throws InterruptedException
{		
	ShopItem shopItem = this.getShopItemByID(itemId);
	
	if (shopItem == null)
		return -1;
	
	return this.getAmountForSlot(shopItem.slotID);
}

And actually, because the getShopItemByName and getShopItemByID use the getAllShopItems() which seemed to be somewhat sluggish, I wrote a getShopItemByItemId() method:

public ShopItem getShopItemByItemId(int itemId)
{
    if (this.isOpen())
    {
        Item[] items = this.scr.client.getInterface(this.parentID).getItems(this.childID);
        
        for (int slotId = 0; slotId < items.length; slotId++)
        {
            if (items[slotId].getId() == itemId)
            {
                ShopItem shopItem = new ShopItem(this.scr, slotId);
                shopItem.name = items[slotId].getName();
                shopItem.id = items[slotId].getId();
                shopItem.amount = items[slotId].getAmount();
                return shopItem;
            }
        }
    }
    return null;
}

Edited by bfir3

I'm getting a similar error to one somebody else posted. Does anybody know what this is caused by? I can't seem to find any solution for it.

 

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.osbot.script.engine.ScriptManager.startScript(wh:97)
at org.osbot.yA.run(mo:408)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/merccy/Shop/Shop

I'm getting a similar error to one somebody else posted. Does anybody know what this is caused by? I can't seem to find any solution for it.

java.lang.reflect.InvocationTargetException

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at org.osbot.script.engine.ScriptManager.startScript(wh:97)

at org.osbot.yA.run(mo:408)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.NoClassDefFoundError: com/merccy/Shop/Shop

I got the same thing, it could be on how we've imported those files (shop, and shop item)

I just downloaded the Shop.jar file and used a build path to it. I'm kind of new to this whole thing though so I don't really understand what's going on when I import the files, I just kinda follow the steps :P 

In my experience, getting the amount from the ShopItem and keeping the item up to date can be a bit tricky depending on connection quality and other performance factors. I personally use the slotId to get the amount of items in the slot using this method:

public int getAmountForSlot(int slotId) throws InterruptedException
{
        return this.scr.client.getInterface(this.parentID).getChild(this.childID).getInvStackSizes()[slotId];
}
This will return the correct data even when shop.isOpen() returns false. I was running into a lot of problems when refreshing ShopItems and they would become null due to what I could only conclude was networking issues. This took care of it nicely.

 

And with this you could also do something like this:

public int getAmountForItemId(int itemId) throws InterruptedException
{		
	ShopItem shopItem = this.getShopItemByID(itemId);
	
	if (shopItem == null)
		return -1;
	
	return this.getAmountForSlot(shopItem.slotID);
}

And actually, because the getShopItemByName and getShopItemByID use the getAllShopItems() which seemed to be somewhat sluggish, I wrote a getShopItemByItemId() method:

public ShopItem getShopItemByItemId(int itemId)
{
    if (this.isOpen())
    {
        Item[] items = this.scr.client.getInterface(this.parentID).getItems(this.childID);
        
        for (int slotId = 0; slotId < items.length; slotId++)
        {
            if (items[slotId].getId() == itemId)
            {
                ShopItem shopItem = new ShopItem(this.scr, slotId);
                shopItem.name = items[slotId].getName();
                shopItem.id = items[slotId].getId();
                shopItem.amount = items[slotId].getAmount();
                return shopItem;
            }
        }
    }
    return null;
}

Where would I put this At. Shopitem.java

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.