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
  • GrandExchange.buyItem Error


    botstig

    Recommended Posts



    Can't seem to get GE.buyItem() to work.. If I try either API buyitem or searchItem(<ItemName>) it just sits on search screen and times out.

        public static boolean buyItem(int ItemID, int amount, int price){
            if (!isGeOpen()){
                openGE();
            }
            Debug.log("Placing buy offer for x" + amount + " of " + ItemList.getItem(ItemID).name + " for " + price + " each");
            return GrandExchange.buyItem(ItemID, amount, price);
        }


    The manual way that is not working either:

           /*
            int slot = GrandExchange.getFirstOpenSlot();
            Debug.log("Available slot " + slot + "!");
            if (slot > -1) {
                Debug.log("Opening available slot " + slot + "!");
                GrandExchange.openBuyScreen(slot);
                Sleep.sleepUntil(GrandExchange::isBuyOpen, 2000);
    
                Debug.log("Adding buy offer for " + ItemList.getItem(ItemID).name);
                GrandExchange.searchItem(ItemList.getItem(ItemID).name);
                Sleep.sleepUntil(() -> GrandExchange.getCurrentChosenItemID() == ItemID, 5000);
    
                Debug.log("Setting amount: " + amount);
                GrandExchange.setQuantity(amount);
                Debug.log("Setting price: " + price);
                GrandExchange.setPrice(price);
    
                Debug.log("Place offer");
                GrandExchange.confirm();
                Sleep.sleepUntil(() -> GrandExchange.slotContainsItem(slot), 5000);
                if (GrandExchange.slotContainsItem(slot)){
                    return slot;
                } else {
                    return -1;
                }
            } else {
                return -1;
            }
    
             */

     

    Edited by botstig
    Link to comment
    Share on other sites

    Why make it so difficult. Just use something like

    if(GrandExchange.isOpen()) {
        if (GrandExchange.buyItem("Nature rune", 100, 50)) {
            if (Sleep.sleepUntil(GrandExchange::isReadyToCollect, Calculations.random(10000, 20000))) {
                GrandExchange.collect();
            }
        }
    }
    Edited by brad734
    Link to comment
    Share on other sites

    Posted (edited)

    I tried/am, that's basically the first block, it doesn't search for the item when buyItem or searchItem are called.
    The commented code was a attempt to brute force when buyitem wasn't working.

    Edited by botstig
    Link to comment
    Share on other sites

    ```

    if (GrandExchange.isOpen()) {
             if (GrandExchange.buyItem(knife, 1, 150)) {
                log("Buying knife");
                Sleep.sleepTicks(2);
                   if (GrandExchange.isOpen()) {
                      if (GrandExchange.isReadyToCollect() && GrandExchange.collect()) {
                           log("Knife collected successfully");
                      } else {
                         log("Failed to collect knife or knife was not ready to collect");
                        }
                   }
               }
    Edited by idhurtit
    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
    ×
    ×
    • 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.