What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Question] Help with code...

Pages: (2): « First [ 1 ] 2 » Last »
[Question] Help with code...
Author: Message:
MicroWay
Senior Member
****

Avatar
Do you want me? Try to get me!

Posts: 571
Reputation: 16
36 / Male / Flag
Joined: Jul 2006
Status: Away
O.P. Huh?  [Question] Help with code...
Hello!!!

My second question of the day:

I have a simple "script" that displays how many contacts are online on PSM.

code:
var online;
var offline;
var percent;
var str;

function OnEvent_SigninReady(Email){
doIt(Email);
}

function OnEvent_ContactSignin(Email){
doIt(Email);
}

function OnEvent_ContactSignout(Email){
doIt(Email);
}

function OnEvent_Initialize(MessengerStart){
doIt(Messenger.MyEmail);
}

function doIt(Email){
str="";
online=0;
offline=0;
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext()) {
var Contact = e.item();
if(Contact.Status!=1&&Contact.Status!=0){
online++;
}
offline++;

}
percent = Math.round((online/offline)*100);
for(var i=0;i<percent;i++){
str=str.replace("-","|");
}
for(var a=0;a<=100;a++){
str=str.replace("-","");
}

percent2 = Math.round(100 - percent);
for(var i=0;i<percent;i++){
str=str.replace("-","|");
}
for(var a=0;a<=100;a++){
str=str.replace("-","");
}
str=str+" "+percent+"% of contacts Online ("+online+"/"+offline+")";
Messenger.MyPersonalMessage = str;
Debug.Trace(Email +" caused PSM to update");
}


How I can make it apeears after the message I have writed?

Example:

My original PSM -> Congratulations, Kelvin
The script will put -> 21% of contacts Online (21/46)

I want ->  Congratulations, Kelvin - 21% of contacts Online (21/46)

(The colors are just to help you understand me...)

This post was edited on 10-28-2006 at 02:11 AM by MicroWay.
10-24-2006 01:20 AM
Profile PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: [Question] Help with code...
Just put the current psm in a variable and add it to the string that your code made.

code:
var psm = Messenger.MyPersonalMessage;
Messenger.MyPersonalMessage = psm + " " + str;
[Image: 1-0.png]
             
10-24-2006 02:38 AM
Profile PM Web Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: [Question] Help with code...
Actually Ezra, no need to do that. Just replace this line:
code:
Messenger.MyPersonalMessage = str;
with this:
code:
Messenger.MyPersonalMessage = Messenger.MyPersonalMessage + " - " + str;
10-24-2006 02:39 AM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Question] Help with code...
quote:
Originally posted by deAd
code:
Messenger.MyPersonalMessage = Messenger.MyPersonalMessage + " - " + str;

You phail!

That is going to show for instance:
quote:
Originally posted by Possible PSM
blah - 2 - 3 - 4 - 7 - 10
This is after it has run for a little bit. Store the Original PSM in a variable then set the psm as sOrgPSM + ' - ' str.
10-24-2006 03:15 AM
Profile E-Mail PM Find Quote Report
MicroWay
Senior Member
****

Avatar
Do you want me? Try to get me!

Posts: 571
Reputation: 16
36 / Male / Flag
Joined: Jul 2006
Status: Away
O.P. RE: [Question] Help with code...
Thank's Ezra, Matty and deAd for the replies!!!
But now, with the line that Ezra pass me, when the script updates, it shows the Old PSM, the last number of contacts online and the new one... :S
Example:

Old PSM : Congratulations YYYY!!!
PSM after script is turned on : Congratulations YYYY!!! - 7% of contacts Online (3/13)
PSM after first update : Congratulations YYYY!!! - 7% of contacts Online (3/13) - 13% of contacts Online (5/13)

How can it be fixed???

If could help, here is the code again (updated)

code:
var online;
var offline;
var percent;
var str;

function OnEvent_SigninReady(Email){
doIt(Email);
}

function OnEvent_ContactSignin(Email){
doIt(Email);
}

function OnEvent_ContactSignout(Email){
doIt(Email);
}

function OnEvent_Initialize(MessengerStart){
doIt(Messenger.MyEmail);
}

