Johnxtrem Posted June 9, 2017 Share Posted June 9, 2017 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! Quote Link to comment Share on other sites More sharing options...
Butters Posted June 9, 2017 Share Posted June 9, 2017 (edited) Well off the top of my head you could do Player lastPlayer = trade.getLastRequestingPlayer(); if (lastPlayer != null) { DO TRADE lastPlayer = null; } Edited June 9, 2017 by nosepicker Quote Link to comment Share on other sites More sharing options...
Johnxtrem Posted June 9, 2017 Author Share Posted June 9, 2017 Hey, I was trying to keep it local, since the state switches, but I guess it should work just fine. Thanks! Quote Link to comment Share on other sites More sharing options...
Explv Posted June 9, 2017 Share Posted June 9, 2017 (edited) 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, 2017 by Explv 1 Quote Link to comment Share on other sites More sharing options...
Johnxtrem Posted June 9, 2017 Author Share Posted June 9, 2017 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. Quote Link to comment Share on other sites More sharing options...