Shoutbox

[release] Who's online - 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: [release] Who's online (/showthread.php?tid=65477)

[release] Who's online by Jimbo on 08-27-2006 at 05:10 PM

I did not make this script but i think people will use it so im gonna post it.

Matty and alexp2_ad gave me the code, so thanks again to them

This script shows 2 toasts when you login.

the first one says    :  xx contacts are online
the second one says: xx contacts are offline

it also shows these toasts again every 10 minutes(this can be changed but you will have to altar the code)

Screenshot of the two toasts:

[Image: screenshot1ud7.png]

can anyone make a configuration window for this?


RE: [release] Who's online by Zeh on 08-27-2006 at 07:37 PM

Yeah a configuration window for this would be cool. I think many people would download this if you could change the script settings without changing the code.


Ok I need some help with this. I've tried changing the code so it would show both online and offline in the same toast but it isn't working. It show contacts online in green and counts them and it also counts the offline contacts well but instead of apearing in red it show .$4 in the begining and .$0 in the end.

I've changed onle of the show toast lines to:

MsgPlus.DisplayToastContact('contact counter', '·$3contacts online : '+online+'.$0' , '·$4contacts offline : '+offline+'·$0' , '' , '', '');

and I've deleted the other so it wouldn't appear 2 counters. Can anyone tell me what's wrong with the code?
RE: [release] Who's online by alexp2_ad on 08-27-2006 at 08:42 PM

The second half of the contact toast doesn't support colours, it's meant for using the contact name, then info about them in the second bit, and the info wouldn't need colours.

But you could just use:

code:
MsgPlus.DisplayToastContact('Contact Counter', '·$3Contacts online: '+online+'.$0'+'·$4contacts offline : '+offline+'·$0','', '' , '', '');

It'd probably wrap over, though I haven't tested.  Also, why not use the nice, easier colour codes...
RE: [release] Who's online by Zeh on 08-27-2006 at 08:46 PM

The code you sugested doesn't work. The colors are right but they appear in the same line wich makes impossible to read part of the message because of the toast's size. And also the first .$0 still appers between online and offline contacts.


RE: RE: [release] Who's online by alexp2_ad on 08-27-2006 at 08:51 PM

quote:
Originally posted by Zeh
The code you sugested doesn't work. The colors are right but they appear in the same line wich makes impossible to read part of the message because of the toast's size. And also the first .$0 still appers between online and offline contacts.

That's because I forgot to put in a space, and because your code had a full stop instead of the dot in the middle on the $0, which is why I suggested the simpler colour codes. :P

code:
MsgPlus.DisplayToastContact('Contact Counter', '[c=green]Contacts online: '+online+'[/c] '+'[c=red]Contacts offline: '+offline+'[/c]','');

Try that...

EDIT:  Tried it, doesn't fit, this is better:

code:
MsgPlus.DisplayToastContact('Contact Counter', '[c=green]Online: '+online+'[/c] '+'[c=red]Offline: '+offline+'[/c]','');

RE: [release] Who's online by Zeh on 08-27-2006 at 08:56 PM

Ok it's a bit better but it still shows everything in the same line and you forgot to delete a dot next to the '+' but it still apears in the same line after I delete the dot.


RE: RE: [release] Who's online by alexp2_ad on 08-27-2006 at 09:00 PM

quote:
Originally posted by Zeh
Ok it's a bit better but it still shows everything in the same line and you forgot to delete a dot next to the '+' but it still apears in the same line after I delete the dot.

Lol, you were quick, I removed that in an edit about 10 seconds after making the post. :P

Also, just edited to add code that does fit.  Just remove the word contacts each time, plenty room. :

EDIT:

Add:

code:
function OnEvent_Initialize(bMessengerStart){
    if(!bMessengerStart){ OnEvent_SigninReady(Messenger.MyEmail); }
}

To make it work if the script is started when messenger is already signed in (eg. when editing and enabling / disabling the script...)
RE: [release] Who's online by Zeh on 08-27-2006 at 09:02 PM

LOL ok. But isn't there any way of putting each of them in a diferent line with colors? Even if it would take a more complecated code?


RE: RE: [release] Who's online by alexp2_ad on 08-27-2006 at 09:04 PM

