Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

nulling getLastRequestingPlayer?

Featured Replies

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

Well off the top of my head you could do 

Player lastPlayer = trade.getLastRequestingPlayer();
if (lastPlayer != null) {
DO TRADE
lastPlayer = null;
}

 

Edited by nosepicker

  • Author

Hey,  I was trying to keep it local, since the state switches, but I guess it should work just fine. Thanks! :D

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

  • 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

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.