Jump to content

How to send an ingame message?


Recommended Posts

Posted

I can't figure out how to send a message ingame, I can figure out how to send key events to the bot but I don't think splitting strings to char arrays and for looping through them to send messages is very efficient lol.

Is there a better way? I can't find one in the API and have thoroughly googled.

Posted

 

Edit:

messages = (ArrayList<String>) getChatbox().getMessages(MessageType.PLAYER);
    	String message;
    	if(messages.size() > 0) {
    		message = messages.get(messages.size() - 1);
    	} else {
    		message = "";
    	}

This code works when the bot loads, but after the chatbox updates with a new public message it crashes with an indexOutOfBounds exception: -1 @line 45

After researching this it seems others have this issue and it might have been a game update that broke this function? :( 

Posted

Edit:

messages = (ArrayList<String>) getChatbox().getMessages(MessageType.PLAYER);
    	String message;
    	if(messages.size() > 0) {
    		message = messages.get(messages.size() - 1);
    	} else {
    		message = "";
    	}
This code works when the bot loads, but after the chatbox updates with a new public message it crashes with an indexOutOfBounds exception: -1 @line 45

After researching this it seems others have this issue and it might have been a game update that broke this function? sad.png

Don't cast it like that. Just use the array.

Posted (edited)

Don't cast it like that. Just use the array.

 

Eclipse throws an error when I don't cast ArrayList<String> for some reason. I think I'll clean and rebuild my project and see if that resolves.

 

Edit: Clean > Rebuild resolved the issue.

Edited by Spork

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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