Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Completely lost on why onGameMessage(Message) is not working for me...?


    Bryno

    Recommended Posts

    Hi, so my class implements ChatListener and this is the code:

    public void onGameMessage(Message msg) {
    		logError("Msg: " + msg.getMessage());
    		logError("result = " + msg.getMessage().contains("You get some oak logs"));
    }

    I've already tried putting:

    @Override

    on top of the method as well..

    I am literally not getting ANY console output. My onGameMessage() method is just not getting invoked at all..

    Any ideas? :( 

    Link to comment
    Share on other sites

    20 minutes ago, Bryno said:

    Hi, so my class implements ChatListener and this is the code:

    public void onGameMessage(Message msg) {
    		logError("Msg: " + msg.getMessage());
    		logError("result = " + msg.getMessage().contains("You get some oak logs"));
    }

    I've already tried putting:

    @Override

    on top of the method as well..

    I am literally not getting ANY console output. My onGameMessage() method is just not getting invoked at all..

    Any ideas? :( 

    why not just check your inventory for another logic being added? 

    Link to comment
    Share on other sites

    Are you implementing it in your main script class (the one with a ScriptManifest) or a separate class? If it's a separate class you'll need to register it manually via Instance#addEventListener.

    Link to comment
    Share on other sites

      

    1 hour ago, RSMasterGuard said:

    why not just check your inventory for another logic being added? 

    This is a good idea for a work around, however it will not work for my application.

    Just for too much detail, I am looking for a message of "You don't have an axe" to make sure I create a failsafe for the script to stop.

    Link to comment
    Share on other sites

    1 hour ago, Pandemic said:

    Are you implementing it in your main script class (the one with a ScriptManifest) or a separate class? If it's a separate class you'll need to register it manually via Instance#addEventListener.

    Hi there, unfortunately it is in the same class as my ScriptManifester.

    The class extends AbstractScript and implements ChatListener.

    Still no luck 😕 

    Link to comment
    Share on other sites

    4 minutes ago, Bryno said:

    Hi there, unfortunately it is in the same class as my ScriptManifester.

    The class extends AbstractScript and implements ChatListener.

    Still no luck 😕 

    You may want to use onMessage instead of onGameMessage as whatever message you're looking for may not be of that type (there are many different types of chat messages: https://dreambot.org/javadocs/org/dreambot/api/wrappers/widgets/message/MessageType.html). onMessage will catch ALL messages so you can check the type in there if you'd prefer using a more specific method :)

    Link to comment
    Share on other sites

    1 hour ago, Bryno said:

      

    This is a good idea for a work around, however it will not work for my application.

    Just for too much detail, I am looking for a message of "You don't have an axe" to make sure I create a failsafe for the script to stop.

    what about checking for the axe in the equipment slot and inventory?

    Link to comment
    Share on other sites

    6 hours ago, Bryno said:
    		logError("result = " + msg.getMessage().contains("You get some oak logs"));
    

    getting logs is not a game message its a filtered message, not having an axe is a game message so if you arent getting that one you've set something up wrong

    Link to comment
    Share on other sites

    4 hours ago, camalCase said:

    getting logs is not a game message its a filtered message, not having an axe is a game message so if you arent getting that one you've set something up wrong

    Wow that's so weird that a message that is under the "Game" tab in the client is considered a MessageType.FILTERED haha 

    I would have never guessed, but okay thank you for  this information! Appreciate it a lot! 

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.