mankel200 0 Posted August 27, 2022 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)); } }
420x69x420 73 Posted August 27, 2022 You have to implement ChatListener in your AbstractScript class: 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.
Axolotl 31 Posted August 28, 2022 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
Recommended Posts
Archived
This topic is now archived and is closed to further replies.