botelias Posted July 16, 2019 Share Posted July 16, 2019 Hi! I can't get a joke-bot to accept past the 2nd trade window. Tried several different widgets, but it just won't work. Anybody know why? if (getTrade().isSecondInterfaceOpen()) { log("Second trade..."); if (getTrade().didOtherAcceptTrade() && !getTrade().getTheirOffers().isEmpty()) { RS2Widget acceptTrade = getWidgets().get(334, 25); if (acceptTrade.interact()) { tellJoke = true; return random(200, 300); } } } Also tried replacing: RS2Widget acceptTrade = getWidgets().get(334, 25); with: RS2Widget acceptTrade = getWidgets().getWidgetContainingText("Accept"); First time I try messing with Java, so probably something stupid I've missed Thanks! Quote Link to comment Share on other sites More sharing options...
Kramnik Posted July 16, 2019 Share Posted July 16, 2019 I think there is no need to use widgets when accepting trades as API has implemented method. I just use trade.acceptTrade(); Quote Link to comment Share on other sites More sharing options...
botelias Posted July 17, 2019 Author Share Posted July 17, 2019 Yeah, solved it with a similar solution! Thanks! Do you happen to know how to insert an item in a trade? ---------------------------------------------------------------- public int onLoop() throws InterruptedException { if (trade.isCurrentlyTrading()) { if (trade.isFirstInterfaceOpen()) { trade.offer(2140,1); } (and a bit more code) ---------------------------------------------------------------- ^ does not work. It does however work if I place "trade.offer(2140,1);" right after the onLoop; ---------------------------------------------------------------- public int onLoop() throws InterruptedException { trade.offer(2140,1); if (trade.isCurrentlyTrading()) { if (trade.isFirstInterfaceOpen()) { } ---------------------------------------------------------------- ^ does work. Quote Link to comment Share on other sites More sharing options...
Czar Posted July 18, 2019 Share Posted July 18, 2019 Hmm it seems to be working for me if I check getTrade().isFirstInterfaceOpen() before offering an item. can you print in the logger: log("Is first interface open? " + getTrade().isFirstInterfaceOpen() + "."); to confirm it's detecting that you're in the first interface? Quote Link to comment Share on other sites More sharing options...
botelias Posted July 18, 2019 Author Share Posted July 18, 2019 9 hours ago, Czar said: Hmm it seems to be working for me if I check getTrade().isFirstInterfaceOpen() before offering an item. can you print in the logger: log("Is first interface open? " + getTrade().isFirstInterfaceOpen() + "."); to confirm it's detecting that you're in the first interface? It works, just not always. And when it doesn't work, I have to restart client to get it working again. Read similar issues, but no solutions. It hovers over decline button when it doesn't work. Quote Link to comment Share on other sites More sharing options...
Czar Posted July 18, 2019 Share Posted July 18, 2019 7 hours ago, botelias said: It works, just not always. And when it doesn't work, I have to restart client to get it working again. Read similar issues, but no solutions. It hovers over decline button when it doesn't work. Alright is there any way you can replicate this bug or is it completely random? In any case I will have a chat with the scripters/devs and see if there's anything wrong ^^ Quote Link to comment Share on other sites More sharing options...
botelias Posted August 24, 2019 Author Share Posted August 24, 2019 On 7/18/2019 at 11:06 PM, Czar said: Alright is there any way you can replicate this bug or is it completely random? In any case I will have a chat with the scripters/devs and see if there's anything wrong ^^ Done more research now after coming back from vacation. The issue appears to be 100% random, and unrelated to account. Sometimes it works, sometimes it doesn't. If it however does work, it will keep working as long as client is running. Same if it doesn't work. Quote Link to comment Share on other sites More sharing options...
Czar Posted August 24, 2019 Share Posted August 24, 2019 (edited) Well I will have to take a closer look at the trading and try to reproduce the bug in effort to send it to the devs ASAP so we can get it fixed. EDIT: Will be reviewing every possible variable that involves trading too. Edited August 24, 2019 by Czar Quote Link to comment Share on other sites More sharing options...
botelias Posted August 24, 2019 Author Share Posted August 24, 2019 Tried simplifying the trade process as much as possible, removing everything that has to do with declining trade (empty window, slow trade, etc etc). Still hovers over "Decline". Quote Link to comment Share on other sites More sharing options...
BravoTaco Posted August 24, 2019 Share Posted August 24, 2019 (edited) Try and use widget id 334, 13 its the one that contains the action accept on the second trade screen. The other one that you are using contains only the text. Also I wrote up a basic trading handler here https://osbot.org/forum/topic/155996-trading-api-unpredictable/ Quick addition, to offer an item try and use this method. public boolean offerItem(String action, String itemName){ return getInventory().interact(action, itemName); } Edited August 24, 2019 by BravoTaco Quote Link to comment Share on other sites More sharing options...