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
  • Grabbing chat messages


    Vogelbekdier

    Recommended Posts

    Simple question; Trying to make a fire making script that will relight the new log once chat contains the message "The fire catches and the logs begin to burn" however I can't figure out how to grab the text from my chatbox.

    Link to comment
    Share on other sites

    1 hour ago, Vogelbekdier said:

    Simple question; Trying to make a fire making script that will relight the new log once chat contains the message "The fire catches and the logs begin to burn" however I can't figure out how to grab the text from my chatbox.

    Hey @Vogelbekdier! You can achieve what you've set out to do using the "ChatListener" interface. Simply implement the ChatListener in your script and override the method you'd like to use. I've provided an example for you below.

    public class TestScript implements ChatListener {
        ... some code here ...
          
        @Override
        public void onGameMessage(Message message) {
            if (message.getMessage().contains("The fire catches and the logs begin to burn")) {
                shouldLightFire = true;
            }
        }
    }

    You can view all of the methods that can be overridden for ChatListener here: https://dreambot.org/javadocs/org/dreambot/api/script/listener/ChatListener.html

    You can view all of the information provided by a "Message" here: https://dreambot.org/javadocs/org/dreambot/api/wrappers/widgets/message/Message.html

    The different overrides are for the different types of message (game message, clan message, etc.). You can also use the catch-all "onMessage()" method.

    Hope that helps! Best of luck 🙂

    Link to comment
    Share on other sites

    • 2 months later...

    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.