What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » im having troble with my script

im having troble with my script
Author: Message:
killa
New Member
*


Posts: 3
Joined: Aug 2007
O.P. im having troble with my script
im makeing an update to my script and im adding a command to logme out with a command but i keep getting this error
code:
Error: Object expected (code: -2146823281)
       File: brb.js. Line: 26.
Function OnEvent_ChatWndSendMessage returned an error. Code: -2147352567
what does it mean cause im new to this
here the code

code:
function notify(msg){
    msg = MsgPlus.RemoveFormatCodes(msg);
    MsgPlus.DisplayToast("brb", msg, "");
}




function OnEvent_ChatWndSendMessage(ChatWnd,Message){

    if(Message == "brb"){

           
       
       
        notify("locking msn.");
        MsgPlus.LockMessenger('True');
        return '';
}
    if(Message == '/logout'){

           
       
       
        SendMessage('/all');
        SendMessage('/close');

        notify('login out.');
        Signout();
       


    }
}
sorry iv fixed it now i had to add chatwnd to sendmessage and messenger to signout

This post was edited on 08-06-2007 at 05:44 PM by killa.
08-06-2007 05:23 PM
Profile E-Mail PM Find Quote Report
pollolibredegrasa
Full Member
***

Avatar
formerly fatfreechicken

Posts: 483
Reputation: 34
35 / Male / Flag
Joined: May 2005
RE: im having troble with my script
Signout(); should be Messenger.Signout();

code:
SendMessage('/all');
SendMessage('/close');
You don't actually need to do these, as the Signout() function does this automatically. However, the reason it isnt working is because SendMessage is a function of a ChatWnd, so using your code it should be ChatWnd.SendMessage('Message to send').

Also, instead of multiple if statements, use a select case. The following code seems to do what you want:

code:
function notify(msg){
    msg = MsgPlus.RemoveFormatCodes(msg);
    MsgPlus.DisplayToast('brb', msg, '');
}

function OnEvent_ChatWndSendMessage(ChatWnd,Message){
    switch (Message){
        case 'brb':
            notify('locking msn.');
            MsgPlus.LockMessenger('True');   
            return '';
        case '/logout':
            notify('login out.');
            Messenger.Signout();
    }
}


Hope this helps :)
;p

[Image: chickennana.gif] Vaccy is my thin twin! [Image: chickennana.gif]
08-06-2007 05:53 PM
Profile PM Find Quote Report
killa
New Member
*


Posts: 3
Joined: Aug 2007
O.P. RE: im having troble with my script
hy thanks i never knowen how to do cases thank you

This post was edited on 08-07-2007 at 01:43 PM by killa.
08-07-2007 01:40 PM
Profile E-Mail PM Find Quote Report
Volv
Skinning Contest Winner
*****

Avatar

Posts: 1233
Reputation: 31
34 / Male / Flag
Joined: Oct 2004
RE: im having troble with my script
quote:
SendMessage('/all');
SendMessage('/close');
And you need SendMessage('/all /close'); instead...
08-07-2007 01:55 PM
Profile PM Find Quote Report
killa
New Member
*


Posts: 3
Joined: Aug 2007
O.P. RE: im having troble with my script
i need some more help iv now added if some one says bye its says hurry up or get lost ill kill you whoever
jk jk
then if i say bye i say it to my self
heres the code
dont take out activate thats so my mom carnt use them
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message1, MessageKind)
{

switch(Message1)
{
case "brb":
if (activate == 1)
{
ChatWnd.SendMessage('okey dokey');
}
break
case "bye":
if (activate == 1)
{
ChatWnd.SendMessage('ok if u dont get lost soon i will kill you '+ Origin);
ChatWnd.SendMessage('jk jk');
}
break
}
}

08-08-2007 10:00 AM
Profile E-Mail PM Find Quote Report
Volv
Skinning Contest Winner
*****

Avatar

Posts: 1233
Reputation: 31
34 / Male / Flag
Joined: Oct 2004
RE: im having troble with my script
First, it would be a lot easier to have the switch nested inside the activate check, instead of having a whole bunch of activate checks.

Secondly, as said in the Scripting Docs (here), the ChatWndReceiveMessage event is triggered whenever anything is added to the history box in a chat window which includes messages sent by yourself. As such you must compare the Origin parameter to your current nickname to check that it was not you who sent the message before making any responses.

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message1, MessageKind)
{

if (activate == 1 && Origin != Messenger.MyName) {
    switch(Message1)
    {
        case "brb":
        ChatWnd.SendMessage('okey dokey');
        break;

        case "bye":
        ChatWnd.SendMessage('ok if u dont get lost soon i will kill you '+ Origin);
        ChatWnd.SendMessage('jk jk');
        break;
    }
}

}

NOTE: A known limitation is that if a user uses the exact same nickname as yourself they will be recognised as you, and as such will not be responded to by the script.

This post was edited on 08-08-2007 at 10:42 AM by Volv.
08-08-2007 10:40 AM
Profile PM Find Quote Report
LifelesS
Full Member
***


Posts: 115
Reputation: 4
31 / Male / Flag
Joined: Dec 2006
RE: im having troble with my script
You could have it done with 2 arrays, like:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
    var receive = new Array("brb", "bye");                                                //on this array you store the arriving messages
    var send = new Array("okey dokey", "ok if u dont get lost soon i will kill you\njk jk");    //on this array you store the sending messages
    //note that they have to match in the array order

    if(Origin != Messenger.MyName && activate == 1)            //very important, or you would asnwer yourself if you typed brb or something lol
    {
        for(i=0; i<receive.length; i++)        //simple loop, while i less than receive.length [which in this case is 1 (zero based)] adds 1
        {
            if(Message == receive[i])        //if Message is equal to receive[i] (the first time it would be 0 which is brb)
            {
                ChatWnd.SendMessage(send[i]);//sends the message in send[i], this is y they need to match, so if receive[i] & send[i] is 0, it sends "okeydokey"
            }
        }
    }
}

it works, I've tested it :)

This post was edited on 08-08-2007 at 10:52 AM by LifelesS.
Best Regards,
Joćo Godinho
08-08-2007 10:51 AM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: im having troble with my script
Instead of doing a For Loop for an array like this:
quote:
Originally posted by LifelesS
code:
for(i=0; i<receive.length; i++)

do it like this:
code:
for(var i in arrayname)
08-08-2007 12:47 PM
Profile E-Mail PM Find Quote Report
Volv
Skinning Contest Winner
*****

Avatar

Posts: 1233
Reputation: 31
34 / Male / Flag
Joined: Oct 2004
RE: im having troble with my script
matty, unless I'm mistaken, that doesn't allow you to get the element's index in the array and hence you can't get the corresponding response =/
08-08-2007 01:01 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: im having troble with my script
quote:
Originally posted by Volv
matty, unless I'm mistaken, that doesn't allow you to get the element's index in the array and hence you can't get the corresponding response =/
No, that's why the variable i is there! Actually, it doesn't matter what method you choose, it'll always give you a loop through the array. However, if you're trying this on an object, you have to use Matty's method because an object doesn't have numeral indexes. Instead, the i variable contains the key name of the object value. For example:
code:
var FruitColors = function() {
   this.Banana = "yellow"; //"Banana" is not numeral and therefore you can't use a number to iterate through this object
   this.Apple = "red";
   this.Pear = "green";
}
var MyObject = new FruitColors();
for(var i in MyObject) {
   Debug.Trace("The color of "+i+"s is "+FruitColors[i]); //Output: "The color of Bananas is yellow" etc.
}

Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
08-08-2007 03:19 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


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