damufinmkan Posted August 5, 2016 Share Posted August 5, 2016 Hello, not sure if I'm posting this in the right spot so please move if necessary. So, I'm making a script to assist my Nightmare Zone AFK training. Right now, I have it set up so that an alarm goes off when I need to drink an overload or prayer potion. Now, I want to scan the chatbox to see when a Power Surge powerup spawns. I'm trying to figure out the best way to do this. My first thought, given the API limitations, was to grab all messages in the chat of MessageType.GAME and evaluate just the most recent one, see if it's a power surge notificaiton, and if so, set the alarm. BUT, since I'm grabbing all the chat messages in a loop once every second, I think it's causing the client to crash. Is there a better way to get the most recent chatbox message without getting the whole list of messages? Or is there a way to put that part in an onLoop separate from my other code, to only scans the chatbox every 30 seconds or so? Keep in mind, I want to make sure that the alarm only beeps once, when the powerup is first available to use. Please share your thoughts. -Damufin Quote Link to comment Share on other sites More sharing options...
Team Cape Posted August 5, 2016 Share Posted August 5, 2016 (edited) chatbox.getMessages().get(chatbox.getMessages().size()-1); should get the last item in the list of messages. is that what you want...? or if you just want to check every 30 seconds: private long timeStarted; @ Override public void onStart() { timeStarted = System.currentTimeMillis(); } @ Override public int onLoop() throws InterruptedException { if((System.currentTimeMillis() - timeStarted) % 30000 == 0) { //check for surge } } Edited August 12, 2016 by Imateamcape Quote Link to comment Share on other sites More sharing options...
Chris Posted August 6, 2016 Share Posted August 6, 2016 have you tried onMessage ? Quote Link to comment Share on other sites More sharing options...