BloodRush20 Posted March 24, 2015 Share Posted March 24, 2015 Hey guys sorry im rushed n looking for a quick answer i have this loop while (this.inventory.contains(new String[] { "Ferret" })){ for (Item fr : inventory.getItems()) { if (fr.getId() == 10092) { fr.interact("Release"); sleep(random(500, 600)); } } } and instead of going to the item it just sits there i tired debugging it but im strapped for time anyone run into this before? Quote Link to comment Share on other sites More sharing options...
Celeos Posted March 24, 2015 Share Posted March 24, 2015 Remove the first line and see if that works. Quote Link to comment Share on other sites More sharing options...
BloodRush20 Posted March 24, 2015 Author Share Posted March 24, 2015 Remove the first line and see if that works. Tired just it before posting and it didnt i added the while loop to see if it wasn't trying to do one and then getting the state again but still nothing Quote Link to comment Share on other sites More sharing options...
GSC Posted March 24, 2015 Share Posted March 24, 2015 Do you get any errors? Check the console. According to the API docs the array returned by getItems() may contain null elements so you should check for that, otherwise your ID check will throw NullPointerException. Quote Link to comment Share on other sites More sharing options...
Twin Posted March 24, 2015 Share Posted March 24, 2015 (edited) if(inventory.contains(10092)//assuming ferret id is 10092 inventory.interact("Release",10092); Not sure if that's what you wanted or not, but I feel ilke that's what I read. so long as you have 10092 in your inventory it will go through this until your dont. Edited March 24, 2015 by twin 763 Quote Link to comment Share on other sites More sharing options...
BloodRush20 Posted March 24, 2015 Author Share Posted March 24, 2015 if(inventory.contains(10092)//assuming ferret id is 10092 inventory.interact("Release",10092); Not sure if that's what you wanted or not, but I feel ilke that's what I read. so long as you have 10092 in your inventory it will go through this until your dont. tired but it freaks out does one then just jumps along the others and is very slow. error is with the fr.getid equalling 10092 and yes using 10092 ids the ferrets inventory id Quote Link to comment Share on other sites More sharing options...
Precise Posted March 24, 2015 Share Posted March 24, 2015 You in need to null check the itemfr in the for loop before checking Id. if(fr != null) Hope this helped Quote Link to comment Share on other sites More sharing options...
Valkyr Posted March 24, 2015 Share Posted March 24, 2015 (edited) The script already runs on a loop, so my modified version of your code should work Hey guys sorry im rushed n looking for a quick answer i have this loop while (this.inventory.contains(new String[] { "Ferret" })){ for (Item fr : inventory.getItems()) { if (fr.getId() == 10092) { fr.interact("Release"); sleep(random(500, 600)); } } } and instead of going to the item it just sits there i tired debugging it but im strapped for time anyone run into this before? for (Item fr : inventory.getItems()) { if (fr.getName().equals("Ferret")) { fr.interact("Release"); sleep(random(500, 600)); } } Edited March 24, 2015 by Valkyr Quote Link to comment Share on other sites More sharing options...
Precise Posted March 24, 2015 Share Posted March 24, 2015 The script already runs on a loop, so my modified version of your code should work for (Item fr : inventory.getItems()) { if (fr.getName().equals("Ferret")) { fr.interact("Release"); sleep(random(500, 600)); } } shouldn't you include a null check on fr? Because he says it is throwing an error where is checks the id which would lead me to believe it is an NPE. I may be wrong Precise Quote Link to comment Share on other sites More sharing options...
BloodRush20 Posted March 25, 2015 Author Share Posted March 25, 2015 The script already runs on a loop, so my modified version of your code should work for (Item fr : inventory.getItems()) { if (fr.getName().equals("Ferret")) { fr.interact("Release"); sleep(random(500, 600)); } } This worked out perfect I kinda had an idea to use the name but i went with id, I see this api is slightly different than i've scrip[ted before but thanks to the community I hope to get the hang of it fast! Thank you Valk shouldn't you include a null check on fr? Because he says it is throwing an error where is checks the id which would lead me to believe it is an NPE. I may be wrong Precise IT wouldn't execute as the condition of state checks for the item before executing Quote Link to comment Share on other sites More sharing options...
Tom Posted March 25, 2015 Share Posted March 25, 2015 (edited) for(int i = 0; i < 28; i ++){ item = instance.inventory.getItemInSlot(i); if(item == null) continue; instance.inventory.interact(i, "Drop"); for(int temp = 0; temp < i; temp ++){ //This part of the method should counter Item tempItem = instance.inventory.getItemInSlot(temp); // items being skipped due to unknown causes, presumably lag. if(tempItem != null)){ MethodProvider.sleep(MethodProvider.random(200,400)); inventory.interact(temp, "Drop"); } } } } You can probably change this around a bit, but what it does is goes back when items are accidentally skipped due to lag, instead of looping through the entire inventory, then checking if there are items left over. Snippet I provided is not very bot like. Just add the ferret check line, and you should be all G Edited March 25, 2015 by Mykindos Quote Link to comment Share on other sites More sharing options...
BloodRush20 Posted March 25, 2015 Author Share Posted March 25, 2015 for(int i = 0; i < 28; i ++){ item = instance.inventory.getItemInSlot(i); if(item == null) continue; instance.inventory.interact(i, "Drop"); for(int temp = 0; temp < i; temp ++){ //This part of the method should counter Item tempItem = instance.inventory.getItemInSlot(temp); // items being skipped due to unknown causes, presumably lag. if(tempItem != null)){ MethodProvider.sleep(MethodProvider.random(200,400)); inventory.interact(temp, "Drop"); } } } } You can probably change this around a bit, but what it does is goes back when items are accidentally skipped due to lag, instead of looping through the entire inventory, then checking if there are items left over. Snippet I provided is not very bot like. Just add the ferret check line, and you should be all G Thanks kindo may need this now because it will jsut randomly stop on items that arent the ferret n sit there haha!!! 1 Quote Link to comment Share on other sites More sharing options...