Update number of contacts |
Author: |
Message: |
SnuZZer
Full Member
Posts: 114
32 / /
Joined: Jun 2006
|
O.P. Update number of contacts
Hi.
I'm from Denmark and my english isn't good, but i'll try.
I have made a script (..or tried to make a script) which shows how many contacts there's online/offline, how many contacts there's on the list and how many windows there's open.
I have tried to make a timer which update the number in the personal message every second, but it doesn't works.
My script:
var Status = "fra"; // SÆTTER STATUS TIL/FRA
var oprindeligPB = Messenger.MyPersonalMessage;
function OpdaterPB()
{
var online = 0;
var offline = 0;
var kontakter = Messenger.MyContacts;
var e = new Enumerator(kontakter);
for(; !e.atEnd(); e.moveNext()) {
var kontakt = e.item();
if(kontakt.Status == "1") {
offline++;
} else {
online++;
}
}
var alle = (online + offline);
var igang = Messenger.CurrentChats.Count;
Messenger.MyPersonalMessage = "Online: " + online + " | Offline: " + offline + " | I alt: " + alle + " | Åbne vinduer: " + igang;
AddTimer("1",100);
}
// NÅR DU LOGGER PÅ : START
function OnEvent_Initialize(MessengerStart)
{
if (Status == "til")
{
opdaterPB();
}
}
// NÅR DU LOGGER PÅ : SLUT
// NÅR DU LOGGER AF : START
function OnEvent_Uninitialize(MessengerExit)
{
Messenger.MyPersonalMessage = oprindeligPB;
}
// NÅR DU LOGGER AF : SLUT
// NÅR EN KONTAKTER LOGGER PÅ : START
function OnEvent_ContactSignin()
{
if (Status == "til")
{
opdaterPB();
}
}
// NÅR EN KONTAKTER LOGGER PÅ : SLUT
// NÅR EN KONTAKTER LOGGER AF : START
function OnEvent_ContactSignout()
{
if (Status == "til")
{
opdaterPB();
}
}
// NÅR EN KONTAKTER LOGGER AF : SLUT
// NÅR ET VINDUE ÅBNES : START
function OnEvent_ChatWndCreated()
{
OpdaterPB();
}
// NÅR ET VINDUE ÅBNES : SLUT
// NÅR ET VINDUE LUKKES : START
function OnEvent_ChatWndDestroyed()
{
OpdaterPB();
}
// NÅR ET VINDUE LUKKES : SLUT
// TJEKKER TIMER : START
function OnEvent_Timer(id)
{
if (id == "1")
{
opdaterPB();
}
}
// TJEKKER TIMER : SLUT
// LAVER MENU : START
function OnGetScriptMenu(Location)
{
ScriptMenu = "<ScriptMenu>";
ScriptMenu += "<MenuEntry Id=\"tilfra\">";
if (Status == "fra")
{
ScriptMenu += "Slå til";
} else {
ScriptMenu += "Slå fra";
}
ScriptMenu += "</MenuEntry>";
ScriptMenu += "</ScriptMenu>";
return ScriptMenu;
}
// LAVER MENU : SLUT
// VALGT MENU : START
function OnEvent_MenuClicked(MenuItemId,Location,OriginWnd)
{
switch(MenuItemId)
{
case "tilfra":
if (Status == "fra")
{
Status = "til";
MsgPlus.DisplayToast("Kontakt information", "Kontakt information er slået til.");
opdaterPB();
} else {
Status = "fra";
MsgPlus.DisplayToast("Kontakt information", "Kontakt information er slået fra.");
Messenger.MyPersonalMessage = oprindeligPB;
CancelTimer(1);
}
break;
}
}
// VALGT MENU : SLUT
Thanks in advance.
- Simon
|
|
10-22-2006 03:04 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Update number of contacts
CancelTimer(1); should be MsgPlus.CancelTimer("1");
Your timer interval is set for 100 which is 10 times a second. (I'm pretty sure that below minimum. Use 1000 instead.)
Thats all i noticed by having a quick look
<Eljay> "Problems encountered: shit blew up"
|
|
10-22-2006 03:25 PM |
|
|
SnuZZer
Full Member
Posts: 114
32 / /
Joined: Jun 2006
|
O.P. RE: Update number of contacts
Hi.
It doesn't work.
The timer is only necessary beacuse the numbers of open chat windows is falling if you close the window with the button, and it doesn't fall if you close the window with "ESC".
|
|
10-22-2006 03:46 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Update number of contacts
As far as I can tell it should work. There is no point updating the PSM every second though as there is a limit to how often it updates (6 or times a minute I think ) so any faster and nobody notices anyway.
My PSM+ script just uses the Messenger.CurrentChats.Count everytime a window is created or destroyed and it works fine
<Eljay> "Problems encountered: shit blew up"
|
|
10-22-2006 03:50 PM |
|
|
SnuZZer
Full Member
Posts: 114
32 / /
Joined: Jun 2006
|
O.P. RE: Update number of contacts
Hi.
Ohh.. I'm confused. I'm also use Messenger.CurrentChats.Count, and actually it works when i press "ESC" ( ) But when there aren't any windows open it still says that there is one open.
|
|
10-22-2006 03:56 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Update number of contacts
That's a problem I came across... it's wierd. Just use:
code: --Messenger.CurrentChats.Count
Thats should take 1 away from the value. It makes it correct then all the time.
<Eljay> "Problems encountered: shit blew up"
|
|
10-22-2006 05:33 PM |
|
|
SnuZZer
Full Member
Posts: 114
32 / /
Joined: Jun 2006
|
O.P. RE: Update number of contacts
Hi.
I'm sorry. I don't understand.
Like this?
code: var igang = --Messenger.CurrentChats.Count;
Or like this?
code: var igang = Messenger.CurrentChats.Count--;
|
|
10-22-2006 05:48 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Update number of contacts
should be the first one. If that method doesn't work, use:
code: var igang = Messenger.CurrentChats.Count-1;
EDIT: [/code]
This post was edited on 10-22-2006 at 06:04 PM by Spunky.
<Eljay> "Problems encountered: shit blew up"
|
|
10-22-2006 06:03 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Update number of contacts
code: var _enabled = new Boolean(false);
var oprindeligPB;
function _update_mypersonalmessage(_conversations) {
var _online = 0;
var _offline = 0;
var _total = 0;
for(var e = new Enumerator(Messenger.MyContacts); !e.atEnd(); e.moveNext()) {
if(e.item().Status == 1) { _offline++; }
else { _online++; }
}
var _total = (_online + _offline);
Messenger.MyPersonalMessage = "Online: " + _online + " | Offline: " + _offline + " | I alt: " + _total + " | Åbne vinduer: " + _conversations;
}
function OnEvent_Initialize(bMessengerStart){
try{
oprindeligPB = Messenger.MyPersonalMessage;
}catch (e){}
}
function OnEvent_SignInReady(sEmail) {
if (oprindeligPB != Messenger.MyPersonalMessage){ oprindeligPB = Messenger.MyPersonalMessage; }
if (_enabled == true) { _update_mypersonalmessage(Messenger.Chats.Count); }
}
function OnEvent_Uninitialize(bMessengerExit) {
Messenger.MyPersonalMessage = oprindeligPB;
}
function OnEvent_ContactSignin(){
if (_enabled == true) { _update_mypersonalmessage(Messenger.Chats.Count); }
}
function OnEvent_ContactSignout() {
if (_enabled == true) { _update_mypersonalmessage(Messenger.Chats.Count); }
}
function OnEvent_ChatWndCreated(){
if (_enabled == true) { _update_mypersonalmessage(Messenger.Chats.Count); }
}
function OnEvent_ChatWndDestroyed() {
if (_enabled == true) { _update_mypersonalmessage(Messenger.Chats.Count-1); }
}
function OnGetScriptMenu(Location) {
ScriptMenu = "<ScriptMenu>";
ScriptMenu += "<MenuEntry Id=\"tilfra\">";
if (Status == "fra") { ScriptMenu += "Slå til"; }
else { ScriptMenu += "Slå fra"; }
ScriptMenu += "</MenuEntry>";
ScriptMenu += "</ScriptMenu>";
return ScriptMenu;
}
function OnEvent_MenuClicked(MenuItemId,Location,OriginWnd) {
switch(MenuItemId) {
case "tilfra":
if (_enabled == false) {
_enabled = true;
MsgPlus.DisplayToast("Kontakt information", "Kontakt information er slået til.");
_update_mypersonalmessage(Messenger.Chats.Count);
} else {
_enabled = false;
MsgPlus.DisplayToast("Kontakt information", "Kontakt information er slået fra.");
Messenger.MyPersonalMessage = oprindeligPB;
}
break;
}
}
Would look something like this.
This post was edited on 10-22-2006 at 06:35 PM by matty.
|
|
10-22-2006 06:34 PM |
|
|
SnuZZer
Full Member
Posts: 114
32 / /
Joined: Jun 2006
|
O.P. RE: Update number of contacts
Hi.
If i minus one ( var igang = Messenger.CurrentChats.Count-1;) i must open to windows before the numbers of open chat windows change.
Hi again.
Maybe it is because i turn the counter on in a chatwindow and then it counts that window and don't want to minus it... In a way. .. Does that sounds possible?
|
|
10-22-2006 07:04 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|