Magerange Posted June 7, 2017 Share Posted June 7, 2017 (edited) So I've decided to clean and restructure one of my scripts that I've stitched together by a miracle (started scripting roughly a month ago, so don't kill me straight away). This one has the trading function included in it, but I can't seem to make it complete the second trade window (it does 'accept' the first trade screen (if condition is met) , but closes second one). I've inserted snippets after the script has opened the trade window (no issues there). if (getTrade().isFirstInterfaceOpen() && getTrade().getTheirOffers().contains("")) { getTrade().acceptTrade(); Script.sleep(Script.random(1000, 1500)); } if (getTrade().isSecondInterfaceOpen()) { getTrade().acceptTrade(); Script.sleep(Script.random(1000, 1500)); } Previously I used something very redundant and fairly stupid, but it got the job done (no need to grill me on that one): if (getTrade().isFirstInterfaceOpen()) { Script.sleep(Script.random(2000, 3000)); if (getTrade().getTheirOffers().contains("")) { Script.sleep(Script.random(2000, 3000)); getTrade().acceptTrade(); Script.sleep(Script.random(2000, 3000)); getTrade().acceptTrade(); Script.sleep(Script.random(2000, 3000)); } Edited June 7, 2017 by Magerange Quote Link to comment Share on other sites More sharing options...
Muffins Posted June 7, 2017 Share Posted June 7, 2017 u should use conditional sleeps Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted June 7, 2017 Share Posted June 7, 2017 (edited) This works for me, ignore the "script." that precedes all of my crap, it's a long story. edit: looks like you just need yo use trade instead of getTrade if (script.trade.isFirstInterfaceOpen() == true){ script.log("First window open, waiting"); new ConditionalSleep(30000) { @Override public boolean condition() throws InterruptedException { return script.trade.didOtherAcceptTrade() == true; } }.sleep(); script.trade.acceptTrade(); new ConditionalSleep(30000) { @Override public boolean condition() throws InterruptedException { return script.trade.didOtherAcceptTrade() == true; } }.sleep(); script.log("Second window open, accepting"); Script.sleep(Script.random(2000, 3000)); script.trade.acceptTrade(); Edited June 7, 2017 by sudoinit6 Quote Link to comment Share on other sites More sharing options...
Lewis Posted June 7, 2017 Share Posted June 7, 2017 2 minutes ago, sudoinit6 said: This works for me, ignore the "script." that precedes all of my crap, it's a long story. edit: looks like you just need yo use trade instead of getTrade if (script.trade.isFirstInterfaceOpen() == true){ script.log("First window open, waiting"); new ConditionalSleep(30000) { @Override public boolean condition() throws InterruptedException { return script.trade.didOtherAcceptTrade() == true; } }.sleep(); script.trade.acceptTrade(); new ConditionalSleep(30000) { @Override public boolean condition() throws InterruptedException { return script.trade.didOtherAcceptTrade() == true; } }.sleep(); script.log("Second window open, accepting"); Script.sleep(Script.random(2000, 3000)); script.trade.acceptTrade(); that code nasty if (trade.isCurrentlyTrading()) { if (trade.isFirstInterfaceOpen()) { trade.acceptTrade(); log("accept trade 1"); new ConditionalSleep(10000) { @Override public boolean condition() throws InterruptedException { return trade.isSecondInterfaceOpen() || !trade.isCurrentlyTrading(); } }.sleep(); } else if (trade.isSecondInterfaceOpen()) { log("accept trade 2"); trade.acceptTrade(); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return !trade.isCurrentlyTrading(); } }.sleep(); } } Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted June 7, 2017 Share Posted June 7, 2017 3 minutes ago, Lewis said: that code nasty Meh, I am a horrible coder, but it gets the job done. I was just trying to help out. Quote Link to comment Share on other sites More sharing options...
Lewis Posted June 7, 2017 Share Posted June 7, 2017 30 minutes ago, sudoinit6 said: Meh, I am a horrible coder, but it gets the job done. I was just trying to help out. it gets the job done, but theres many flaws in it Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted June 7, 2017 Share Posted June 7, 2017 42 minutes ago, Lewis said: it gets the job done, but theres many flaws in it Like everything else I will fix them when it doesn't work, that's how one learns. Quote Link to comment Share on other sites More sharing options...
Magerange Posted June 8, 2017 Author Share Posted June 8, 2017 Thanks, everyone! Quote Link to comment Share on other sites More sharing options...
FrostBug Posted June 9, 2017 Share Posted June 9, 2017 On 6/8/2017 at 0:03 AM, sudoinit6 said: looks like you just need yo use trade instead of getTrade Literally the same thing Quote Link to comment Share on other sites More sharing options...