H0ppy Posted July 12, 2013 Share Posted July 12, 2013 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 1 Link to comment Share on other sites More sharing options...
Joseph Posted July 17, 2013 Share Posted July 17, 2013 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 Link to comment Share on other sites More sharing options...
ohhungry Posted July 18, 2013 Share Posted July 18, 2013 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. Link to comment Share on other sites More sharing options...
SpanishFly Posted July 18, 2013 Share Posted July 18, 2013 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(); } } 1 Link to comment Share on other sites More sharing options...
ohhungry Posted July 18, 2013 Share Posted July 18, 2013 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 Link to comment Share on other sites More sharing options...
bfir3 Posted July 19, 2013 Share Posted July 19, 2013 (edited) 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 July 19, 2013 by bfir3 Link to comment Share on other sites More sharing options...
ohhungry Posted July 21, 2013 Share Posted July 21, 2013 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 Link to comment Share on other sites More sharing options...
Joseph Posted July 21, 2013 Share Posted July 21, 2013 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) Link to comment Share on other sites More sharing options...
ohhungry Posted July 21, 2013 Share Posted July 21, 2013 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 Link to comment Share on other sites More sharing options...
danbancroft Posted July 21, 2013 Share Posted July 21, 2013 good work Link to comment Share on other sites More sharing options...
Joseph Posted July 26, 2013 Share Posted July 26, 2013 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 Link to comment Share on other sites More sharing options...