June 9, 20178 yr Hey, is there a way to nullify trade.getLastRequestingPlayer? Since even after the trade is accepted, or done, the value is still the player that traded. Or is there another way to handle this? Thanks!
June 9, 20178 yr Well off the top of my head you could do Player lastPlayer = trade.getLastRequestingPlayer(); if (lastPlayer != null) { DO TRADE lastPlayer = null; } Edited June 9, 20178 yr by nosepicker
June 9, 20178 yr Author Hey, I was trying to keep it local, since the state switches, but I guess it should work just fine. Thanks!
June 9, 20178 yr 9 minutes ago, Johnxtrem said: Hey, is there a way to nullify trade.getLastRequestingPlayer? Since even after the trade is accepted, or done, the value is still the player that traded. Or is there another way to handle this? Thanks! You're thinking about it completely wrong. It doesn't make sense for getLastRequestingPlayer to be null unless no one has traded you. What you should do is have a global boolean variable, let's call it shouldTrade. You initialise shouldTrade to false. Then you add a message listener using getBot().addMessageListener(MessageListener listener) or override the onMessage(Message message) method in your script class. Inside the onMessage method you then check if the message is of type RECEIVED_TRADE. If it is of that type set shouldTrade to true. In onLoop you check if shouldTrade is true, if it is then you can begin trading. Once the trade is complete, set shouldTrade to false. There are other ways to do it, but that's probably the simplest Edited June 9, 20178 yr by Explv
June 9, 20178 yr Author 10 minutes ago, Explv said: You're thinking about it completely wrong. It doesn't make sense for getLastRequestingPlayer to be null unless no one has traded you. What you should do is have a global boolean variable, let's call it shouldTrade. You initialise shouldTrade to false. Then you add a message listener using getBot().addMessageListener(MessageListener listener) or override the onMessage(Message message) method in your script class. Inside the onMessage method you then check if the message is of type RECEIVED_TRADE. If it is of that type set shouldTrade to true. In onLoop you check if shouldTrade is true, if it is then you can begin trading. Once the trade is complete, set shouldTrade to false. There are other ways to do it, but that's probably the simplest Thanks, making more sense now.
Create an account or sign in to comment