Jump to content

nulling getLastRequestingPlayer?


Johnxtrem

Recommended Posts

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
Link to comment
Share on other sites

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. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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