botstig 0 Share Posted August 10, 2023 (edited) 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 August 10, 2023 by botstig Link to comment Share on other sites More sharing options...
brad734 3 Share Posted August 10, 2023 (edited) 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 August 10, 2023 by brad734 Link to comment Share on other sites More sharing options...
botstig 0 Author Share Posted August 10, 2023 (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 August 10, 2023 by botstig Link to comment Share on other sites More sharing options...
idhurtit 20 Share Posted August 11, 2023 (edited) ``` 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 August 11, 2023 by idhurtit Link to comment Share on other sites More sharing options...
ginahana1 1 Share Posted December 15, 2023 Okay, I had the same issue and it hasn't been resolved yet so I came up with solution like that: if(GrandExchange.openBuyScreen(1)) { // opens buy screen if(Sleep.sleepUntil(() -> GrandExchange.isBuyOpen(), 4000)) { // waits until open if(Widgets.getWidgetChild(465, 25, 0) != null && Widgets.getWidgetChild(465, 25, 0).isVisible()) { // checks if the icon that is placeholder for the item in the buy screen is visible and even exists Widgets.getWidgetChild(465, 25, 0).interact("Choose item"); // iteracts with this button Sleep.sleep(1000, 2500); GrandExchange.buyItem(properItemID, buyItemLive, properItemIDPrice); //now this works Sleep.sleep(1500, 2500); } } } This solution works, but of course if anything changes with the client and the ID of the widget child changes - you will need to change it too manually. But if it works - leave it Remember to delete comments // 😜 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now