January 15, 20188 yr 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
January 15, 20188 yr 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, 20188 yr by DrizzyBot
January 15, 20188 yr just implement onMessage inside your script and it will check messages make sure the message type == Game
January 16, 20188 yr 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'
January 16, 20188 yr 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.
January 16, 20188 yr 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.
January 16, 20188 yr 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.
January 16, 20188 yr Author 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(); } } }
January 16, 20188 yr Author 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(); } } }
January 16, 20188 yr Author What causes the client to crash? Having problems with the whole client freezing upon starting the script
January 17, 20188 yr 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.
Create an account or sign in to comment