Thiccboi Posted June 13, 2018 Share Posted June 13, 2018 (edited) I am newly learning java and getting into scripting, I am trying to make the bot accept a trade when it is sent to it and then accept if coins are in the trade. the main issue I am having with my code is that it keeps spam trading the other player, It will accept the trade then close the trade instantly and keep spam trading them. but if you start the script while the trade window is open it works as intended, I would really like some help if possible. public int onLoop() throws InterruptedException { if (trade.getLastRequestingPlayer() != null) { trade.getLastRequestingPlayer().interact("trade with"); log ("trade started"); } if (trade.getTheirOffers().contains("coins")){ trade.acceptTrade();} if (trade.isSecondInterfaceOpen()) { trade.acceptTrade(); }; return random (200, 300); Edited June 13, 2018 by Thiccboi Quote Link to comment Share on other sites More sharing options...
John Cena Posted June 13, 2018 Share Posted June 13, 2018 Just now, Thiccboi said: I am newly learning java and getting into scripting, I am trying to make the bot accept a trade when it is sent to it and then accept if coins are in the trade. the main issue I am having with my code is that it keeps spam trading the other player, It will accept the trade then close the trade instantly and keep spam trading them. but if you start the script while the trade window is open it works as intended, I would really like some help if possible. public int onLoop() throws InterruptedException { if (trade.getLastRequestingPlayer() != null) { trade.getLastRequestingPlayer().interact("trade with"); log ("trade started"); } if (trade.getTheirOffers().contains("coins")){ trade.acceptTrade();} if (trade.isSecondInterfaceOpen()) { trade.acceptTrade(); }; return random (200, 300); I would just set getLastRequestingPlayer to null once you've done the interaction. Quote Link to comment Share on other sites More sharing options...
Charlotte Posted June 13, 2018 Share Posted June 13, 2018 You should explore conditional sleeps. I believe there are 2 trade interfaces. Quote Link to comment Share on other sites More sharing options...
Thiccboi Posted June 14, 2018 Author Share Posted June 14, 2018 (edited) 19 hours ago, John Cena said: I would just set getLastRequestingPlayer to null once you've done the interaction. if you don't mind me asking where does it store the username for getLastRequestingPlayer? I have tried trade.getLastRequestingPlayer == null; but I just get an error. Edited June 14, 2018 by Thiccboi Quote Link to comment Share on other sites More sharing options...
Canidae Posted June 14, 2018 Share Posted June 14, 2018 Looking at your code, I recommend you not playing with trades since you will need some additional checks to make sure you trade the right player etc. etc. Start with something more easy, like a cow killer or a woodcutter. 1 Quote Link to comment Share on other sites More sharing options...
John Cena Posted June 14, 2018 Share Posted June 14, 2018 1 hour ago, Thiccboi said: if you don't mind me asking where does it store the username for getLastRequestingPlayer? I have tried trade.getLastRequestingPlayer == null; but I just get an error. Ill send you the source to my trade script later on. Quote Link to comment Share on other sites More sharing options...
TheMcPker Posted June 14, 2018 Share Posted June 14, 2018 1 hour ago, John Cena said: Ill send you the source to my trade script later on. you shoudn't tbh just giving free code doesn't help him learn Quote Link to comment Share on other sites More sharing options...
John Cena Posted June 14, 2018 Share Posted June 14, 2018 4 minutes ago, TheMcPker said: you shoudn't tbh just giving free code doesn't help him learn He'll learn from my grade A code. 1 Quote Link to comment Share on other sites More sharing options...
Hel Posted June 14, 2018 Share Posted June 14, 2018 As charlotte said, learn about conditional sleeps and do checks for it it's currently trading, I believe the methods you'll need are: trade.isCurrentlyTrading(), trade.isFirstInterfaceOpen() and trade.isSecondInterfaceOpen() Quote Link to comment Share on other sites More sharing options...
TheMcPker Posted June 14, 2018 Share Posted June 14, 2018 1 hour ago, John Cena said: He'll learn from my grade A code. ow god im already scared Quote Link to comment Share on other sites More sharing options...
Thiccboi Posted June 14, 2018 Author Share Posted June 14, 2018 actually I was able to find a solution myself, I just forgot to post it here. Thank you for all of the help though! Quote Link to comment Share on other sites More sharing options...