Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Picking up multiple items from the ground


    pakruojinis

    Recommended Posts

    Hello all, recently tried making a script and ran into this error, while trying to pick up more than 1 item from the ground, even with a code like this, it only picks up 1 item and just seems to ignore every other pickup request and continues with the script, it is the same item. 
     

    for (int i = 0; i < 28; i++) {
        if (item != null) {
            item.interact("Take");
        }
    Link to comment
    Share on other sites

    - Show us where you're assigning a value to 'item'.

    - Why are you iterating 28 times?

    - You should be sleeping (dynamically) upon interaction to avoid 'spam clicking'.

    Link to comment
    Share on other sites

     

    21 hours ago, Pseudo said:

    - Show us where you're assigning a value to 'item'.

    - Why are you iterating 28 times?

    - You should be sleeping (dynamically) upon interaction to avoid 'spam clicking'.

    - I get this problem with any item, logs, axes, shields whatever

    - That's how much an inventory can hold 

    - Yes, I have tried it with sleeps, and will use them if I this solved, just didn't bother putting it here, thank you

    Link to comment
    Share on other sites

    2 hours ago, pakruojinis said:

     

    - I get this problem with any item, logs, axes, shields whatever

    - That's how much an inventory can hold 

    - Yes, I have tried it with sleeps, and will use them if I this solved, just didn't bother putting it here, thank you

    Yeah as I said before, can you show your declaration of 'item'?

    Link to comment
    Share on other sites

    I would assume this would be from calling the same ground item instance to keep attempting to pick up. 
    IE once you pick up the first item, that item is no longer on the ground. 
    So say there are 28 donuts on the ground. 
    Once you pick up the first donut, you need to either do another query to grab the next instance or query the list of them to take from and iterate through each element in the list until you successfully pick up 28 items. Although, you really should have it check if your inventory is full. If not, pick up an item and sleep for a small duration or something.  

     

    Link to comment
    Share on other sites

    On 10/5/2021 at 8:19 PM, pakruojinis said:

    Hello all, recently tried making a script and ran into this error, while trying to pick up more than 1 item from the ground, even with a code like this, it only picks up 1 item and just seems to ignore every other pickup request and continues with the script, it is the same item. 
     

    for (int i = 0; i < 28; i++) {
        if (item != null) {
            item.interact("Take");
        }

    i would assume your item variable is not resetting after you pick up the first item , since the following works just fine 

    for (GroundItem groundItem : GroundItems.all()){
        if (groundItem!=null){
            groundItem.interact("Take");
        }
    }
    Link to comment
    Share on other sites

    18 hours ago, Pseudo said:

    Yeah as I said before, can you show your declaration of 'item'?

    GroundItem logs = GroundItems.closest("Logs");
    if (logs != null) {
        for (int i = 0; i < 5; i++) {
            if (logs != null) {
                logs.interact("Take");
            } // changing the logs to anything won't do anything differently
    
    10 hours ago, Koschei said:

    I would assume this would be from calling the same ground item instance to keep attempting to pick up. 
    IE once you pick up the first item, that item is no longer on the ground. 
    So say there are 28 donuts on the ground. 
    Once you pick up the first donut, you need to either do another query to grab the next instance or query the list of them to take from and iterate through each element in the list until you successfully pick up 28 items. Although, you really should have it check if your inventory is full. If not, pick up an item and sleep for a small duration or something.  

     

    This was pretty random for me, I tried checking for the inventory, and it seemed to spam click on it, but because of the delay I could not see if it actually picks up all 5 (I lowered the count for testing), after adding some sleeps it now just clicks once for whatever reason
     

    1 hour ago, Hosfad said:

    i would assume your item variable is not resetting after you pick up the first item , since the following works just fine 

    for (GroundItem groundItem : GroundItems.all()){
        if (groundItem!=null){
            groundItem.interact("Take");
        }
    }

    Could you please post this with any item written into it, I tried it and it just seemed to wanna open random doors and spazz out, here's what I tried. I appreaciate you all helping me :)

    for (GroundItem Logs : GroundItems.all()){
        if (Logs!=null){
            Logs.interact("Take");
        }
    }
    Link to comment
    Share on other sites

    I use the follow code for an area around me:

    itemsOnGround = GroundItems.all();
    for (GroundItem i : itemsOnGround) {
        if(lootArea.contains(i)){
            if (itemsToPickup.contains(i.getName())) {
            MethodProvider.log("found a match to loot list");
            i.interact("Take");
        }
        }
    }

    Area is around me, and the itemsToPickup is a list of items.  Updated to remove my food dropper

     

    3 weeks later that's fine but sleep until inventory listener so you can know when you pick it up.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.