March 29, 20178 yr Hello guys. Been working hard on an automatic trading script and after alot of figgeling I'm currently hitting a wall. The idea of the code below is that I want to check what a player is offering, and specifically if he's offering coins. This can be the only thing he's allowed to offer and has to be over a certain value. What I tried to do is wait until the player is offering coins by using a conditional sleep. The first problem is that if the condition is false, it will exit the loop and start over again while it actually needs to decline the trade after nothing has happened for X amount of seconds. Second problem is that I need to check the amount of coins and if it is more than 9. In the current code it will first check for coins and only then it will check for value (which probably isn't properly executes and have no idea how to). So their offer should be placed twice in order for it to register and the code needs to be able to do it on the first check. Here my code: public int onLoop() throws InterruptedException { if (trade.isFirstInterfaceOpen()) { if (!trade.getTheirOffers().contains("Coins")) { new ConditionalSleep(10000) { @Override public boolean condition() { return trade.getTheirOffers().contains("Coins"); } }.sleep(); Item item = trade.getTheirOffers().getItem("Coins"); int amountcoins = item.getAmount(); log(amountcoins); } else { } if (trade.getTheirOffers().contains("Coins") && amountcoins > 9) { new ConditionalSleep(10000) { public boolean condition() { return trade.didOtherAcceptTrade(); } }.sleep(); if (trade.didOtherAcceptTrade()) { trade.acceptTrade(); } else { trade.declineTrade(); } } As always, help will be much appreciated!
March 29, 20178 yr Try overriding your 2nd conditional sleep like so new ConditionalSleep(10000) { @Override public boolean condition() { return trade.didOtherAcceptTrade(); } }.sleep(); May be something else wrong with it, let me know. Edit: Nesting your third if statement inside your second one may get rid of some problems aswell, you won't need to use a variable for the coins this way, could just say: if(getTrade().getTheirOffers().getAmount("Coins") >= 9) { // Do stuff } Edited March 29, 20178 yr by naaiz
March 29, 20178 yr 15 minutes ago, naaiz said: Try overriding your 2nd conditional sleep like so new ConditionalSleep(10000) { @Override public boolean condition() { return trade.didOtherAcceptTrade(); } }.sleep(); May be something else wrong with it, let me know. Edit: Nesting your third if statement inside your second one may get rid of some problems aswell, you won't need to use a variable for the coins this way, could just say: if(getTrade().getTheirOffers().getAmount("Coins") >= 9) { // Do stuff } @Override is just an annotation. It improves readability and helps compiler checks, but is not essential.
March 29, 20178 yr 9 minutes ago, Explv said: @Override is just an annotation. It improves readability and helps compiler checks, but is not essential. TIL, cheers.