June 13, 20187 yr 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, 20187 yr by Thiccboi
June 13, 20187 yr 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.
June 14, 20187 yr Author 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, 20187 yr by Thiccboi
June 14, 20187 yr 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.
June 14, 20187 yr 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.
June 14, 20187 yr 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
June 14, 20187 yr 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.
June 14, 20187 yr 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()
June 14, 20187 yr 1 hour ago, John Cena said: He'll learn from my grade A code. ow god im already scared
June 14, 20187 yr Author actually I was able to find a solution myself, I just forgot to post it here. Thank you for all of the help though!
Create an account or sign in to comment