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

Need scripting help
Author: Message:
Juffle
New Member
*


Posts: 2
Joined: Jan 2011
O.P. Need scripting help
Hi,

I'm trying to write a script that when I log on from my cell phone messenger client that my home PC messenger change my Display Picture to a mobile picture, then wait 10 mins of idle and change it again to another DP then wait 2 mins and change it back to my default one.

So far I've writen this but it dosent work at all... What I'm doing wrong ?

I would really appreciate some help as I'm not used in jscripting.

Thank you

Juffle

-----Code-----

var mobileCode = "(mp)";

function OnEvent_MyNameChange(NewName) {
    if (Messenger.MyName.lastIndexOf(mobileCode)) {
        MsgPlus.AddTimer(on,5000);
    }
}


function OnEvent_Timer(TimerId) {
    if (TimerId == "on") {
        Messenger.MyDisplayPicture = MsgPlus.ScriptFilesPath + "\\images\\mobile_on.gif";
        MsgPlus.AddTimer(off,600000);
    }
    else if (TimerId == "off") {
        Messenger.MyDisplayPicture = MsgPlus.ScriptFilesPath + "\\images\\mobile_off.gif";
        MsgPlus.AddTimer(default,120000);
    }
    else if (TimerId == default) {
        Messenger.MyDisplayPicture = MsgPlus.ScriptFilesPath + "\\images\\default.gif";
        Messenger.MyName = Messenger.MyName.replace(mobileCode,"");
    }
}


function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {
    if (Origin == Messenger.MyName) {
        if (Messenger.MyName.lastIndexOf(mobileCode)) {
            MsgPlus.CancelTimer(off);
            MsgPlus.CancelTimer(default);
            MsgPlus.AddTimer(on,5000);
        }
    }
}

---End Of Code-----
01-23-2011 09:30 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Need scripting help
For starters:

on, off and default are strings.
And thus there should be quotes around those strings.

You did it twice good in if (TimeId == "on" ) and if (TimeId == "off" ). But all the other occurances of those strings lack the quotes (and thus are threated as undefined variables)....



Another thing you might want to consider: Timers do not stop running after you've signed out!

This means that if you are signed out for some reason, the timers will still keep on running (until they fire). At which time you might not be signed in once again and thus an error will occur when the timer event tries to set your display picture. Similar stuff will happen when you sign out and someone else  (or you with another identity) signs in after that; the timers might still be running and the other person's display picture will be set instead....

To solve this _extremely common_ mistake, simply cancel all the used timers in a OnEvent_SignOut event.

;)

This post was edited on 01-24-2011 at 01:25 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
01-24-2011 01:19 AM
Profile PM Find Quote Report
Juffle
New Member
*


Posts: 2
Joined: Jan 2011
O.P. RE: Need scripting help
Thank you for pointing that out, but I've noticed that the "OnEvent_MyNameChange" dosent get triggered when the name change occur from another client changing the name even if the name actualy change. So this make my idea useless.
01-24-2011 01:33 AM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Need scripting help
quote:
Originally posted by Juffle
Thank you for pointing that out, but I've noticed that the "OnEvent_MyNameChange" dosent get triggered when the name change occur from another client changing the name even if the name actualy change. So this make my idea useless.
it doesn't? but the display picture does change? hmmm .... didn't knew that (never tried something like that before with MPOP either).

btw, make sure you actually do change the name on your mobile after you signed in on your mobile phone. Thus, first sign in, then change the name. A name change event wont fire when you sign in with another name than before. The code must actually 'see' the name change happening live so to speak.

Another way would be to send a remote command and check upon that in the OnEvent_ChatWndReceiveMessage event... like !Mobile or something.. Actually, I dunno if it needs to be a remote command, since stuff said on your mobile phone is normally mimiced on your PC because of the MPOP feature. So, it might be that a normal command would do fine.

Again, I never tried something like this so I dunno exactly how everything will behave in those circumstances (and I can't test at this moment either), so you'll have to do some tests yourself.... or wait for someone who has tried it before.

Either way... appart from those small (but nevertheless crucial) mistakes of forgetting the quotes around those strings, I think you have the hang of it and seem to have the proper knowhow to pull this of on your own in a good manner though.....

;)

This post was edited on 01-24-2011 at 01:49 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
01-24-2011 01:44 AM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: Need scripting help
quote:
Originally posted by Juffle
I've noticed that the "OnEvent_MyNameChange" dosent get triggered when the name change occur from another client changing the name even if the name actualy change

Just to clarify, which version of WLM are you using and does the event fire when you change your name on the local machine?
<Eljay> "Problems encountered: shit blew up" :zippy:
01-24-2011 12:31 PM
Profile 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