Shoutbox

Reminder - 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: Reminder (/showthread.php?tid=87788)

Reminder by mrfireman on 12-16-2008 at 10:18 PM

Hey guys!

I have a script, which makes reminder in toast. It is working if you write:

/reminder <minutes> <message> to any conversion window.

But my question is:

Is  it possiblie, to write to the script, to not tell it to Toast, tell it to conversion window, and the input could be given from else?

For example, I am talking with Peter: and Peter says:
/reminder <minutes> <message>

And when the time has come, my client will write the alarm to the conversion window!

Is it possible? The code of the script is the following:

jscript code:


RE: Reminder by roflmao456 on 12-17-2008 at 10:13 PM

Not too sure what you mean, but:

If you wanted to alert your client when the reminder timer activates, you can try using ChatWnd.SendMessage.


example:

jscript code:
var chatwnds=[];

function OnEvent_Timer(TimerId){
    chatwnds[TimerId].SendMessage("time's up!"); // Sends a message to contact..
    delete chatwnds[TimerId];
    }
   
function OnEvent_ChatWndSendMessage(ChatWnd,Message){
    if(/^\/(\S*)\s*(.*)/.exec(Message))
        if(RegExp.$1.toLowerCase()=="reminder"){
            var m=RegExp.$2*60000;
            chatwnds[m]=ChatWnd;
            MsgPlus.AddTimer(m,m);
            Debug.Trace("Done and done. Reminding in "+m/60000+" minute(s)");
            return "";
            }
    /* usage: /reminder <minutes> */
    }

RE: Reminder by mrfireman on 12-17-2008 at 10:53 PM

Thank you, I changed it for you wrote, but it still doesn't working... Maybe i wrote to bad place what you say, or i didn't delete something, i had to...

Could you copy me the "all code" if I please you? Thx


RE: Reminder by roflmao456 on 12-17-2008 at 11:02 PM

Oh right, type mismatch.. AddTimer doesn't seem to accept ChatWnds..

corrected code above.


RE: Reminder by mrfireman on 12-17-2008 at 11:07 PM

It is still doesn't working at me, but I am sure, i am the noob to misswrote something... (I am newbie at scripting) My script now:

jscript code:
//set globals
var time;
var own_message;
var chatwnds=[];

//display the toast
//hehe toast.... mmm butter...
function toast() {
    var t_title = "Time's Up!";
    var t_msg;
   
    //if personal message set
    if(own_message == "") {
        var t_msg = "You set a timer for "+time+" minute(s) and your time is up!";
    }
    //if default message
    else {
        var t_msg = time+" minute(s) has passed - \""+own_message+"\"";
    }
    //display the toast
    MsgPlus.DisplayToast(t_title,t_msg,"alarm.mp3");
   
    //unset variables
    time = "";
    own_message = "";
}

//check input for function
function OnEvent_ChatWndSendMessage(ChatWnd,Message) {
    //generate new array
    var input = new Array();
    //assign values to array
    input = Message.split(" ");
   
    if(input[0] == "/remind") {
        // set a reminder
        time = input[1];
        if(input[2]) {
            // own message
            var input_no = 3;
            own_message = input[2];
           
            //if the message is more than one word
            if(input[3]) {
                //string together message
                while(input_no < input.length) {
                    own_message+=" "+input[input_no];
                    input_no = input_no+1;
                }
            }
           
        }
        //convert to milliseconds
        var time_ms = time*60000;
        //set timer
        MsgPlus.AddTimer("toaster2", time_ms);
        //return nowt
        return "";
    }
}
var chatwnds=[];

function OnEvent_Timer(TimerId){
    chatwnds[TimerId].SendMessage("time's up!"); // Sends a message to contact..
    delete chatwnds[TimerId];
    }
   
function OnEvent_ChatWndSendMessage(ChatWnd,Message){
    if(/^\/(\S*)\s*(.*)/.exec(Message))
        if(RegExp.$1.toLowerCase()=="reminder"){
            var m=RegExp.$2*60000;
            chatwnds[m]=ChatWnd;
            MsgPlus.AddTimer(m,m);
            Debug.Trace("Done and done. Reminding in "+m/60000+" minute(s)");
            return "";
            }
    /* usage: /reminder <minutes> */
    }
function OnEvent_Initialize(MessengerStart) {}
function OnEvent_Uninitialize(MessengerExit) {}

RE: Reminder by roflmao456 on 12-17-2008 at 11:08 PM

Try making another new script (disable yours) and paste my code in there.


RE: Reminder by mrfireman on 12-17-2008 at 11:11 PM

It works perfectly, very very very Big Thanks for you help and Respect! :)

And I know it is more now, but is it possible, to send a message to the chatwindow, if the reminder has saved a notice?

For example I am talking with Peter, and I write to the window: /reminder 1

And after I write it, Peter can see a message from me: "Mr.Fireman has added a reminder for 1 minutes!"

Is it possible?
And very very very big thanks for you to help me!


RE: Reminder by Spunky on 12-17-2008 at 11:35 PM

jscript code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message){
    if(/^\/(\S*)\s*(.*)/.exec(Message))
        if(RegExp.$1.toLowerCase()=="reminder"){
            var m=RegExp.$2*60000;
            chatwnds[m]=ChatWnd;
            MsgPlus.AddTimer(m,m);
            Debug.Trace("Done and done. Reminding in "+m/60000+" minute(s)");
            return "/me has added a reminder for "+m/60000+"minute(s)";
            }
    /* usage: /reminder <minutes> */
    }

RE: Reminder by mrfireman on 12-17-2008 at 11:40 PM

I love you ;) Thx


RE: Reminder by roflmao456 on 12-18-2008 at 12:00 AM

If your friend doesn't have msgplus, it would be better to return a normal message. :P

jscript code:
return "[Info] (!NP) has added a reminder. ("+m/60000+" mins)";