What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [help] my first script..

[help] my first script..
Author: Message:
mltz2plz
New Member
*

Avatar
^^Adopt a kleppet^^ www.Kleppets.tk

Posts: 14
34 / Male / –
Joined: Oct 2004
O.P. [help] my first script..
Hey, well i'm just sort of playing around and stuff trying to figure out the whole scripting thing. I've made a small script that doesn't work exactly how i wanted. What it does is when you change your status it adds a "note" at the front of your PSM saying whatever you wish, eg. if you set your status to "out to lunch" it will say "Shh! eating. - (old psm here)". or whatever you put for it to say.

heres the script so far:

code:


function OnEvent_MyStatusChange(Stat) {

//Appear Offline - Set the PSM between the ""
           if(Stat == 2) {
    Messenger.MyPersonalMessage = "I'm appearing offline " + " - " + Messenger.MyPersonalMessage + "";
//Online - Set the PSM between the ""
    } else if(Stat == 3) {
    Messenger.MyPersonalMessage = "Online" + " - "+ Messenger.MyPersonalMessage + "";   
//Busy - Set the PSM between the ""   
    } else if(Stat == 4) {
    Messenger.MyPersonalMessage = "I'm busy" + " - " + Messenger.MyPersonalMessage + "";   
//Be Right Back - Set the PSM between the ""   
    } else if(Stat == 5) {
    Messenger.MyPersonalMessage = "I will be right back" + " - " + Messenger.MyPersonalMessage + "";   
//Idle - Set the PSM between the ""   
    } else if(Stat == 6) {
    Messenger.MyPersonalMessage = "Idle" + " - " + Messenger.MyPersonalMessage + "";   
//Away - Set the PSM between the ""
    } else if(Stat == 7) {
    Messenger.MyPersonalMessage = "I'm away" + " - " + Messenger.MyPersonalMessage + "";   
//In a Call - Set the PSM between the ""   
    } else if(Stat == 8) {
    Messenger.MyPersonalMessage = "Shh! Im in a call" + " - " + Messenger.MyPersonalMessage + "";   
//Out to Lunch - Set the PSM between the ""   
    } else if(Stat == 9) {
    Messenger.MyPersonalMessage = "Mmm, Im eating!" + " - " + Messenger.MyPersonalMessage + "";
    }
    }



now, my problem is that when a person changes their status it will work how i wanted, eg

*change to online*
"online - this is the old personal message"

but then say they change their status to busy it will show up like this:
"Busy - Online - this is hte old personal message"

is there a way i can get rid of the "online -" i'm pretty sure it is possible but am not too sure how to do it. please help.
thanks in advanced, nick.
[Image: s116.PNG]
:^) www.NickzPlace.tk - www.Kleppets.tk
06-26-2006 05:58 AM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: [help] my first script..
You can save the original personal message first in a variable, like this:
code:
function OnEvent_Signin() {
var originalPSM = Messenger.MyPersonalMessage;
}
Also, I recommend to use a switch case block instead of using every time if elseif. It makes the code easier to read. ;)
Here's a simplified version for your script:
code:
function OnEvent_MyStatusChange(Stat) {
switch(Stat) {
    //Appear Offline
    case 2:
    Messenger.MyPersonalMessage = "I'm appearing offline - " + originalPSM;
    break;
    //Online
    case 3:
    Messenger.MyPersonalMessage = "Online - " + originalPSM;
    break;
    //Busy
    case 4:
    Messenger.MyPersonalMessage = "I'm busy - " + originalPSM;
    break;
    //Be Right Back
    case 5:
    Messenger.MyPersonalMessage = "I will be right back - " + originalPSM;
    break;
    //Idle
    case 6:
    Messenger.MyPersonalMessage = "Idle - " + originalPSM;
    break;
    //Away
    case 7:
    Messenger.MyPersonalMessage = "I'm away - " + originalPSM;
    break;
    //In a call
    case 8:
    Messenger.MyPersonalMessage = "Shh! I'm in a call - " + originalPSM;
    break;
    //In a call
    case 9:
    Messenger.MyPersonalMessage = "Mmm, I'm eating! - " + originalPSM;
    break;
}
As you can see, every case block ends in a break statement. This is because if you don't, it will execute all the other code too! :o

I hope that helps... :)

This post was edited on 06-26-2006 at 06:23 AM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
06-26-2006 06:22 AM
Profile E-Mail PM Web Find Quote Report
mltz2plz
New Member
*

Avatar
^^Adopt a kleppet^^ www.Kleppets.tk

Posts: 14
34 / Male / –
Joined: Oct 2004
O.P. RE: [help] my first script..
Hey thanks for the help. i'm just starting out so i dont really know much about what i'm doing so thanks for your help.
[Image: s116.PNG]
:^) www.NickzPlace.tk - www.Kleppets.tk
06-26-2006 06:32 AM
Profile E-Mail PM Web Find Quote Report
can16358p
Junior Member
**

WLM + MP!L User

Posts: 58
34 / Male / –
Joined: Oct 2005
Status: Away
RE: [help] my first script..
Also, don't forget updating originalPSM when the user changes it. I'm new to (Plus) scripting too so I don't remember the event names, but you can easily find that event in the documentation.
[Image: anathema.gif][Image: hax0r.png]
06-26-2006 07:19 AM
Profile E-Mail PM Find Quote Report
mltz2plz
New Member
*

Avatar
^^Adopt a kleppet^^ www.Kleppets.tk

Posts: 14
34 / Male / –
Joined: Oct 2004
O.P. RE: [help] my first script..
ok well i've been trying with your simplified code and that variable thing and it keep saying originalPSM undefined
[Image: s116.PNG]
:^) www.NickzPlace.tk - www.Kleppets.tk
06-26-2006 01:44 PM
Profile E-Mail PM Web Find Quote Report
The Brain
Junior Member
**

Avatar

Posts: 49
Reputation: 1
– / Male / Flag
Joined: Jan 2003
RE: RE: [help] my first script..
quote:
Originally posted by Mattike
You can save the original personal message first in a variable, like this:
code:
function OnEvent_Signin() {
var originalPSM = Messenger.MyPersonalMessage;
}


you will have to define the originalPSM variable outside of the function

code:
var originalPSM;
function OnEvent_Signin()
{
        originalPSM = Messenger.MyPersonalMessage;
}



This post was edited on 06-26-2006 at 03:26 PM by The Brain.
06-26-2006 03:26 PM
Profile PM Web Find Quote Report
mltz2plz
New Member
*

Avatar
^^Adopt a kleppet^^ www.Kleppets.tk

Posts: 14
34 / Male / –
Joined: Oct 2004
O.P. RE: [help] my first script..
thanks
[Image: s116.PNG]
:^) www.NickzPlace.tk - www.Kleppets.tk
06-27-2006 09:49 AM
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