function doIt(Email){
str="";
online=0;
offline=0;
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext()) {
var Contact = e.item();
if(Contact.Status!=1&&Contact.Status!=0){
online++;
}
offline++;

}
percent = Math.round((online/offline)*100);
for(var i=0;i<percent;i++){
str=str.replace("-","|");
}
for(var a=0;a<=100;a++){
str=str.replace("-","");
}

percent2 = Math.round(100 - percent);
for(var i=0;i<percent;i++){
str=str.replace("-","|");
}
for(var a=0;a<=100;a++){
str=str.replace("-","");
}
str=str+" "+percent+"% dos contatos Online ("+online+"/"+offline+")";
var psm = Messenger.MyPersonalMessage;
Messenger.MyPersonalMessage = psm + " -" + str;
Debug.Trace(Email +" caused PSM to update");
}


This post was edited on 10-25-2006 at 08:49 PM by MicroWay.
10-25-2006 08:05 PM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: [Question] Help with code...
code:
var online;
var offline;
var percent;
var str;
var oldPSM;

function OnEvent_SigninReady(Email){
doIt(Email);
}

function OnEvent_ContactSignin(Email){
doIt(Email);
}

function OnEvent_ContactSignout(Email){
doIt(Email);
}

function OnEvent_Initialize(MessengerStart){
doIt(Messenger.MyEmail);
oldPSM = Messenger.MyPersonalMessage
}

function doIt(Email){
str="";
online=0;
offline=0;
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext()) {
var Contact = e.item();
if(Contact.Status!=1&&Contact.Status!=0){
online++;
}
offline++;

}
percent = Math.round((online/offline)*100);
for(var i=0;i<percent;i++){
str=str.replace("-","|");
}
for(var a=0;a<=100;a++){
str=str.replace("-","");
}

percent2 = Math.round(100 - percent);
for(var i=0;i<percent;i++){
str=str.replace("-","|");
}
for(var a=0;a<=100;a++){
str=str.replace("-","");
}
str=str+" "+percent+"% dos contatos Online ("+online+"/"+offline+")";
var psm = Messenger.MyPersonalMessage;
Messenger.MyPersonalMessage = oldPSM + " -" + str;
Debug.Trace(Email +" caused PSM to update");
}

This will only show the PSM when the script was started + str though :p

This post was edited on 10-25-2006 at 09:30 PM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
10-25-2006 09:28 PM
Profile PM Find Quote Report
MicroWay
Senior Member
****

Avatar
Do you want me? Try to get me!

Posts: 571
Reputation: 16
36 / Male / Flag
Joined: Jul 2006
Status: Away
O.P. RE: RE: [Question] Help with code...
quote:
Originally posted by SpunkyLoveMuff
This will only show the PSM when the script was started + str though :p

Ohhhh... :$ Now I saw it!!!
Thank's very much...
Now it's working!!!

(Y)
;)
10-27-2006 12:46 AM
Profile PM Find Quote Report
saralk
Veteran Member
*****

Avatar

Posts: 2598
Reputation: 38
35 / Male / Flag
Joined: Feb 2003
RE: [Question] Help with code... (solved)
If you log off, with a %age status at the end of the PSM, then when you next sign on, you will still get the same problem.
The Artist Formerly Known As saralk
London · New York · Paris
Est. 1989
10-27-2006 10:19 AM
Profile PM Find Quote Report
MicroWay
Senior Member
****

Avatar
Do you want me? Try to get me!

Posts: 571
Reputation: 16
36 / Male / Flag
Joined: Jul 2006
Status: Away
O.P. RE: [Question] Help with code... (solved)
No... not the same problem...
But when I login, the script writes: "undefined - 5% contacts online (2/23)"
Then it's just delete "undefined" and rewrite something I like...
:)
10-27-2006 01:15 PM
Profile PM Find Quote Report
Baggins
Full Member
***

Avatar
B000ALFAZO

Posts: 387
Reputation: 13
29 / Male / Flag
Joined: Oct 2006
RE: [Question] Help with code... (solved)
store original psm in a global variable on signin, same with the %of contacts
right before updating psm replace old %of with new %of then
code:
Messenger.MyPersonalMessage = psm + " - " + %of;
on signout replace current psm with original psm (or write a RegEx to split at last "-" (<<<Best idea)).
10-28-2006 12:37 AM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On