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
  • How do I make a SeedCounter


    UnusualPerson

    Recommended Posts

    Hello everyone,

    I am writing a script that steals from the master farmer. I would like to add something that counts the amount of a specific seed I stole.

    public int onLoop() {
        int GuamCount = getInventory().count("Guam Seed");

    I have tried this,  but whenever I go to the bank to empty my inventory, the counter resets.

    Does anyone know how I can edit this piece so that it doesn't reset after banking?

    Link to comment
    Share on other sites

    The InventoryListener is perfect for this job.

    @Override
    public void onItemChange(Item[] items) {
        // loop through items
            // if item is seed you're interested in
                // increment your counter by its getAmount
    }

    Note that if the amount is < 0, you either dropped or banked the seeds. If the amount is > 0 you acquired them. You'd want to ignore the items if their getAmount is negative.

    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.