What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Script Snippit Examples?

Script Snippit Examples?
Author: Message:
Keikonium
Full Member
***


Posts: 229
Reputation: 3
35 / Male / Flag
Joined: Jul 2006
O.P. Script Snippit Examples?
Is there a place on the net where I can view examples of code with an explanation of what it does? Basically, I am a noob when it comes to JScript, and I'm not quite understanding the documentation all the well :-#.

For example, I see in the documentation for the "MsgPlus:: PlaySound" syntax. To call this function, I type "MsgPlus.PlaySound(syntax)". So what I see happening, is changing the "::" in the documentation to a single "." .

When I try to do this same thing with "Contact::Email" changing it to "Contact.Email" it gives me an error in the debug console (Error: 'Contact' is undefined (code: -2146823279)).

So I have no idea what I am doing wrong, and I don't understand why the documentation doesn't include an example or two for each property / function.

If anyone can shed some light on this for me, I'd be happy lol.

Thanks :)

This post was edited on 09-02-2008 at 11:23 PM by Keikonium.
Now Playing:
[image not working] [Image: 87cc21b0.png]
09-02-2008 11:22 PM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Script Snippit Examples?
Objects related to Plus! only have the documentation you have seen.

The problem you have is because Contact is an object returned by another function such as GetContact or an enumeration of Messenger.MyContacts
<Eljay> "Problems encountered: shit blew up" :zippy:
09-02-2008 11:32 PM
Profile PM Find Quote Report
Keikonium
Full Member
***


Posts: 229
Reputation: 3
35 / Male / Flag
Joined: Jul 2006
O.P. RE: Script Snippit Examples?
I'm still a bit confused, so how do I go about calling the objects that aren't related to Plus!?

I have tried "Contacts.GetContact(Email);" (which makes sense to me) but I still get an error :P.

I just want to display a toast that contains a contacts email when they sign in lol.

This is the code I am using:

code:
var contactMail = Contacts.GetContact(Email);
var contactName = Contacts.GetContact(Name);

// PLAYS A SOUND WHEN A CONTACT SIGNS IN
function OnEvent_ContactSignin(){
MsgPlus.DisplayToastContact("Sign In","" + contactName + "", "(" + contactMail + ")\nhas signed in.", "", "OnEvent_ToastClicked", contactMail);
}


I can get the toasts to display fine if I make the vars into text strings (just adding " and " around whatever I have there) so I know there is no problem with the toast code, it's just the vars and such.
Now Playing:
[image not working] [Image: 87cc21b0.png]
09-02-2008 11:42 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Script Snippit Examples?
Well first things first take a look at the documentation.

code:
OnEvent_ContactSignin(
        [string] Email
    );

Notice the function passes the email address as a parameter. Therefore the code you use is

code:
function OnEvent_ContactSignin(sEmail){
    Debug.Trace(sEmail);
}

Also to note that the Contact and Contacts objects are only available when you enumerate or use the Messenger.MyContacts.GetContact function.

To enumerate the object you need to do the following:

code:
for ( var oContact = new Enumerator(Messenger.MyContacts); !oContact.atEnd(); oContact.moveNext() );
    Debug.Trace( oContact.item().Email );
}

And to use the GetContact function it looks like this
code:
Debug.Trace( Messenger.MyContacts.GetContact( 'johndoe@hotmail.com' ).Email );

This post was edited on 09-02-2008 at 11:57 PM by matty.
09-02-2008 11:56 PM
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: Script Snippit Examples?
To continue on matty's post:

Since you already have the Email parameter passed to your OnEvent_Signin function, you can use that to get a Contact object for the contact who just signed in. We'll store that in a variable, such as "theContact". Then, we have a valid Contact object so we can use all of its functions and properties. The one we are interested in is the contact's name, so we make a variable "sName" to store the contact's display name in. From there, you can easily use the "sEmail" and "sName" to display a toast.
code:
function OnEvent_ContactSignin(sEmail){
    var theContact = Messenger.MyContacts.GetContact(sEmail);
    var sName = theContact.Name;
    MsgPlus.DisplayToastContact("Sign In","" + sName + "", "(" + sEmail + ")\nhas signed in.", "", "OnEvent_ToastClicked", sEmail);
}
Since you defined a callback function "OnEvent_ToastClicked" in that call, you might want to make such a function:
code:
function OnEvent_ToastClicked(sEmail) {
    //Do something useful here!
}
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
09-03-2008 11:09 AM
Profile E-Mail PM Web Find Quote Report
Keikonium
Full Member
***


Posts: 229
Reputation: 3
35 / Male / Flag
Joined: Jul 2006
O.P. RE: Script Snippit Examples?
Ah it works :D! I think I understand this now, since I've applied it to contacts starting a conversation also :).

Thanks for helping out a noob guys, it's been quite informative ^_^.

I hope to get my script out soon (almost done the basics!).
Now Playing:
[image not working] [Image: 87cc21b0.png]
09-03-2008 11:19 AM
Profile E-Mail PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Script Snippit Examples?
Snippets:

http://mpscripts.net/code.php
[Image: 1-0.png]
             
09-03-2008 02:05 PM
Profile PM Web Find Quote Report
Keikonium
Full Member
***


Posts: 229
Reputation: 3
35 / Male / Flag
Joined: Jul 2006
O.P. RE: Script Snippit Examples?
That's the first site I came across when I searched before I posted. It's got very few examples unfortunately :(
Now Playing:
[image not working] [Image: 87cc21b0.png]
09-03-2008 06:07 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Script Snippit Examples?
Dempsey is kind of busy and it takes a lot to contribute to something that bug and complex.
09-03-2008 06:21 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