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
  • getItem() pick a item?


    maferosrs

    Recommended Posts

    i Guys, I'm reading the API documentation, is there a method for picking up the floor items? What class do you belong to?Hi Guys, I'm reading the API documentation, is there a method for picking up the floor items? What class do you belon

    Link to comment
    Share on other sites

    ty ty ty
     

     

    this is correct ?

    public class Main extends AbstractScript {
    
        public GroundItem pickThisItems[] = {"Bones" , "Coins"};
    
        @Override
        public int onLoop() {
    
            getGroundItems(pickThisItems);
            return 100;
        }
    }
    Link to comment
    Share on other sites

     

    ty ty ty

     

     

    this is correct ?

    public class Main extends AbstractScript {
    
        public GroundItem pickThisItems[] = {"Bones" , "Coins"};
    
        @Override
        public int onLoop() {
    
            getGroundItems(pickThisItems);
            return 100;
        }
    }

    no.

    Link to comment
    Share on other sites

     

    ty ty ty

     

     

    this is correct ?

    public class Main extends AbstractScript {
    
        public GroundItem pickThisItems[] = {"Bones" , "Coins"};
    
        @Override
        public int onLoop() {
    
            getGroundItems(pickThisItems);
            return 100;
        }
    }

     

    Try this:

    public class Main extends AbstractScript {
    
      GroundItem coins = getGroundItems().closest(c -> c != null && c.getName().equals("Coins")); //this filter will look for ground items that are not null and have the name "Coins"
    
      @Override
      public int onLoop() {
      if (coins != null)
        coins.interact("Pick up"); //I'm not sure if that text is right, make sure the text matches the in-game text for hovering over a ground item. Also, you might want to make sure the coins are on-screen.
      return 100;
      }
    }
    
    Link to comment
    Share on other sites

     

    Try this:

    public class Main extends AbstractScript {
    
      GroundItem coins = getGroundItems().closest(c -> c != null && c.getName().equals("Coins")); //this filter will look for ground items that are not null and have the name "Coins"
    
      @Override
      public int onLoop() {
      if (coins != null)
        coins.interact("Pick up"); //I'm not sure if that text is right, make sure the text matches the in-game text for hovering over a ground item. Also, you might want to make sure the coins are on-screen.
      return 100;
      }
    }
    

    ty ty 

    package Main;
    
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.wrappers.items.GroundItem;
    
    import java.awt.*;
    
    @SuppressWarnings("ALL")
    @ScriptManifest(
            author = "Mafer",
            name = "My First Script Pick",
            version = 1.0,
            description = "Pick Items",
            category = Category.MONEYMAKING)
    
    public class Main extends AbstractScript {
    
        int c1 = 0;
    
        GroundItem itemBones = getGroundItems().closest("Bones");
    
        @Override
        public int onLoop() {
            if (itemBones.isOnScreen() && itemBones != null ){
                itemBones.interact("Take");
                        c1++;
            }
            return 100;
        }
    
        @Override
        public void onPaint(Graphics g) {
            g.setFont(new Font("Arial", Font.PLAIN,14));
            // Text In Screeen
            g.drawString("Bones Takes: " + c1, 20, 60);
        }
    }
    

    What about now? But does not start the script because?

    Link to comment
    Share on other sites

    ty ty 

    package Main;
    
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.wrappers.items.GroundItem;
    
    import java.awt.*;
    
    @SuppressWarnings("ALL")
    @ScriptManifest(
            author = "Mafer",
            name = "My First Script Pick",
            version = 1.0,
            description = "Pick Items",
            category = Category.MONEYMAKING)
    
    public class Main extends AbstractScript {
    
        int c1 = 0;
    
        GroundItem itemBones = getGroundItems().closest("Bones");
    
        @Override
        public int onLoop() {
            if (itemBones.isOnScreen() && itemBones != null ){
                itemBones.interact("Take");
                        c1++;
            }
            return 100;
        }
    
        @Override
        public void onPaint(Graphics g) {
            g.setFont(new Font("Arial", Font.PLAIN,14));
            // Text In Screeen
            g.drawString("Bones Takes: " + c1, 20, 60);
        }
    }
    

    What about now? But does not start the script because?

    GroundItem itemBones = getGroundItems().closest("Bones");
    

    Not possible.

     

    Use:

    GroundItem itemBones;
    
    @Override
    public int onLoop() {
      itemBones = getGroundItems().closest("Bones");
      if (itemBones.isOnScreen() && itemBones != null ){
        itemBones.interact("Take");
        c1++;
      }
      return 100;
    }
    
    
    Link to comment
    Share on other sites

    GroundItem itemBones = getGroundItems().closest("Bones");
    

    Not possible.

     

    Use:

    GroundItem itemBones;
    
    @Override
    public int onLoop() {
      itemBones = getGroundItems().closest("Bones");
      if (itemBones.isOnScreen() && itemBones != null ){
        itemBones.interact("Take");
        c1++;
      }
      return 100;
    }
    
    

    You should null check the item before checking if it's on the screen :P.

    Link to comment
    Share on other sites

    You should null check the item before checking if it's on the screen :P.

     

    I didn't wrote this :D I just wrote the answer to the question. = But does not start the script because?

    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.