Shoutbox

[help] my first script.. - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [help] my first script.. (/showthread.php?tid=61502)

[help] my first script.. by mltz2plz on 06-26-2006 at 05:58 AM

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.
RE: [help] my first script.. by Matti on 06-26-2006 at 06:22 AM

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... :)
RE: [help] my first script.. by mltz2plz on 06-26-2006 at 06:32 AM

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.


RE: [help] my first script.. by can16358p on 06-26-2006 at 07:19 AM

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.


RE: [help] my first script.. by mltz2plz on 06-26-2006 at 01:44 PM

ok well i've been trying with your simplified code and that variable thing and it keep saying originalPSM undefined


RE: RE: [help] my first script.. by The Brain on 06-26-2006 at 03:26 PM

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;
}



RE: [help] my first script.. by mltz2plz on 06-27-2006 at 09:49 AM

thanks