[JS] Intervaled messages

Started by Anonymous, May 12, 2018, 07:06:58 AM

Previous topic - Next topic

Anonymous

var intervaledMessages = {};

intervaledMessages.enabled = true;
intervaledMessages.messages = [];
intervaledMessages.messageIndex = 0;
intervaledMessages.messageInterval = 60000;

intervaledMessages.messages[0] = 'Message 1';
intervaledMessages.messages[1] = 'Message 2';
intervaledMessages.messages[2] = 'Message 3';

if(intervaledMessages.enabled && intervaledMessages.messages.length != 0)
{
setInterval(function(){
outputChatBox(intervaledMessages.messages[intervaledMessages.messageIndex], COLOUR_BLUE);

if(intervaledMessages.messageIndex == (intervaledMessages.messages.length - 1))
intervaledMessages.messageIndex = 0;
else
intervaledMessages.messageIndex++;
}, intervaledMessages.messageInterval);
}