March 24, 201510 yr 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?
March 24, 201510 yr Author 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
March 24, 201510 yr 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.
March 24, 201510 yr 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, 201510 yr by twin 763
March 24, 201510 yr Author 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
March 24, 201510 yr You in need to null check the itemfr in the for loop before checking Id. if(fr != null) Hope this helped
March 24, 201510 yr 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, 201510 yr by Valkyr
March 24, 201510 yr 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
March 25, 201510 yr Author 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
March 25, 201510 yr 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, 201510 yr by Mykindos
March 25, 201510 yr Author 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!!!
Create an account or sign in to comment