debug Posted April 26, 2016 Share Posted April 26, 2016 I'm not sure why this isn't working, but when it gets to the Drop method it will start from the top and begin dropping, but it will leave the bottom logs, sometimes 1, sometimes 2 and it will keep building up. if (sI.inventory.isFull() && !sI.myPlayer().isAnimating()) { for (Item i : sI.getInventory().getItems()) { if (i != null && i.getName().equals("Logs")) { sI.inventory.dropAll(i.getName()); sleep(random(300, 1200)); } } } Quote Link to comment Share on other sites More sharing options...
Explv Posted April 26, 2016 Share Posted April 26, 2016 (edited) I'm not sure why this isn't working, but when it gets to the Drop method it will start from the top and begin dropping, but it will leave the bottom logs, sometimes 1, sometimes 2 and it will keep building up. if (sI.inventory.isFull() && !sI.myPlayer().isAnimating()) { for (Item i : sI.getInventory().getItems()) { if (i != null && i.getName().equals("Logs")) { sI.inventory.dropAll(i.getName()); sleep(random(300, 1200)); } } } Well your code doesn't make much sense... Why would you call dropAll, a function which DROPS ALL on every single Log in your inventory? It should just be: if (sI.getInventory().isFull()) { sI.getInventory().dropAll("Logs"); } Edited April 26, 2016 by Explv Quote Link to comment Share on other sites More sharing options...
Prozen Posted April 26, 2016 Share Posted April 26, 2016 (edited) Well your code doesn't make much sense... Why would you call dropAll, a function which DROPS ALL on every single Log in your inventory? It should just be: if (sI.getInventory().isFull()) { sI.getInventory().dropAll("Logs"); } What I was wondering aswell. On another note though, I tried it and it works for me. Your method would make somewhat sense if you were making an api, seeing as you didnt pass a variable im assuming thats not the case, i'd use the snippet LoudPacks gave. If you are using it to make a universal method, try this. void dropAll(String itemName) { if(!myPlayer().isAnimating()) { for(Item i : getInventory().getItems()) { if(i.getName() == itemName) i.interact("Drop"); //Would typically be your own drop method here } } } Edited April 26, 2016 by Prozen Quote Link to comment Share on other sites More sharing options...
Psvxe Posted April 26, 2016 Share Posted April 26, 2016 What I was wondering aswell. On another note though, I tried it and it works for me. Your method would make somewhat sense if you were making an api, seeing as you didnt pass a variable im assuming thats not the case, i'd use the snippet LoudPacks gave. If you are using it to make a universal method, try this. void dropAll(String itemName) { if(!myPlayer().isAnimating()) { for(Item i : getInventory().getItems()) { if(i.getName() == itemName) i.interact("Drop"); //Would typically be your own drop method here } } } Why would check within the method if player is animating and only drop if it isn't? Doesn't really make sense to me. Quote Link to comment Share on other sites More sharing options...
Explv Posted April 26, 2016 Share Posted April 26, 2016 (edited) What I was wondering aswell. On another note though, I tried it and it works for me. Your method would make somewhat sense if you were making an api, seeing as you didnt pass a variable im assuming thats not the case, i'd use the snippet LoudPacks gave. If you are using it to make a universal method, try this. void dropAll(String itemName) { if(!myPlayer().isAnimating()) { for(Item i : getInventory().getItems()) { if(i.getName() == itemName) i.interact("Drop"); //Would typically be your own drop method here } } } 1. You should use .equals() when comparing Strings. == Compares references not the values. 2. You should just use: getInventory().dropAll(itemName); 3. The animating check should not be in that method / doesn't really have any use for determining when you should drop items lol Edited April 26, 2016 by Explv Quote Link to comment Share on other sites More sharing options...
progamerz Posted April 26, 2016 Share Posted April 26, 2016 1. You should use .equals() when comparing Strings. == Compares references not the values. 2. You should just use: getInventory().dropAll(itemName); 3. The animating check should not be in that method / doesn't really have any use for determining when you should drop items lol i think he wants to put random sleep time between ech item thats why he is not using that Quote Link to comment Share on other sites More sharing options...
Prozen Posted April 26, 2016 Share Posted April 26, 2016 1. You should use .equals() when comparing Strings. == Compares references not the values. 2. You should just use: getInventory().dropAll(itemName); 3. The animating check should not be in that method / doesn't really have any use for determining when you should drop items lol I said in your own api, if you had your own drop and drop all method (not using osbot's drop method). as for checking if the player is animating yeah true that shouldnt be in the method since you should do the checks before you call the dropAll method. Quote Link to comment Share on other sites More sharing options...
debug Posted April 26, 2016 Author Share Posted April 26, 2016 I managed to fix it so it drops all of the inventory. I was trying to add a random sleep between each drop so it doesn't seem to bot like and fast. Quote Link to comment Share on other sites More sharing options...
Explv Posted April 26, 2016 Share Posted April 26, 2016 (edited) I managed to fix it so it drops all of the inventory. I was trying to add a random sleep between each drop so it doesn't seem to bot like and fast. If you want to add sleeps then you can do something like: private void dropAll(final String name) throws InterruptedException { for(final Item item : getInventory().getItems()){ if(item.getName().equals(name) && item.interact("drop")){ sleep(random(200, 300)); } } } But I am pretty sure that getInventory().dropAll(itemName) already does sleep a random amount from 25ms to 75ms in between drops. Edited April 26, 2016 by Explv Quote Link to comment Share on other sites More sharing options...
debug Posted April 26, 2016 Author Share Posted April 26, 2016 If you want to add sleeps then you can do something like: private void dropAll(final String name) throws InterruptedException { for(final Item item : getInventory().getItems()){ if(item.getName().equals(name) && item.interact("drop")){ sleep(random(200, 300)); } }}But I am pretty sure that getInventory().dropAll(itemName) already does sleep a random amount from 25ms to 75ms in between drops. Thanks, I'll try that. The reason is that I think the dropping is far to fast, and I can't drop items that fast so I was trying to make it delay around a second I will try your method and change the sleep and see if it works. Quote Link to comment Share on other sites More sharing options...