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
  • problems with ongamemessage


    mankel200

    Recommended Posts

    Basically im trying to get my script read from chat

    I have tried this but didnt get it to work:

    
    public void onGameMessage(@NotNull Message message){
        if (message.getMessage().contains("I can't")){
            log("vituiks");
            Walking.walk(TREES.getRandomTile());
            sleep(Calculations.random(1000, 1500));
    
        }
    }
    Edited by mankel200
    Link to comment
    Share on other sites

    You have to implement ChatListener in your AbstractScript class:

    zMl7bTN.png

     

    Then in the same class you Override the specific method you want to use. For ChatListener all the methods are optional to Override since implementing ChatListener gives u access to all types of Messages (GameMessage, PlayerMessage, etc). The method onMessage captures all messages that u can filter thru whereas the method onGameMessage only captures game messages.

    lAvJXCo.png

    Edited by 420x69x420
    Link to comment
    Share on other sites

    Everything 420 said is correct. Also onMessage captures gameMessages that gameMessage doesn't, like player being frozen. So personally I only use that.
    Just make sure to filter it with:

    @Override
    public void onMessage(Message message)
    {
        String gameMessage = message.getMessage();
        if (message.getUsername().equals(""))
        {
            log("Not said by user");
            if(gameMessage.contains("You have been frozen!") && !isFrozen)
            {
                log("Player has been frozen");
            }
        }
    }

    So its not triggered if a person types what a game message contains

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • 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.