April 26, 20169 yr 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)); } } }
April 26, 20169 yr 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, 20169 yr by Explv
April 26, 20169 yr 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, 20169 yr by Prozen
April 26, 20169 yr 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.
April 26, 20169 yr 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, 20169 yr by Explv
April 26, 20169 yr 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
April 26, 20169 yr 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.
April 26, 20169 yr Author 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.
April 26, 20169 yr 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, 20169 yr by Explv
April 26, 20169 yr Author 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.
Create an account or sign in to comment