What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Some big help I need

Some big help I need
Author: Message:
SR01001010
New Member
*


Posts: 4
Joined: Jan 2010
O.P. Some big help I need
On an event of someone signing in, how can I have it so it automatically opens a selected contact and says a certain thing? Eg:

// contact signs in

// if contact email = "myfriendexample135"hotmail.co.uk"
//{
//open window for chat with this person
ChatWnd.SendMessage("Hello mate!");
//}

Some help would be nice :D
07-08-2010 07:36 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Some big help I need
js code:
function OnEvent_ContactSignin(sEmail) {
    // Make sure they are my friend
    if (sEmail === 'myfriendexample135@hotmail.co.uk') {
        // Make sure the contact isn't blocked
        if (Messenger.MyContacts.GetContact(sEmail).Blocked === false) {
            Messenger.OpenChat(sEmail).SendMessage('Hello mate!');
        }
    }
}
07-08-2010 07:39 PM
Profile E-Mail PM Find Quote Report
ultimatebuster
Junior Member
**


Posts: 17
Joined: Oct 2008
RE: Some big help I need
or better yet

js code:
var CONTACTS = "johnsmith@hotmail.com, abcdefg@hotmail.com";

function OnEvent_Signin(Email){
    if (CONTACTS.indexOf(Email) != -1){
        if (!Messenger.MyContacts.GetContact(Email).Blocked) {
            Messenger.OpenChat(Email).SendMessage('Hi!);
        }
    }
}

This post was edited on 07-09-2010 at 02:37 AM by ultimatebuster.
07-09-2010 02:36 AM
Profile E-Mail PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
RE: Some big help I need
quote:
Originally posted by ultimatebuster
js code:
var CONTACTS = "johnsmith@hotmail.com, abcdefg@hotmail.com";

function OnEvent_Signin(Email){
    if (CONTACTS.indexOf(Email) != -1){
        if (!Messenger.MyContacts.GetContact(Email).Blocked) {
            Messenger.OpenChat(Email).SendMessage('Hi!);
        }
    }
}


If you want to check multiple contacts, you would be better off with an array.
js code:
var Contacts = ["johnsmith@hotmail.com", "abcdefg@hotmail.com"];

function OnEvent_Signin(Email)
{
    for (var X in Contacts)
    {
        if (Contacts[X] === Email)
        {
            if (!Messenger.MyContacts.GetContact(Email).Blocked)
            {
                Messenger.OpenChat(Email).SendMessage("Hi!");
            }
            break;
        }
    }
}

PS: you also seemed to miss the end quote for the sent message.  :)
quote:
Originally posted by ultimatebuster
js code:
Messenger.OpenChat(Email).SendMessage('Hi!);

07-09-2010 08:12 AM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Some big help I need
And if you want to improve even further upon that code snippet, you go for a fast numeric loop instead of a slower property enumeration loop.

js code:
var Contacts = ["johnsmith@hotmail.com", "abcdefg@hotmail.com"];

function OnEvent_Signin(Email)
{
>>>    for (var i=0, len=Contacts.length; i < len; ++i)<<<
    {
        if (Contacts[i] === Email)
        {
            // <snipped>
        }
    }
}
Or with a reverse while loop:
js code:
function OnEvent_Signin(Email)
{
>>>    var i = Contacts.length;<<<
>>>    while(i--)<<<
    {
        if (Contacts[i] === Email)
        {
            // <snipped>
        }
    }
}
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
07-09-2010 12:55 PM
Profile E-Mail PM Web Find Quote Report
SR01001010
New Member
*


Posts: 4
Joined: Jan 2010
O.P. RE: Some big help I need
Thankyou everyone I'll get on my project asap thanks again
07-09-2010 11:51 PM
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