Shoutbox

[HELP] Messenger.MyPersonalMessage won't assign to variable? - 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] Messenger.MyPersonalMessage won't assign to variable? (/showthread.php?tid=76665)

[HELP] Messenger.MyPersonalMessage won't assign to variable? by Kriogenic on 08-10-2007 at 12:17 AM

Hey there I am currently making a script.

I have tried assigning my personal message to a variable and the variable has always come up empty... This is what I have done...


var MyOldPM = Messenger.MyPersonalMessage;
Debug.Trace("Personal Message is " + MyOldPM);


In the debug window this is what I see
"Personal Message is "

This tells me that MyOldPM is turning up as an empty variable...

Can some one please help me with this? I don't see any reason why it should not work...

Thanks,
Kriogenic.



RE: [HELP] Messenger.MyPersonalMessage won't assign to variable? by GNSPS on 08-10-2007 at 12:26 AM

Have you got something in your PSM at all?
I can't see any reason for it not being working either...


RE: [HELP] Messenger.MyPersonalMessage won't assign to variable? by Spunky on 08-10-2007 at 12:26 AM

try

code:
Debug.Trace("Personal Messages is " + Messenger.MyPersonalMessage);


and make sure that it's not the property that is an empty string for some reason
RE: [HELP] Messenger.MyPersonalMessage won't assign to variable? by Kriogenic on 08-10-2007 at 12:33 AM

I tried

Trace.Debug("Personal Message is " + Messenger.MyPersonalMessage);

and I get

"Personal Message is testing pm is not empty

(My pm was set to testing pm is not empty)


So it is working I just have no idea why it won't assign to the variable I can set a new PM using Messenger.MyPersonalMessage = "New PM"; it just wont allow me to assign the variable :S Wierd...

Kriogenic.


RE: [HELP] Messenger.MyPersonalMessage won't assign to variable? by Spunky on 08-10-2007 at 12:34 AM

can you copy and paste the whole code in a post for me please in code tags? eg:
[code]
...
...
...
[/code]


RE: [HELP] Messenger.MyPersonalMessage won't assign to variable? by GNSPS on 08-10-2007 at 12:39 AM

For me it works just fine... Yeah you would have to post the whole code because it must be any other statement messing around with the PSM...


RE: [HELP] Messenger.MyPersonalMessage won't assign to variable? by matty on 08-10-2007 at 12:45 AM

He is either doing it outside of a function or on initialize and the Object isn't filled yet because the user isn't signed in.

code:
var myOldPsm;

function OnEvent_Initalize(bMessengerStart) {
    if (Messenger.MyStatus < 2) return false;
    myOldPsm = Messenger.MyPersonalMessage;
}

function OnEvent_SigninReady() {
    OnEvent_Intialize(true);
}

RE: [HELP] Messenger.MyPersonalMessage won't assign to variable? by Kriogenic on 08-10-2007 at 12:45 AM

Sure.....

code:
function OnEvent_ChatWndSendMessage( ChatWnd, Message )
{
    chat_window = ChatWnd;
    Command = Message.split(' ')
    switch ( Command[0].toLowerCase() )
    {
           
        case "/testing" :
                var i = 0;
        var TheOldPm = Messenger.MyPersonalMessage;
        MsgPlus.AddTimer("testing", 1000 );
        Message = '';
        return "";
        break;
   
        default:
    }
    return Message;
}

function OnEvent_Timer( TimerId )
{
    switch( TimerId )
    {
        case 'testing':
      i++
     if(i < 60){
      Messenger.MyPersonalMessage = "Timing... " + i + " Minutes have passed";
        MsgPlus.AddTimer( 'cuptime', 60000 );
}else{
Messenger.MyPersonalMessage = MyOldPM;
}
            break;

        default:
    }
}


Now this is just the basis of my script... I am going to build on it make it so people can change how many minutes and what the message will say right now... After an hour the PM gets reset to normal... Lots for to do on the script its just a basis...

Thanks,
Kriogenic.
RE: [HELP] Messenger.MyPersonalMessage won't assign to variable? by GNSPS on 08-10-2007 at 12:50 AM

You've got the variable wrong it isn't outputing anything because you're initializing it inside OnEvent_ChatWndSendMessage() function... if you put it like this it should work:

code:
var MyOldPM;
function OnEvent_ChatWndSendMessage( ChatWnd, Message )
{
    chat_window = ChatWnd;
    Command = Message.split(' ')
switch ( Command[0].toLowerCase() )
{
           
case "/testing" :
                var i = 0;
MyOldPm = Messenger.MyPersonalMessage;
MsgPlus.AddTimer("testing", 1000 );
Message = '';
return "";
break;
   
        default:
    }
    return Message;
}

function OnEvent_Timer( TimerId )
{
    switch( TimerId )
    {
        case 'cuptime':
      i++
     if(i < 60){
      Messenger.MyPersonalMessage = "Timing... " + i + " Minutes have passed";
        MsgPlus.AddTimer( 'cuptime', 60000 );
}else{
Messenger.MyPersonalMessage = MyOldPM;
}
            break;

        default:
    }
}
[code]

EDIT: you also got the variable name wrong you've got The in one and My on another! Hope this works...
[/code]
RE: [HELP] Messenger.MyPersonalMessage won't assign to variable? by matty on 08-10-2007 at 12:50 AM

code:
var chat_window;
var TheOldPm;

function OnEvent_ChatWndSendMessage(ChatWnd, Message){
    chat_window = ChatWnd;
    Command = Message.split(' ')
    switch ( Command[0].toLowerCase() ){
        case "/testing" :
            var i = 0;
            TheOldPm = Messenger.MyPersonalMessage;
            MsgPlus.AddTimer("testing", 1000 );
            Message = '';
            return "";
            break;
    }
    return Message;
}

function OnEvent_Timer(TimerId) {
    switch(TimerId){
        case 'cuptime':
            i++
            if(i < 60){
                Messenger.MyPersonalMessage = "Timing... " + i + " Minutes have passed";
                MsgPlus.AddTimer('cuptime', 60000);
            }
            else{
                Messenger.MyPersonalMessage = TheOldPM;
            }
            break;
    }
}

The problem is is that you are declaring TheOldPm inside a function making it local to the function, however you are trying to use a variable called MyOldPm.
RE: [HELP] Messenger.MyPersonalMessage won't assign to variable? by Spunky on 08-10-2007 at 12:52 AM

if your going to use MyOldPM like that, you need to declare it as global... outside of any functions put

code:
var MyOldPM;

and then just use MyOldPM like normal in ur script once it's been set, but you don't use var MyOldPM again, just in that initial declaration


EDIT: Beaten x2 :(
RE: [HELP] Messenger.MyPersonalMessage won't assign to variable? by Kriogenic on 08-10-2007 at 12:55 AM

Alright thanks this works perfectly (y) thanks for all your help

Kriogenic.