You use "MsgPlus.AddTimer("timer",5000);" like a sleeper which stops the loop for 5 seconds. BUT the msgplus's timer is a timer which calls the function "OnEvent_Timer()" when it finish.
So you've to use it like this :
code:
var the_wnd;
var Emoticons;
var e;
function send_emoticon(wnd)
{
if(wnd.EditChangeAllowed==true)
{
Emoticons = Messenger.CustomEmoticons;
e = new Enumerator(Emoticons);
the_wnd = wnd; // Stock the chat window
OnEvent_Timer("timer_name"); // launch the timer's loop
}
}
function OnEvent_Timer(timer)
{
if(timer == "timer_name"){
var smile="";
for(var i = 0; !e.atEnd()&&i<5; e.moveNext(), i++)smile=" "+e.item().Shortcut;
the_wnd.SendMessage(smile); // Send the 5 smilies
Debug.Trace(smile);
if(!e.atEnd())MsgPlus.AddTimer("timer_name", 5000); // If not finished yet, recall the function in 5 seconds
}
}
Hope you understand !
EDIT : Not tried but should works, otherwise it's enough to help you about your project i think.