quote:
Originally posted by Zeh
LOL ok. But isn't there any way of putting each of them in a diferent line with colors? Even if it would take a more complecated code?

No.  At least, not without making your on toast window or something.

You could have green and black as your colours?

Actually, patchou should make a function for a toast that line wraps and uses colours... *-)
RE: [release] Who's online by Zeh on 08-27-2006 at 09:10 PM

Well yeah I could use green and black. But it would be really cool if it was green and red don't you think. Well that may be a suggestion for the next release of WLM !plus. To be able to line wrap and use colors in different lines of the WLM !plus toasts. Could you suggest that? Cuz I really don't know what and where to say that! LOL


RE: [release] Who's online by Spunky on 08-27-2006 at 11:17 PM

Just been trying some things out for you (none of which worked). ALT codes don't seem to go into the script very well (It'd be ALT+0015 for carriage return). I was thinking about sendkeys to create a variable with a carriage return in it, but theres not an open window :p


RE: [release] Who's online by Zeh on 08-28-2006 at 04:05 PM

Ok so the changes I made to the script based on what alexp2_ad are working great! Now I've haded a line saying "Next count in 10 minutes". But I wanted to add some code to instead off saying allways 10 minutes to say the minutes left based on what you have chosen. Anyone knows how to do this?


RE: [release] Who's online by alexp2_ad on 08-28-2006 at 04:15 PM

This'll do it, I put the time in a variable you set at the top:

EDIT: See below post...


RE: [release] Who's online by Zeh on 08-28-2006 at 04:22 PM

Ok thkz! It's working great! :)


RE: [release] Who's online by alexp2_ad on 08-28-2006 at 04:40 PM

Actually, use this... it uses minutes or seconds as appropriate, and rounds the number if it's decimal:

code:
var ThirtyMins = 1800000;
var SixtyMins = 3600000;
var FiveMins = 300000;
var TenMins = 600000;

// SET THE TIME YOU WANT TO USE HERE!
var mytime = ThirtyMins;

function OnEvent_Initialize(bMessengerStart){
    if(!bMessengerStart){ OnEvent_SigninReady(Messenger.MyEmail); }
}

function OnEvent_SigninReady(sEmail){
    var contacts = Messenger.MyContacts;
    var online = 0;
    var offline = 0;
    for(var e = new Enumerator(contacts); !e.atEnd(); e.moveNext()){
        item = e.item();
        if(item.Status != 1 && item.Status != 0){ online++; } else { offline++; }
    }
    MsgPlus.DisplayToastContact('Contact Counter', '[c=green]Online: '+online+'[/c]'+'[c=red]Offline: '+offline+'[/c]','Next count in '+TimeLength(mytime));
    MsgPlus.AddTimer('reload', mytime) //Repalce with SixtyMins if you want an hour
}

function OnEvent_Timer(sTimerId){
    if (sTimerId == 'reload'){
        OnEvent_SigninReady(Messenger.MyEmail); //Simply call the function so you dont duplicate code
    }
}

function TimeLength(time){
    if(time >= 60000){ return Math.round(time/60000)+" minutes"; }
    else{ return Math.round(time/1000)+" seconds"; }
}

RE: [release] Who's online by Zeh on 08-28-2006 at 04:51 PM

I didn't understand what you just did but It's still the same. lol


RE: RE: [release] Who's online by alexp2_ad on 08-28-2006 at 04:58 PM

quote:
Originally posted by Zeh
I didn't understand what you just did but It's still the same. lol

It means if you put in 30 minutes and 20 seconds it would round the bit on the toast to 30 minutes and not some space sapping number.

And if you put just 30 seconds, it'll have it in seconds instead of 0.5 minutes.
RE: [release] Who's online by Zeh on 08-28-2006 at 05:02 PM

Ok I see but to put 30 seconds I would have to create a new var telling what the script what is 30 seconds just like the vars in the beggining of the script. Right?


RE: RE: [release] Who's online by alexp2_ad on 08-28-2006 at 05:05 PM

quote:
Originally posted by Zeh
Ok I see but to put 30 seconds I would have to create a new var telling what the script what is 30 seconds just like the vars in the beggining of the script. Right?

Yes.  Or just set mytime = 30000;  and cut the middle man.
RE: [release] Who's online by Zeh on 08-28-2006 at 05:07 PM

