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
  • Best way to buy items in GE?


    FilthE

    Recommended Posts

    I'm trying to buy quest items from the GE with this script, and maybe I'm interpreting the api wrong because it seems like the bot will randomly not buy some items from my list on one test, then the next test it buys all the items, and on other tests it buys different items in my list so I'm not too sure what's going on. Here is a snippet of how I'm getting it to buy items right now...

                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Lobster");
    
                getGrandExchange().buyItem("Lobster", 10, buyPrice);
    
                getGrandExchange().goBack();
    

    What's the best way to go about this? What would make it buy the right items one time and then not buy them the next time around?

     

    Full method:

       private void buyItems(){
    
            int buyPrice = 2000;
    
            if(getGrandExchange().isOpen() == false) {
    
                getGrandExchange().open("Exchange");
    
            }
    
    
            if (getGrandExchange().isGeneralOpen()) {
    
                //Buys lobster
                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Lobster");
    
                getGrandExchange().buyItem("Lobster", 10, buyPrice);
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
    
    
    
                //Buys Beer
                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Beer");
    
                getGrandExchange().buyItem("Beer", 3, buyPrice);
    
                sleep(Calculations.random(1000, 5000));
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
    
    
                //Buys balls of wool
                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Ball of wool");
    
                getGrandExchange().buyItem("Ball of wool", 3, buyPrice);
    
                sleep(Calculations.random(1000, 5000));
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
    
    
                //Collects
                if (getGrandExchange().isReadyToCollect(1)) {
    
                    getGrandExchange().collect();
    
                    getGrandExchange().goBack();
    
                    sleep(Calculations.random(1000, 5000));
    
                }
    
    
    
                //Buys redberries
                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Redberries");
    
                getGrandExchange().buyItem("Redberries", 1, buyPrice);
    
                sleep(Calculations.random(1000, 5000));
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
    
    
                //Buys soft clay
                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Soft clay");
    
                getGrandExchange().buyItem("Soft clay", 1, buyPrice);
    
                sleep(Calculations.random(1000, 5000));
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
    
    
                //buys yellow die
                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Yellow dye");
    
                getGrandExchange().buyItem("Yellow Dye", 1, buyPrice);
    
                sleep(Calculations.random(1000, 5000));
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
    
    
    
                //Collects
                if (getGrandExchange().isReadyToCollect(1)) {
    
                    getGrandExchange().collect();
    
                    getGrandExchange().goBack();
    
                    sleep(Calculations.random(1000, 5000));
    
                }
    
    
    
                //Buys ashes
                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Ashes");
    
                getGrandExchange().buyItem("Ashes", 1, buyPrice);
    
                sleep(Calculations.random(1000, 5000));
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
    
    
                //Buys flour
                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Pot of flour");
    
                getGrandExchange().buyItem("Pot of flour", 1, buyPrice);
    
                sleep(Calculations.random(1000, 5000));
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
    
    
                //Buys water
                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Bucket of water");
    
                getGrandExchange().buyItem("Bucket of water", 1, buyPrice);
    
                sleep(Calculations.random(1000, 5000));
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
    
    
                //Collects
                if (getGrandExchange().isReadyToCollect(1)) {
    
                    getGrandExchange().collect();
    
                    getGrandExchange().goBack();
    
                    sleep(Calculations.random(1000, 5000));
    
    
                }
    
    
                //Buys bronze bar
                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Bronze bar");
    
                getGrandExchange().buyItem("Bronze bar", 1, buyPrice);
    
                sleep(Calculations.random(1000, 5000));
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
    
    
                //Buys skirt
                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Pink skirt");
    
                getGrandExchange().buyItem("Pink skirt", 1, buyPrice);
    
                sleep(Calculations.random(1000, 5000));
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
    
    
                //Buys Rope
                getGrandExchange().openBuyScreen(1);
    
                getGrandExchange().searchItem("Rope");
    
                getGrandExchange().buyItem("Rope", 1, buyPrice);
    
                sleep(Calculations.random(1000, 5000));
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
            }
    
    
            //Collects
            if (getGrandExchange().isReadyToCollect(1)) {
    
                getGrandExchange().collect();
    
                getGrandExchange().goBack();
    
                sleep(Calculations.random(1000, 5000));
    
                getGrandExchange().close();
    
                questItemsBought = true;
    
    
            }
    
        }
    
    Link to comment
    Share on other sites

    If it doesn't buy some of the items, perhaps it is skipping over them due to the way you wrote your code. You also don't have many sleeps inbetween functions, so that could cause it to also skip. Try adding more if statements and sleeps. like if (ifBuyScreen.isOpen()) { buy shit } blah blah. 

    Link to comment
    Share on other sites

    questItemsBought = true;

     

    add an "if getinventory.contains(boughtItems)"{
    questItemsBought = true;
    }

     

    Otherwise it'll return true just when the script reaches that part of the code (whether you have the items or not).  A sleepuntil either grand exchange has slot with text (custom) or just a sleepuntil inv has the items you're trying to buy, otherwise try again, to double check for items on inv before continuing with the rest of the script.
     

     

    edit: also, can't really confirm as I don't have intelliJ open atm, but I'm pretty sure that 

     

    //getGrandExchange().searchItem("Rope");

    getGrandExchange().buyItem("Rope", 1, buyPrice);

     

    you could probably remove the first line as the 2nd line should already automatically do that... Don't quote me, but I suggest you just try that just to be safe.  =3

    Link to comment
    Share on other sites

     

    You should try to always do 1 action per loop. If one of your actions fail, the whole thing will come out wrong

     

    Xephy stop with the blank quotes REEEEEEEEE.

    Link to comment
    Share on other sites

    Thank you guys, it seems like removing getGrandExchange().searchItem("Whatever");, adding more sleeps and separating it into smaller functions did the trick.

    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.