What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » AddTimer makes msn crash

AddTimer makes msn crash
Author: Message:
Dauntless
Junior Member
**


Posts: 16
– / Male / –
Joined: Aug 2006
O.P. AddTimer makes msn crash
Hi,

What I'm trying to do, is this:

[you type] /countdown
[send msg]5
[send msg]4
[send msg]3
[send msg]2
[send msg]1
[send msg]"Happy Newyear"

This is what I have so far:
code:
var counter = 6;
var currentCW;
var counting = false;

function OnEvent_Initialize(MessengerStart)
{
    Debug.trace(" ");
    Debug.trace("------------------ My Script initialised ------------------");
    Debug.trace(" ");
}

function OnEvent_Uninitialize(MessengerExit)
{
}

function OnEvent_ChatWndSendMessage(chatWnd, msg)
{
    if(counting)
    {
        return "";
    }
    var isCommand = checkCommand(msg);
    if(isCommand)
    {
        var command = getCommand(msg);
        switch (command)
        {           
            case "countdown":
                counting = true;
                countDown(chatWnd);
                return "";
                break;
               
            default:
                break;
        }
    }
    else
    {
        return msg;
    }
}

function countDown(chatWnd)
{
    currentCW = chatWnd;
    MsgPlus.AddTimer("commandCountDown", 500);
}

function onEvent_Timer()
{
    counter --;
    Debug.trace("counter = "+counter);
    if(counter == 0)
    {
        counting = false;
        sendMessage("Happy New Year!");
    }
    else
    {
        Debug.trace("Else");
        sendMessage(counter);
    }
}

function sendMessage(msg)
{
    currentCW.sendMessage(msg)
}

function getCommand(msg)
{
    var msgArray = msg.split(" ");
    var command = msgArray[0].substr(1);
    return command;
}

function checkCommand(msg)
{
    if(msg.charAt(0) == "/")
    {
        if(msg.charAt(1) == "/")
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    else
    {
        return false;
    }

}
(I know this code could be A LOT shorter, but i'm trying to do it as well-structured as possible).

I think the problem is that every time a message is sent, the OnEvent_ChatWndSendMessage is called (so not just, when I type something, but also when msn sends out a message (window.sendMessage();).

I thought this would be fixed by the 'counting' var but appearantly, it is not.
I also created an extra variable 'currentCW' because I didn't know how to keep track of the current window, while going from AddTimer to onEvent_Timer


And lastly: Does type-casting exist in JScript?
'cause now, i have this:
sendMessage(counter);

but sendMessage requires a string, not a number. Is it automaticly being casted? (And is there a way to do it manually ?)

All help is welcome :).
08-10-2006 12:08 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
AddTimer makes msn crash - by Dauntless on 08-10-2006 at 12:08 AM
RE: AddTimer makes msn crash - by Silentdragon on 08-10-2006 at 12:36 AM
RE: RE: AddTimer makes msn crash - by Dauntless on 08-10-2006 at 12:49 AM
RE: AddTimer makes msn crash - by cloudhunter on 08-10-2006 at 01:09 AM
RE: AddTimer makes msn crash - by Silentdragon on 08-10-2006 at 03:17 AM
RE: RE: AddTimer makes msn crash - by Dauntless on 08-10-2006 at 07:45 AM
RE: AddTimer makes msn crash - by Silentdragon on 08-10-2006 at 07:51 AM
RE: AddTimer makes msn crash - by RaceProUK on 08-10-2006 at 08:43 AM
RE: RE: AddTimer makes msn crash - by Dauntless on 08-10-2006 at 08:49 AM
RE: AddTimer makes msn crash - by -dt- on 08-10-2006 at 08:56 AM
RE: AddTimer makes msn crash - by Dauntless on 08-10-2006 at 08:57 AM
RE: AddTimer makes msn crash - by -dt- on 08-10-2006 at 09:05 AM
RE: RE: AddTimer makes msn crash - by Dauntless on 08-10-2006 at 09:10 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On