Ok. Thkz. You really know your scripting well! Eheh.


RE: [release] Who's online by Jimbo on 08-29-2006 at 10:35 AM

could someone make a configuration window for my script so that people can change the color of the text in the toasts and also so they can change the amount of time that it re-displays the toasts?


RE: [release] Who's online by Zeh on 08-29-2006 at 12:44 PM

Maybe alexp2_ad knows how to do it.


RE: [release] Who's online by Jimbo on 08-29-2006 at 06:41 PM

i hope so, because i think with the configuration window, the script will be a huge success


RE: [release] Who's online by dylan! on 08-29-2006 at 07:11 PM

quote:
Originally posted by 134jimbodude's first post
I did not make this script
quote:
Originally posted by your siggy
My script: Who's online?

stealing otehrs work?:S taking credit for it? that just doesn't add up :undecided:
RE: [release] Who's online by Jimbo on 09-01-2006 at 08:44 AM

add up now?
lol


So, can someone make a configuration window for this or not?, i would be so happy if someone would.
RE: RE: RE: [release] Who's online by CookieRevised on 09-01-2006 at 09:36 AM

quote:
Originally posted by alexp2_ad
quote:
Originally posted by Zeh
LOL ok. But isn't there any way of putting each of them in a diferent line with colors? Even if it would take a more complecated code?
No.

Actually, patchou should make a function for a toast that line wraps and uses colours... *-)
Use the newline character like you can in every other string in JScript:

\n

and if that doesn't work try to use:

\x0D

and if that doesn't work, slap Patchou :p

EDIT: and it doesn't work, so let us slap Patchou...



quote:
Originally posted by SpunkyLoveMuff
ALT codes don't seem to go into the script very well (It'd be ALT+0015 for carriage return).
ALT+0015 is certainly not a carriage return. The decimal ascii for a CR is 13 (and thus 0x0D in hexadecimal, see above)...





------------------------------------------

about alexp2_ad's code the code alexp2_ad posted (which isn't his!... ;)@alex):

optimized:
code:
function OnEvent_SigninReady(sEmail) {
    var online = 0;
    var offline = 0;
    for (var e = new Enumerator(Messenger.MyContacts); !e.atEnd(); e.moveNext()) {
        if (e.item().Status > 1) { online++; } else { offline++; }
    }
    MsgPlus.DisplayToastContact('Contact Counter', '[c=green]Online: ' + online + '[/c]\n[c=red]Offline: ' + offline + '[/c]', 'Next count in ' + TimeLength(mytime));
    MsgPlus.AddTimer('reload', mytime) //Replace with SixtyMins if you want an hour
}


function OnEvent_Timer(sTimerId) {
    if (Messenger.MyStatus != 0) {
        OnEvent_SigninReady(Messenger.MyEmail);
    }
}
Extremely important note:

Each and every script that uses timers to manipulate or check user specific stuff should first check if the same user is still signed in when the timer triggers!!!

It should check if it is still the same current user who is signed in and thus only perform the action if the user is the same as the one who started the timer.

Failing todo all this will cause many errors when:
- the user signs out when a timer is still active
- a new user signs in and the action when the timer triggers is something like blocking a contact, changing status, retrieving contacts, etc...

All this because timers do not reset and aren't deleted when somebody signs out or when somebody else signs in.



For this particular script above, the check to see if it is still the current user who started the timer, isn't needed since the SigninReady() event function is used, but every developer should be aware of the above pitfalls.
Extremely many scripts make these faults...

Another, and even better solution for the above problem (for this particular script!) is to explicitly delete the timer when the user signs out:

code:
function OnEvent_SignOut(sTimerId) {
    MsgPlus.DeleteTimer('reload');
}
function OnEvent_Timer(sTimerId) {
    OnEvent_SigninReady(Messenger.MyEmail);
}

RE: RE: RE: RE: [release] Who's online by alexp2_ad on 09-01-2006 at 10:05 AM

quote:
Originally posted by CookieRevised
quote:
Originally posted by alexp2_ad
Actually, patchou should make a function for a toast that line wraps and uses colours... *-)
Use the newline character like you can in every other string in JScript:

\n

