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
  • Try asking for help in the chatbox
  • Returning items collected for paint


    drchrismas
     Share

    Recommended Posts

    Hello!

    I'm not the best at java nor dreambot scripting but i think it's fun to do on my own time so i just create bots for fun little projects. One thing i've ran into i can't come up with how to do is how do i return the amount of items collected?

     

    Here's my main class:

    package itemPickUpper;
    
    //import org.dreambot.api.methods.skills.Skill;
    //import org.dreambot.api.methods.skills.SkillTracker;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.impl.TaskScript;
    import java.awt.*;
    
    
    // Every script needs a ScriptManifest so it can be seen in the script manager
    @ScriptManifest(
            category = Category.MONEYMAKING,
            name = "something",
            description = "Shits out something",
            author = "name",
            version = 0.1)
    public class itemPickUpper extends TaskScript {
        public int itemsPickedUp = 0;
        @Override
        public void onStart() {
            // Add our tasks so the bot knows what to do
            addNodes(new Picker(), new Walker(), new WalkToBank(), new Banking());
            log(itemsPickedUp);
        }
    
        /*@Override
        public void onPaint(Graphics g) {
            //heres where my paint would go IF I HAD ANY
        }*/
    
    }

     

     

    Here's the class that picks up the items:

    package itemPickUpper;
    
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.container.impl.Inventory;
    import org.dreambot.api.methods.interactive.GameObjects;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.script.TaskNode;
    import org.dreambot.api.wrappers.interactive.GameObject;
    
    public class Picker extends TaskNode {
        private int itemsPickedUp = 0;
        private final Area itemArea = new Area(cordslmao1);
        @Override
        public boolean accept() { //This is used by DreamBot to decide if it should run this task's execute method.
            // If our inventory isn't full and we're somewhere
            log("Picker accepterande metod: " + (!Inventory.isFull() && itemArea.contains(getLocalPlayer())));
            return !Inventory.isFull() && itemArea.contains(getLocalPlayer()));
        }
    
        @Override
        public int execute() {
            GameObject closestItem = GameObjects.closest("item");
    
            // If there aren't any available items near us, we should just wait until one's available
            if (closestItem == null) return Calculations.random(500, 1000);
    
            if (closestItem.interact("Something")) { // If we successfully click on the rock
                sleepUntil(() -> getLocalPlayer().isAnimating(), 5000); 
                sleep(Calculations.random(500,800));
                itemsPickedUp += 1;
            }
            return itemsPickedUp;
            //return Calculations.random(500, 1000);
        }
    }

     

     

    The log() command isn't displaying anything at all in the console besides the first time it's running. How would i return a value that i can use in a paint? Thanks for all and any help!

    Link to comment
    Share on other sites

    Not sure about how to do it for paint, but I know to output to the log you could convert itemPickedUp to string and use MethodProvider.log(stringHere);

    Edited by GuNCuSSioN
    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • 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.