Jump to content

nulling getLastRequestingPlayer?


Recommended Posts

Posted (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! :D

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 by Explv
  • Like 1
Posted
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

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...