quote:
Originally posted by Dauntless
quote:
Originally posted by Silentdragon
code:
if(counting)
{
return "";
}
That returns nothing making your script not work. Return msg.
If I would return msg, you would see "/countdown"... And I dont want it to display the command!
If you read your code you'd understand that because you don't do that, it causes your whole code to fail. Also doing that won't make the command show, as it returns the message if it is counting.
code:
var counter = 6;
var curWnd;
function OnEvent_ChatWndSendMessage(chatWnd, msg)
{
if(msg == "/countdown") {
curWnd = chatWnd;
MsgPlus.AddTimer("commandCountDown", 1000);
return "";
}
}
function onEvent_Timer()
{
counter--;
Debug.trace("counter = "+counter);
if(counter == 0)
curWnd.sendMessage("Happy New Year!");
else
{
curWnd.sendMessage(counter);
MsgPlus.AddTimer("commandCountDown", 1000);
}
}
Works, and is simplified.