scriptersteve Posted January 15, 2018 Share Posted January 15, 2018 Hi, I want to basically stop my script if chatbox says: You don't have the runes to cast this spell. Having some problems: trying to use chatbox.getMessages(), but keep getting errors in intellij, also just tried the normal message one but think something went wrong there: Would someone be able to show me the correct snippet for detecting this? Thanks Quote Link to comment Share on other sites More sharing options...
DrizzyBot Posted January 15, 2018 Share Posted January 15, 2018 (edited) In your onStart() method: this.getBot().addMessageListener(this); Then you can use the messageListener: public void onMessage(Message message) { String text = message.getMessage().toLowerCase(); if (text.contains("you don't have the runes")) { //They don't have the runes so do something } } Edited January 15, 2018 by DrizzyBot Quote Link to comment Share on other sites More sharing options...
Chris Posted January 15, 2018 Share Posted January 15, 2018 just implement onMessage inside your script and it will check messages make sure the message type == Game Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted January 16, 2018 Author Share Posted January 16, 2018 thanks, will try tomorrow Quote Link to comment Share on other sites More sharing options...
dreameo Posted January 16, 2018 Share Posted January 16, 2018 2 hours ago, DrizzyBot said: In your onStart() method: this.getBot().addMessageListener(this); You don't need to do that for messageListener. It's already implemented from 'Script' Quote Link to comment Share on other sites More sharing options...
The Undefeated Posted January 16, 2018 Share Posted January 16, 2018 7 hours ago, DrizzyBot said: In your onStart() method: this.getBot().addMessageListener(this); Then you can use the messageListener: public void onMessage(Message message) { String text = message.getMessage().toLowerCase(); if (text.contains("you don't have the runes")) { //They don't have the runes so do something } } Make sure to check if the message is from the game so people won't be able to log your accounts of by typing it in chatbox. Quote Link to comment Share on other sites More sharing options...
Alek Posted January 16, 2018 Share Posted January 16, 2018 He asked for a Chatbox API answer and literally every answer in here is not what he was asking for. Your IDE will tell you exactly what's wrong, please show a screenshot of the code you have. Quote Link to comment Share on other sites More sharing options...
The Undefeated Posted January 16, 2018 Share Posted January 16, 2018 15 minutes ago, Alek said: He asked for a Chatbox API answer and literally every answer in here is not what he was asking for. Your IDE will tell you exactly what's wrong, please show a screenshot of the code you have. That's probably because he doesn't know how to do it based on his other threads. His question is not based on having problems with Chatbox API but having problems with reading messages in general. Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted January 16, 2018 Author Share Posted January 16, 2018 4 hours ago, The Undefeated said: That's probably because he doesn't know how to do it based on his other threads. His question is not based on having problems with Chatbox API but having problems with reading messages in general. Yeah, i don't know how to do it :'). This is my current setup had deleted previous attempts but pretty sure they were worse :'). Current problems are the m is unable to be resolved and the = Message.MessageType(GAME) is incorrect public void onMessage(Message m){ if (m.getType() == Message.MessageType(GAME)) { String text = m.getMessage().toLowerCase(); if (text.contains("rune")) { stop(); } if(text.contains("arrow")){ stop(); } } } 5 minutes ago, scriptersteve said: Yeah, i don't know how to do it :'). This is my current setup had deleted previous attempts but pretty sure they were worse :'). Current problems are the m is unable to be resolved and the = Message.MessageType(GAME) is incorrect. Now it's just the Message.MessageType(GAME) that's wrong, fixed the other issue as i had a bracket messed up elsewhere public void onMessage(Message m){ if (m.getType() == Message.MessageType(GAME)) { String text = m.getMessage().toLowerCase(); if (text.contains("rune")) { stop(); } if(text.contains("arrow")){ stop(); } } } Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted January 16, 2018 Author Share Posted January 16, 2018 Hold up got this now and no errors so going to test it: public void onMessage(Message m){ if (m.getType() == GAME) { String text = m.getMessage().toLowerCase(); if (text.contains("rune")) { stop(); } if(text.contains("arrow")){ stop(); } } } Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted January 16, 2018 Author Share Posted January 16, 2018 What causes the client to crash? Having problems with the whole client freezing upon starting the script Quote Link to comment Share on other sites More sharing options...
dreameo Posted January 17, 2018 Share Posted January 17, 2018 It's possible you're getting a null string. Also, text.contains() may fail you later in the future for more general words. text.equals("zz") is better for more exact phrases. You might run into messages that contain other elements other then just the phrase. I believe there is something in the API that could help you out. If you can't find it, there are easy work arounds that you should figure out. Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted January 17, 2018 Author Share Posted January 17, 2018 yeah fixed what it was Quote Link to comment Share on other sites More sharing options...