Have you actually tried it?  Putting a new line character in the contact toast didn't work when I tried. :S

EDIT:  Hey, you can't just edit your post so it looks like you never said it would definitely work! :P  You should have tested it BEFORE you posted! :P


And I didn't write that bit of the code btw, that was Matty, I wrote the code that displayed the toasts on sign in, since that was the original suggestion, then Matty added timer code to bring it up again when that was asked for too.  I wouldn't have thought to recall an event function... dunno why, just never considered it a possibility. :/

EDIT2:  See, I'm not lying, that bit isn't my code. :P
RE: RE: RE: RE: RE: [release] Who's online by CookieRevised on 09-01-2006 at 05:30 PM

quote:
Originally posted by alexp2_ad
You should have tested it BEFORE you posted! :P
says he who needs several posts to post a working script snippet and said "(...) though I haven't tested." ;):p:D.... anyways, it wasn't my intention to change the post in that way though... and you quoted my original post also, so....

for what it is worth: sorry :$


quote:
Originally posted by alexp2_ad
And I didn't write that bit of the code btw, that was Matty, I wrote the code that displayed the toasts on sign in, since that was the original suggestion, then Matty added timer code to bring it up again when that was asked for too.  I wouldn't have thought to recall an event function... dunno why, just never considered it a possibility. :/

EDIT2:  See, I'm not lying, that bit isn't my code. :P

lol, ok, ok, I believed you from the first time :p;) It was just that you posted it.... I'll edit my post again.


blah... off topic spam this post is
RE: RE: RE: RE: RE: RE: [release] Who's online by alexp2_ad on 09-01-2006 at 05:38 PM

quote:
Originally posted by CookieRevised
says he who needs several posts to post a working script snippet and said "(...) though I haven't tested." ;):p:D

1.  They all worked, but some weren't as aesthetically pleasing. :P
2.  I pointed out I hadn't tested it, I didn't say it in the form of "this will definitely work, and you're stupid not to have figured it out". :P

EDIT:  And I didn't post that bit of the code. :S  Matty did, I just linked to it right there. :S  And it was pointed out I didn't write it all right at the top.  The only time I posted that code was in the modified script above, that I posted so people didn't have to manually go through and make the changes I'd made. :S
RE: [release] Who's online by CookieRevised on 09-01-2006 at 05:44 PM

quote:
Originally posted by alexp2_ad
"this will definitely work, and you're stupid not to have figured it out". (Smilie)
I didn't either, did I ? hmmm... yeah I did I guess...

Let me defend myself in saying I wanted to reply short without any fuzz... guess that backfired to me...
quote:
Originally posted by alexp2_ad
The only time I posted that code was in the modified script above, that I posted so people didn't have to manually go through and make the changes I'd made.
Which is what I meant with "the script alex posted".

RE: RE: [release] Who's online by alexp2_ad on 09-01-2006 at 06:12 PM

quote:
Originally posted by CookieRevised
Let me defend myself in saying I wanted to reply short without any fuzz... guess that backfired to me...

Which is what I meant with "the script alex posted".

OK, no problem. ;)

Anyway, on topic, I don't think this script really needs a configuration window as such... *-)

I'll make one if you want, but it seems fairly unnecessary.
RE: [release] Who's online by Spunky on 09-01-2006 at 06:28 PM

quote:
Originally posted by CookieRevised
ALT+0015 is certainly not a carriage return. The decimal ascii for a CR is 13 (and thus 0x0D in hexadecimal, see above)...

http://www.lookuptables.com/ states that ascii for CR is 15 and that 13 is for vertical tab. When I used to code in VB though, I used 13 for CR (or sometimes worked with another number :s)

UPDATE: Looked at wrong column... Ouch, my pride...


RE: [release] Who's online by Felu on 09-01-2006 at 06:34 PM

Here's the configuration window :p. If anyone is interested in coding the js for the window please do it or else ill do it tomorrow |-).'


RE: [release] Who's online by Jimbo on 09-02-2006 at 09:17 AM

Thanks Felu, i can't wait till someone codes it.


RE: [release] Who's online by Matti on 09-02-2006 at 09:21 AM

I'll give it a shot, instead someone is faster. :P


RE: [release] Who's online by Felu on 09-02-2006 at 09:46 AM

Here's it ;).


