Shoutbox

[Reqest] Script that says heyy to whoever signs on - 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: [Reqest] Script that says heyy to whoever signs on (/showthread.php?tid=90439)

[Reqest] Script that says heyy to whoever signs on by ryannathans on 04-30-2009 at 08:27 AM

heyy everyone! this is a request for someone who can make a script that says "heyy" to whoever just signs in. shouldn't be too hard?

thanks


RE: [Reqest] Script that says heyy to whoever signs on by Baggins on 04-30-2009 at 10:23 AM

In the scripts menu click Scripts Prefrences, then create a new script and paste this code in. If you want to change the message, just change what is in the quotes at the top.

js code:
var sMessage = "Hey!";
function OnEvent_ContactSignin(sEmail)
{
    oChatWnd = Messenger.OpenChat(sEmail);
    oCahtWnd.SendMessage(sMessage);
}

RE: [Reqest] Script that says heyy to whoever signs on by ryannathans on 04-30-2009 at 10:39 AM

im trying it now :) thanks


RE: [Reqest] Script that says heyy to whoever signs on by Spunky on 04-30-2009 at 12:00 PM

js code:


Even Simpler...
RE: [Reqest] Script that says heyy to whoever signs on by ryannathans on 04-30-2009 at 12:27 PM

lol yeah and the other guy spelt his wrong...

how about a code for saying heyy only if the contact has NOT been on in the last 10 mins?


RE: [Reqest] Script that says heyy to whoever signs on by Matti on 04-30-2009 at 04:12 PM

quote:
Originally posted by ryannathans
how about a code for saying heyy only if the contact has NOT been on in the last 10 mins?
That's a bit more difficult. Basically, you'd have to store the time when they went online in some kind of global object and when they come online again, check the time difference first before sending the message.

Here's some documented example code. Have a look at it first, make sure you understand what I've done and then try it out.
js code:
/* Global variables */
var sHelloMessage = "Hey!";    //Message to send on contact sign-in
var oContactSigninTimes = {};    // Store for the contact signin times
var nMinSigninInterval = 10 * 60 * 1000;    // 10 minutes (expressed in milliseconds)

function OnEvent_ContactSignin( sEmail ) {
    // Set up some local variables
    var nTime = new Date().getTime();    //Get the current time, as a number
    var nLastSignin = 0;    //Placeholder for the contact's last sign-in time
    // First check if we have a logged sign-in time
    if( nLastSignin = oContactSigninTimes[sEmail] ) {
        // Compare it to the time now
        if( (nTime - nLastSignin) < nMinSigninInterval ) {
            // If the difference is less than the configured interval,
            // stop further execution of this function.
            return;
        }
    }
    // If we don't have a previously logged sign-in time or
    // if the difference is greater than the configured interval,
    // store the current time and send the message.
    oContactSigninTimes[sEmail] = nTime;
    Messenger.OpenChat(sEmail).SendMessage(sHelloMessage);
}
Oh, and by the way: we have an [Image: edit.gif] button here, no need for double post in less than a minute! :P
RE: [Reqest] Script that says heyy to whoever signs on by ryannathans on 05-01-2009 at 07:39 AM

ohh i diddnt see the edit button, thanks