Skip 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.

Game log listener

Featured Replies

Hi, I have been searching round the API but can't seems to find a listener I could implement that gets executed when a game event (like A magical force stops you from moving) appears on the game log. Or is there some other way of reading these?

You need to get a message listener, the method is onMessage() if I recall correctly.

 

EDIT:

 

I.e

   private void onMessage(String message) {
    	if(message.contains("You get some oak logs.")) {
    		itemsMade ++;
    	}
    }

You can make specific message type listeners too:

if you put that in the onMessage method


if(getType().equals(Message.MessageType.GAME)) {
 // game message
}

if(getType().equals(Message.MessageType.PLAYER)) {
 // player message
}

and in the onStart() method:

getBot().addMessageListener(this);

Edited by Vilius

Script implements all listeners:
 

abstract class Script extends MethodProvider implements Painter, MessageListener, ConfigListener, LoginResponseCodeListener, AudioListener

So you just need to override public void onMessage(Message m) in your script

Hi, I have been searching round the API but can't seems to find a listener I could implement that gets executed when a game event (like A magical force stops you from moving) appears on the game log. Or is there some other way of reading these?

 

 

You need to get a message listener, the method is onMessage() if I recall correctly.

   private void onMessage(String message) {
    	if(message.contains("You get some oak logs.")) {
    		itemsMade ++;
    	}
    }

 

You can do this, but this example is incorrect, the argument is not a String. It should be:

@Override
public void onMessage(Message message){

    if(e.getType() == Message.MessageType.GAME &&
       e.getMessage().equals("A magical force stops you from moving")){

           // do something
    }
}

Edited by Explv

 

You can do this, but this example is incorrect, the argument is not a String. It should be:

@Override
public void onMessage(Message message){

    if(e.getType() == Message.MessageType.GAME &&
       e.getMessage().equals("A magical force stops you from moving")){

           // do something
    }
}

Ah yes, been some time when I used message listeners :x

  • Author

Brilliant guys thanks, also one last thing so I don't open an other thread, do you know how you can fetch if a player is skulled or not?

 

NVM got it from Player.getSkullIcon()

Edited by Tazmania

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.