sarthycool Posted June 8, 2016 Share Posted June 8, 2016 (edited) Reveal hidden contents package doubling; import java.awt.Graphics2D; import java.lang.Thread.State; import java.util.List; import org.osbot.rs07.api.Chatbox; import org.osbot.rs07.api.Chatbox.MessageType; import org.osbot.rs07.script.API; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "respond", author = "", version = 1.0, info = "", logo = "") public class doubling extends Script { @Override public void onStart() { log("started"); } @Override public void onExit() { log("ended!"); } public void onMessage(String m) throws InterruptedException{ } @Override public int onLoop() throws InterruptedException { List<String> m = chatbox.getMessages(MessageType.PLAYER); if (m.contains("hey")){ log("someone said it"); String a = new String("somethinga"); String b = new String("somethingb"); String c = new String("somethingc"); int r = random(1, 3); if(r%2 == 0){ keyboard.typeString(a); log("said" + a); sleep(500); } if(r == 1){ keyboard.typeString(b); log("said" + b); sleep(400); } if(r == 3){ keyboard.typeString©; log("said" + c); sleep(500); } } return 215; //The amount of time in milliseconds before the loop starts over } @Override public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) } } The message to be read from player in chatbox. Edited June 8, 2016 by sarthycool Quote Link to comment Share on other sites More sharing options...
Saiyan Posted June 8, 2016 Share Posted June 8, 2016 On 6/8/2016 at 8:07 PM, sarthycool said: Reveal hidden contents package doubling; import java.awt.Graphics2D; import java.lang.Thread.State; import java.util.List; import org.osbot.rs07.api.Chatbox; import org.osbot.rs07.api.Chatbox.MessageType; import org.osbot.rs07.script.API; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "respond", author = "", version = 1.0, info = "", logo = "") public class doubling extends Script { @Override public void onStart() { log("started"); } @Override public void onExit() { log("ended!"); } public void onMessage(String m) throws InterruptedException{ } @Override public int onLoop() throws InterruptedException { List<String> m = chatbox.getMessages(MessageType.PLAYER); if (m.contains("hey")){ log("someone said it"); String a = new String("somethinga"); String b = new String("somethingb"); String c = new String("somethingc"); int r = random(1, 3); if(r%2 == 0){ keyboard.typeString(a); log("said" + a); sleep(500); } if(r == 1){ keyboard.typeString(b); log("said" + b); sleep(400); } if(r == 3){ keyboard.typeString©; log("said" + c); sleep(500); } } return 215; //The amount of time in milliseconds before the loop starts over } @Override public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) } } The message to be read from player in chatbox. try using onMessage? since chatboxGetMessages will get all the messages including old ones i think and onMessage gets the new ones or somethng lol Quote Link to comment Share on other sites More sharing options...
Eagle Scripts Posted June 8, 2016 Share Posted June 8, 2016 You could work with onMessage public void onMessage(Message message) throws java.lang.InterruptedException{ String Txt = message.getMessage().toLowerCase(); if(Txt.contains("hey")) { log("HE said it"); } } Quote Link to comment Share on other sites More sharing options...
sarthycool Posted June 8, 2016 Author Share Posted June 8, 2016 On 6/8/2016 at 8:12 PM, Eagle Scripts said: You could work with onMessage public void onMessage(Message message) throws java.lang.InterruptedException{ String Txt = message.getMessage().toLowerCase(); if(Txt.contains("hey")) { log("HE said it"); } } The whole code which is in onLoop() was in onMessage(). It did not work even then. Quote Link to comment Share on other sites More sharing options...
Eagle Scripts Posted June 8, 2016 Share Posted June 8, 2016 On 6/8/2016 at 8:13 PM, sarthycool said: The whole code which is in onLoop() was in onMessage(). It did not work even then. onMessage should work, i use it with many scripts. Quote Link to comment Share on other sites More sharing options...
sarthycool Posted June 8, 2016 Author Share Posted June 8, 2016 (edited) On 6/8/2016 at 8:15 PM, Eagle Scripts said: onMessage should work, i use it with many scripts. Reveal hidden contents package doubling; import java.awt.Graphics2D; import java.lang.Thread.State; import java.util.List; import org.osbot.rs07.api.Chatbox; import org.osbot.rs07.api.Chatbox.MessageType; import org.osbot.rs07.script.API; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "respond", author = "", version = 1.0, info = "", logo = "") public class doubling extends Script { @Override public void onStart() { log("started"); } @Override public void onExit() { log("ended!"); } public void onMessage(String m) throws InterruptedException{ String m = message.getMessages(MessageType.PLAYER); if (m.contains("Repaid")){ log("someone said repaid"); String a = new String("wow!"); String b = new String("Thank you! <3"); String c = new String("<3 <3"); int r = random(1, 3); if(r%2 == 0){ keyboard.typeString(a); log("said" + a); sleep(500); } if(r == 1){ keyboard.typeString(b); log("said" + b); sleep(400); } if(r == 3){ keyboard.typeString©; log("said" + c); sleep(500); } } } @Override public int onLoop() throws InterruptedException { return 215; //The amount of time in milliseconds before the loop starts over } @Override public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) } } This is the code now. The line marked in red is giving error. Edited June 8, 2016 by sarthycool Quote Link to comment Share on other sites More sharing options...
Saiyan Posted June 8, 2016 Share Posted June 8, 2016 On 6/8/2016 at 8:20 PM, sarthycool said: Reveal hidden contents package doubling; import java.awt.Graphics2D; import java.lang.Thread.State; import java.util.List; import org.osbot.rs07.api.Chatbox; import org.osbot.rs07.api.Chatbox.MessageType; import org.osbot.rs07.script.API; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "respond", author = "", version = 1.0, info = "", logo = "") public class doubling extends Script { @Override public void onStart() { log("started"); } @Override public void onExit() { log("ended!"); } public void onMessage(String m) throws InterruptedException{ String m = message.getMessages(MessageType.PLAYER); if (m.contains("Repaid")){ log("someone said repaid"); String a = new String("wow!"); String b = new String("Thank you! <3"); String c = new String("<3 <3"); int r = random(1, 3); if(r%2 == 0){ keyboard.typeString(a); log("said" + a); sleep(500); } if(r == 1){ keyboard.typeString(b); log("said" + b); sleep(400); } if(r == 3){ keyboard.typeString©; log("said" + c); sleep(500); } } } @Override public int onLoop() throws InterruptedException { return 215; //The amount of time in milliseconds before the loop starts over } @Override public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) } } This is the code now. The line marked in red is giving error. String Txt = message.getMessage().toLowerCase(); try this Quote Link to comment Share on other sites More sharing options...
sarthycool Posted June 8, 2016 Author Share Posted June 8, 2016 On 6/8/2016 at 8:45 PM, Saiyan said: String Txt = message.getMessage().toLowerCase(); try this Doesnt work. 'message' is being underlined. The error is "message cannot be resolved". Quote Link to comment Share on other sites More sharing options...
Explv Posted June 9, 2016 Share Posted June 9, 2016 On 6/8/2016 at 8:53 PM, sarthycool said: Doesnt work. 'message' is being underlined. The error is "message cannot be resolved". Your function definition is this: public void onMessage(String m) throws InterruptedException { } It should be: @Override public void onMessage(Message message) throws InterruptedException { } And now the Message variable is called message so: @Override public void onMessage(Message message) throws InterruptedException { String text = message.getMessage().toLowerCase(); } Quote Link to comment Share on other sites More sharing options...