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.

How to trade other players

Featured Replies

Hello,

I am looking for a bit of help for player trading.

 

i have this so far for the task

import org.osbot.rs07.api.ui.Message;
import org.osbot.rs07.script.MethodProvider;

public class trade extends Task {

    public trade(MethodProvider api) {
        super(api);
    }

    @Override
    public boolean canProcess() {
    return Message.MessageType.RECEIVE_TRADE;     (I need the right command to trigger the task, when it has seen that a player has traded do the task)
    
    }

    @Override
    public void process() {
    api.log("we have been traded");                (I need help with the bot clicking to start the trade, accepting both trade windows)

        
    }

}

Use a message listener to check for trade messages.

If it receives one set some boolean to true indicating that the script should begin the trading task. Also store the username of the player trading with you.

Then interact with that player to commence trading.

There are methods for interacting with the trade window in the API.

 

  • Author
11 minutes ago, Explv said:

Use a message listener to check for trade messages.

If it receives one set some boolean to true indicating that the script should begin the trading task. Also store the username of the player trading with you.

Then interact with that player to commence trading.

There are methods for interacting with the trade window in the API.

 

is this the right command to listen for this? Message.MessageType.RECEIVE_TRADE;

if so how do i set boolean to true?

5 minutes ago, olstan said:

is this the right command to listen for this? Message.MessageType.RECEIVE_TRADE;

if so how do i set boolean to true?

You need to use a MessageListener

You can add one by calling api.getBot().addMessageListener(messageListener);

Check that the message received is of type Message.MessageType.RECEIEVE_TRADE

Then set a global boolean variable inside your Task class to true

And return that boolean variable from your canProcess method

12 minutes ago, olstan said:

if so how do i set boolean to true?

I suspect you may need to spend some more time learning Java, before writing scripts

  • Author

is this close?
    @Override
    public boolean canProcess() {
    MessageListener MessageListener = null;
    api.getBot().addMessageListener(MessageListener);
    Message.MessageType.RECEIVE_TRADE;
    return true;

 

6 minutes ago, Explv said:

I suspect you may need to spend some more time learning Java, before writing scripts

The problem i have, is quite bad dyslexia, i had the same problems learning C with man pages.
I struggle to interpret API

 

But once i get to grips i find it easier

5 minutes ago, olstan said:

is this close?
    @Override
    public boolean canProcess() {
    MessageListener MessageListener = null;
    api.getBot().addMessageListener(MessageListener);
    Message.MessageType.RECEIVE_TRADE;
    return true;

No that is not close.

You have to create a new instance of MessageListener, how could a null MessageListener be of any use?

You also only want to add a message listener once, not every time canProcess() is called.

I understand you may have bad dyslexia, I am not trying to be rude, I am just saying that you may want to follow some Java tutorials before trying to write scripts, because it seems like you don't understand the fundamentals just yet.

  • Author
10 minutes ago, Explv said:

No that is not close.

You have to create a new instance of MessageListener, how could a null MessageListener be of any use?

You also only want to add a message listener once, not every time canProcess() is called.

I understand you may have bad dyslexia, I am not trying to be rude, I am just saying that you may want to follow some Java tutorials before trying to write scripts, because it seems like you don't understand the fundamentals just yet.

I know wasn't trying to be rude.

I have managed to search snippets of other peoples posts, and since then have progressed quite well.
This is just a big part i am stuck with.

    @Override
    public boolean canProcess() {
    MessageListener MessageListener;
    api.getBot().addMessageListener(MessageListener);
    Message.MessageType.RECEIVE_TRADE;
    return true;

 

 

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.