Guest Apogee Posted May 2, 2014 Posted May 2, 2014 When picking this item up, there's no game message. So therefor, i can't use onMessage. (I feel this is the most reliable way of adding info to paint.) When i pick the item up, the script sometimes miss clicks and adds +1 to int "looted" anyways. supersecretitem.interact("Take"); looted++; This is what i have now. So my question to you is: What is a way that i can accurately detect when this item is picked up? I thought about getting the current count in the inventory then when it enters the inventory it looted++'s but i couldn't figure it out. Any help is appreciate. Looking to learn.
Precise Posted May 2, 2014 Posted May 2, 2014 get inventory count before and compare to after, if it is greater, looted ++ or (difference between inventory count before and after).
Guest Apogee Posted May 2, 2014 Posted May 2, 2014 get inventory count before and compare to after, if it is greater, looted ++ or (difference between inventory count before and after). Like i said, i tried this method. I ended up with like 5 ints and super confused. An example, if you have one, would be appreciated.
Precise Posted May 2, 2014 Posted May 2, 2014 (edited) this may work though i have not tested but it is something to work with. long loot = 0; long before = client.getInventory().getAmount("ITEM_NAME"); loot.interact("LOOT"); long after = client.getInventory().getAmount("ITEM_NAME"); if(after > before) { loot += (after-before); } Edited May 2, 2014 by precise
Ande Posted May 2, 2014 Posted May 2, 2014 (edited) Something like this would work I think long amount = client.getInventory().getAmount("Item"); item.interact("Take"); sleep(500); while(myPlayer().isMoving()){ sleep(50); } sleep(500); if(amount != client.getInventory().getAmount("Item")){ itemsLooted++; } Yeah basically the same as above... Edited May 2, 2014 by Ande
Deffiliate Posted May 2, 2014 Posted May 2, 2014 I've actually got a pretty cool custom class for handling loot tracking + Zybez price integration if u want it. :3 1
Dreamliner Posted May 2, 2014 Posted May 2, 2014 (edited) public ItemWatcher watcher = null; public Thread wt = null; public void onStart() { this.watcher = new ItemWatcher(this); this.wt = new Thread(this.watcher); this.wt.start(); } public int onLoop() { System.out.println(this.watcher.getCollected()); return 600; } public void onExit() { this.watcher.kill(); } ItemWatcher.java public class ItemWatcher implements Runnable { private Script s; private int start_item = 0; private int item_now = 0; private int collected_items = 0; private int item = 1337; private boolean run = true; public ItemWatcher(Script s) { this.s = s; this.start_item = s.client.getInventory().getAmount(item); } public void run() { while (run) { this.items_now = s.client.getInventory().getAmount(item); if (items_now > start_item) { this.collected_items += (items_now - start_item); this.start_item = items_now; } Thread.sleep(600); } } public void kill() { this.run = false; } public int getCollected() { return collected_items; } } ignore any typos, it was done in the osbot reply Edited May 2, 2014 by dreamliner