RE: [release] Who's online by CookieRevised on 09-02-2006 at 10:32 AM

quote:
Originally posted by -!Felu!-
Here's it ;).
Please see my previous post about this script. Those notes are highly important.
RE: RE: [release] Who's online by Felu on 09-02-2006 at 10:44 AM

quote:
Originally posted by CookieRevised
quote:
Originally posted by -!Felu!-
Here's it ;).
Please see my previous post about this script. Those notes are highly important.

I didn't read this thread :P. Updated
RE: [release] Who's online by Supersonicdarky on 09-02-2006 at 06:30 PM

2 things

can u make it close the config window on save
and
can u add option to display it in ur pm?


RE: [release] Who's online by Dave on 09-02-2006 at 09:15 PM

I've read the whole thread and i havent quite worked out what the upshot of the talk about putting it all into one toast was.  Was it that it could be done but the second line was in black, or what.

Also, what language are these scripts written in, cos if i get really bored, it might be an idea to start learning how to write/edit  them - does anyone have any ideas how one might begin?


RE: [release] Who's online by CookieRevised on 09-02-2006 at 10:15 PM

[OFF TOPIC]

quote:
Originally posted by Dave
I've read the whole thread and i havent quite worked out what the upshot of the talk about putting it all into one toast was.  Was it that it could be done but the second line was in black, or what.
Either you can have a colored line by (ab)using the nickname parameter of the DisplayToastContact function. Or either you have everything in black but with multiple lines by using the DisplayToast function.

quote:
Originally posted by Dave
Also, what language are these scripts written in, cos if i get really bored, it might be an idea to start learning how to write/edit  them - does anyone have any ideas how one might begin?
language: JScript 5.6 (note: this is not the same, though very similar, as JavaScript).
tutorials: thousands to be found on google.

[/OFF TOPIC]
RE: [release] Who's online by Dave on 09-03-2006 at 09:38 PM

thanks cookierevised.  Do you have to reconfigure this who's online script every time you sign in, or should it remember between times?  Cos i think i had to turn it on my self jsut now, but this might be a one off


RE: [release] Who's online by CookieRevised on 09-04-2006 at 12:38 AM

[OFF TOPIC]

When you have activated a script in the Plus! preferences, it will stay activated. Note that this is for the script execution only. Think of this as executing a program or stopping a program on your computer. Even if the program does nothing, it is still executing.

Scripts can have their own menu to be enabled and disabled, accessable thru the Plus! icon in the contact list or conversation menu or with the aid of commands. Though, "disabled" means the script will still be running as far as Plus! is concearned, it only wont perform its actions. Think of this enabling and disabling as turning on/off a feature of the program.

If you have further general scripting questions I'd suggest to read the official Plus! Scripting Documentation as all this is actually off topic to this thread.

[/OFF TOPIC]


RE: [release] Who's online by Dave on 09-04-2006 at 07:23 AM

sorry, that wasn't quite my question.  I was asking about who's online in particular, because some scripts i use stay turned on (by this i mean doing what they are supposed to do, not just having a tick in the box in the preferences panel) when i next sign in to WLM.  However, i have found with who's online that if i go to the configure box, (this is using the version that -!Felu!- wrote with the config. box) when i have just signed in, it is totally blank and i have to turn it on and set the time delay every time.  Is there a way i can change this?

PS: I think my question is on topic, so you don't need to do your[OFF TOPIC] [/OFF TOPIC] thing :P


RE: [release] Who's online by Jimbo on 09-07-2006 at 03:15 PM

yes, i agree, now !felu! has made a config. window it doesn't save the settings, you have to reset them everytime you sign in
someone please help


RE: [release] Who's online by xxhannahxx on 09-10-2006 at 11:55 AM

kl script 134 jimbodude


RE: [release] Who's online by NanaFreak on 09-10-2006 at 11:59 AM

quote:
Originally posted by xx134xx
kl script 134 jimbodude
ok first it wasnt him who made it and what was the point of bringing up this thread????

also please write in full not slang
RE: [release] Who's online by xxhannahxx on 09-10-2006 at 12:01 PM

is it possible to change the colour of the words online and offline?


sorry about that jayjay i was only saying and anyway it is a cool scipt and well done to everyone that made it