What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Need some help with script

Need some help with script
Author: Message:
Barathrum
Junior Member
**

Avatar
.......................

Posts: 42
30 / Male / Flag
Joined: Nov 2009
O.P. Need some help with script
Hello I have this script here:

code:
function OnEvent_ChatWndReceiveMessage(oChatWnd, Email) {
if(Email == "gregorsturm12@hotmail.com") //Change to your target email.
    {
         oChatWnd.SendMessage('You are Ignored'); // Type thetext to be writen within the ' '
    }
}

I need someone to edit it so, that everytime "gregorsturm12@hotmail.com" sends a messege to the user of this script, it will send messege from the user of the script 'You are Ignored'

Currently it seems to not be working.

Thanks for help :)

This post was edited on 02-11-2010 at 07:46 PM by Barathrum.
02-11-2010 07:45 PM
Profile E-Mail PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: Need some help with script
It probably won't work - the second parameter of OnEvent_ChatWndReceiveMessage is the name of the message sender, not the e-mail.

This post was edited on 02-11-2010 at 07:51 PM by Mnjul.
02-11-2010 07:51 PM
Profile PM Web Find Quote Report
Barathrum
Junior Member
**

Avatar
.......................

Posts: 42
30 / Male / Flag
Joined: Nov 2009
O.P. RE: Need some help with script
Hmm, yeah possible, but don't know how to fix it or what to give instead
02-11-2010 08:31 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Need some help with script
Javascript code:
// declare an object container
var objChatWnd = {};
 
// store the last message sent into our container
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
    objChatWnd[oChatWnd.Handle] = sMessage;
}
 
function OnEvent_ChatWndReceiveMessage(oChatWnd, sOrigin, sMessage, nMessageKind) {
    // check if the message received is our message
    if (objChatWnd[oChatWnd.Handle] === sMessage) {
        // if it is delete the object from the container
        delete objChatWnd[oChatWnd.Handle];
        // return the message to the window
        return sMessage;       
    }
   
    // declare a variable
    var blnIgnoreContact = false;
    // loop through all contacts in the chat
    for (var oContact = new Enumerator(oChatWnd.Contacts); !oContact.atEnd(); oContact.moveNext()) {
        // check the users email
        if (oContact.item().Email === 'gregorsturm12@hotmail.com') {
            // if it matches then set our variable to true
            blnIgnoreContact = true;
        }
    }
   
    // after looping through all contacts check our variable
    if (blnIgnoreContact === true) {
        // send a message if the contact was found
        oChatWnd.SendMessage('You are ignored');
    }
}


This post was edited on 02-11-2010 at 08:45 PM by matty.
02-11-2010 08:44 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: Need some help with script
That code could be simplified even further. Look what I found in the documentation!
quote:
Contacts::GetContact
Return Value: A Contact object if the contact is found in the object's list, null otherwise.
You don't even need a loop to check whether that e-mail address is in the list of chat window contacts, just check that Contacts.GetContact(sIgnoredEmail) is not null! Even better, you don't need that flag variable at all, just put that expression straight in the if-condition! :D
Javascript code:
    // check whether the ignored contact is in this chat
    if (oChatWnd.Contacts.GetContact('gregorsturm12@hotmail.com') !== null) {
        // send a message if the contact was found
        oChatWnd.SendMessage('You are ignored');
    }

Pretty nifty, uh? :P

This post was edited on 02-11-2010 at 09:00 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
02-11-2010 09:00 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Need some help with script
Good catch I forgot about GetContact.
02-11-2010 09:12 PM
Profile E-Mail PM Find Quote Report
Barathrum
Junior Member
**

Avatar
.......................

Posts: 42
30 / Male / Flag
Joined: Nov 2009
O.P. RE: Need some help with script
Thank you all for the help, the script now works :)
02-12-2010 11:59 AM
Profile E-Mail PM 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