Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Buy OSRS Gold

Sell OSRS Gold
im4ever12c

Looting items at specific XYZ

Recommended Posts

Currently trying to create a script to only collect my loot from the ground. I'm having one little issue with this block of code:

I'm currently just trying to make it to where magnetPosition is recorded, item id 526 is collected.

 

Magnet position being the XYZ where the attacked monster was killed.

Item ID 526 being Bones.

Spoiler

    public void gatherItemCollection() {
        if (isInCombat() != true) {
            RSGroundItem[] itemsOnGround = GroundItems.getAt(magnetPosition);
            if (itemsOnGround.length > 0) {
                for (RSGroundItem item : GroundItems.getAt(magnetPosition.getX(), magnetPosition.getY(),
                        magnetPosition.getPlane(), ((Filters.GroundItems.idEquals(526))))) {
                    if (item != null && item.getID() == 526) {
                        DynamicClicking.clickRSGroundItem(item, "Take");
                        sleep(640, 1075);
                    }
                }
            }
        }
    }

 

Everything works if i remove this section, but then it tries to collect every item in a pile, regardless of item ID.
 

Spoiler

 

 for (RSGroundItem item : GroundItems.getAt(magnetPosition.getX(), magnetPosition.getY(),
                        magnetPosition.getPlane(), ((Filters.GroundItems.idEquals(526))))) {

// Do Something

}

 

 

Am I using filters wrong? Or does anyone see another issue going on?

I'm not getting any errors. The script does not execute anything within that argument.

Edited by im4ever12c

Share this post


Link to post
Share on other sites
RSGroundItem[] itemsOnGround = GroundItems.findNearest((526));


if (!Player.getRSPlayer().isInCombat()){
    if (itemsOnGround.length > 0){
        if (itemsOnGround[0].click("Take -> item name")){
            Timing.waitCondition(() -> {
                General.sleep(500);
                return Player.getPosition().equals(itemsOnGround[0].getPosition());
            }, General.random(7000, 8000));
        }
    }

}

 

this will search for the item with id 526 then click take then wait till the player tile is the same as the item 

Edited by testing1
updated as fals said down there

Share this post


Link to post
Share on other sites

The problem is that you are clicking "Take" and it is clicking the first option that starts with "Take" which is top item on the stack.  You should grab the item definition to get the name of the item, so you can then click: "Take " + itemName. If you know which item you are trying to click beforehand, you can hardcode it as "Take Magnet" or whatever you're trying to take.

You can also check the RSMenuNodes from the ChooseOption class to check which specific option pertains to which specific RSGroundItem, which can be useful in some situations

Share this post


Link to post
Share on other sites
1 hour ago, FALSkills said:

The problem is that you are clicking "Take" and it is clicking the first option that starts with "Take" which is top item on the stack

"Take"

For example, "Take advantage of the poor stray dog in Varrock that has nobody to help him against animal cruelty".

 

Share this post


Link to post
Share on other sites

Exactly what the others have said. The code should be something like this,

if (itemsOnGround[0].click("Take " + itemsOnGround[0].getDefinition().getID())) { 
  // or if you change it from ID to the name of the item, change the "getID()" 
  //to "getName()"

 

Edited by flamekiller999

Share this post


Link to post
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.
Note: Your post will require moderator approval before it will be visible.

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.


  • Our picks

    • Over the past few months, I’ve been working diligently on a new project - TRiBot X. Everything has been written from the ground up, with all of the best practices of software engineering. Every aspect of TRiBot has been re-imagined to support three main goals: flexibility, useability, and reliability.
        • Like
      • 31 replies
    • Come give us feedback on the next version of TRiBot!
        • Thanks
        • Like
      • 74 replies
    • TRiBot is looking to improve a lot of its customer relationship management, customer on boarding process, customer experience, design elements, community engagement and pretty much everything else you can imagine when it comes to marketing.

      Our goal: To ensure that the marketing done TRULY reflects the experience and does not shine an inaccurate light on what TRiBot is lacking in.

      So I ask, what do you love about TRiBot and what do you hate about TRiBot? What does O S Bot, Rune M8, PowR Bot and Dre amBot do better? (yes I purposely didn't spell it right 😂).

      Love, 

      RileyZ
        • Like
      • 23 replies
    • Over the last three weeks, I've been working on upgrading our server infrastructure. It's finally ready and is now live!

      Why?

      Increased reliability - less server errors


      Increased availability - less downtime


      Increased security - keeping us and you secure


      Increased capacity - ability to serve you better


      Increased speed - less waiting for things to load


      Faster development - server and service updates will come faster


      What are the changes?

      Move from a single AWS EC2 instance to AWS ECS (Elastic Container Service)


      Distributed computing


      Load balancing


      Git management of server files and filesystem


      Redis caching


      How?

      AWS ECS (with 10 EC2 instances)


      AWS ElastiCache (Redis)


      AWS Load Balancing


      AWS EFS (Elastic file system)


      Please bare with us as I continue to tune the server for maximum performance. Slow loading speeds may occur temporarily. I thank everyone for their patience.

      Please post on this thread if you experience any issues other than slow loading times.
        • Like
      • 51 replies
    • This release will:

      Fix prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)


      Improve banking API (Thanks @Encoded)


      Adds methods for returning and using Java Lists, rather than arrays


      Slightly randomizes some hardcoded behaviour


      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable


      Other back-end improvements





      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Sad
        • Haha
        • Thanks
        • Like
      • 90 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...