code:
var Contacts = new Array();
function LoadContacts() {
for(var e = new Enumerator(Messenger.MyContacts); !e.atEnd(); e.moveNext()) {
Contacts[e.item().Email] = e.item(); // Convert Messenger.MyContacts to an array
}
}
function OnEvent_ContactSignin(Email) {
if(Contacts[Email].Status == STATUS_ONLINE /* Assume you have MsgPlus 4.23 or higher? */ ) {
[do what you want to here]
}
}
Call LoadContacts() somewhere in the very beginning of your script, recommend OnEvent_SigninReady();
If a change occurs in your contact list, Messenger Plus! will update the Contacts
array, as well as Messenger.MyContacts and ChatWnd.Contacts.
A PSM change --> should <-- call OnEvent_ContactPsmChange() (unless you change your own psm). An extra safety option for ContactSignin would be:
code:
function OnEvent_ContactSignin(Email) {
if(Email in Contacts) {
if(Contacts[Email].Status == STATUS_ONLINE /* Assume you have MsgPlus 4.23 or higher? */ ) {
[do what you want to here]
}
}
}
Also, if OnEvent_ContactPsmChange() occurs, the Contacts array (by which I mean our array declared in the global scope at the top, not MsgPlus' Contact(s) object) is updated.