mickael9
Full Member
Posts: 117 Reputation: 3
33 / /
Joined: Jul 2005
|
RE: [Debug needed] Delay Script
code: var TimerParams = {};
function OnEvent_ChatWndSendMessage(ChatWnd, sMessage)
{
var regex = /^#Delay;\s?([0-9]+);\s?(.+)$/;
var match = regex.exec(sMessage);
if (match)
{
var nDelay = match[1];
var sMessage = match[2];
var sTimerName = "timerDelay_" + Math.random().toString().replace(/[^0-9]/,'');
TimerParams[sTimerName] = {"sMessage" : sMessage, "ChatWnd" : ChatWnd};
MsgPlus.AddTimer(sTimerName,nDelay);
return "";
}
}
function OnEvent_Timer(TimerId)
{
if (TimerId.indexOf("timerDelay_") == 0)
{
var sMessage = TimerParams[TimerId].sMessage;
var ChatWnd = TimerParams[TimerId].ChatWnd;
ChatWnd.SendMessage(sMessage);
delete(TimerParams[TimerId]);
}
}
works fine for me
|
|