Jump to content
BloodRush20

Help with looping inventory

Recommended Posts

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?

Link to comment
Share on other sites

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 by twin 763
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by Valkyr
Link to comment
Share on other sites

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

Link to comment
Share on other sites

 

The script already runs on a loop, so my modified version of your code should work smile.png

                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 smile.png

Precise

IT wouldn't execute as the condition of state checks for  the item before executing

Link to comment
Share on other sites

 
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 by Mykindos
Link to comment
Share on other sites

 
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!!!

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...