Jump to content

Need help with reading message from chatbox and doing stuff if it contains something. debug my code please


sarthycool

Recommended Posts

  Reveal hidden contents

 

 

The message to be read from player in chatbox.

Edited by sarthycool
Link to comment
Share on other sites

  On 6/8/2016 at 8:07 PM, sarthycool said:
  Reveal hidden contents

 

 

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

Link to comment
Share on other sites

  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.

Link to comment
Share on other sites

  On 6/8/2016 at 8:15 PM, Eagle Scripts said:

onMessage should work, i use it with many scripts.

 

  Reveal hidden contents

 

 

This is the code now. The line marked in red is giving error.  

Edited by sarthycool
Link to comment
Share on other sites

  On 6/8/2016 at 8:20 PM, sarthycool said:
  Reveal hidden contents

 

 

This is the code now. The line marked in red is giving error.  

String Txt = message.getMessage().toLowerCase(); try this

Link to comment
Share on other sites

  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();
}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...