Shoutbox

Contact PSM change - 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: Contact PSM change (/showthread.php?tid=86927)

Contact PSM change by ArkaneArkade on 10-28-2008 at 06:28 AM

Hey folks,
I've got a bit of an odd one here.  I want a script to copy another contacts PSM, if and when they change it.  However, in this particular situation, the PSM event doesnt fire for this contact.  I'm wondering if theres another way to check for a contact changing PSM,  without using timers if at all possible?

I'm also struggling to figure out how to check if a contact is online at signin, for the same script.  Basically, just to copy their PSM then.

Anyone have any suggestions?
Cheers
Leroux


RE: Contact PSM change by SmokingCookie on 10-28-2008 at 03:32 PM

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.
RE: Contact PSM change by ArkaneArkade on 10-28-2008 at 06:29 PM

Cheers SmokingCookie, I'd completely forgotten how to do enumerators.  Need to stop leaving scripting for so long.  I've got work unfortunately, but after I'm back I'll give it a try and sort everything out.

Regarding the PSM, its a problem becuase I'm trying to get it from a 360.  I know people have made scripts before, but they never work for me.  Its possible to ge the PSM, but the event doesnt fire when the 360 PSM changes.  I have my suspicions regarding why, but in the end it doesnt change anything.  I was gonna use Xniff to get it, but tbh, I think I'll go for the timer.  It'll crash much less, and don't think I care if my name shows they're playing a game for a little longer


RE: Contact PSM change by Matti on 10-28-2008 at 06:35 PM

Why do you need to collect all Contact objects first, when you can do:

code:
function OnEvent_ContactSignin(Email) {
      var Contact = Messenger.MyContacts.GetContact(Email);
      if(Contact.Status == STATUS_ONLINE /* Assume you have MsgPlus 4.23 or higher? */ ) {
            [do what you want to here]
      }
}
Try not to make things more complicated than necessary. Plus! Live scripting is already hard enough! :P
RE: Contact PSM change by SmokingCookie on 10-28-2008 at 06:37 PM

You can use enumerators using the for() loop, as I'd described in my previous post. There may be alternatives, like a while() loop, but this one's what I got used to and prefer to use.

Cheerio ;)

@ Matti:

Cause I think such an array is easier to access, also throughout the script. If you have a load of oops, you'll use lots of memory (and perhaps CPU usage), which you might have wanted to use for other things.


RE: Contact PSM change by matty on 10-28-2008 at 06:42 PM

quote:
Originally posted by SmokingCookie
@ Matti:

Cause I think such an array is easier to access, also throughout the script. If you have a load of oops, you'll use lots of memory (and perhaps CPU usage), which you might have wanted to use for other things.
Which will fail if a new contact is added they will not be in the list.

If at all possible use GetContact.
RE: Contact PSM change by ArkaneArkade on 10-28-2008 at 10:32 PM

I have it working with the GetContact now.  The enumerator worked fine, but I will only need it for a single contact, so the array just gets wasted.

- Looks like its all four naught anyway.  Plus doesnt return the personal message for that account either.  Very odd, since I'm relatively sure that it did yesterday, but nevermind.  I'm just gonna have to use Xniff instead.


RE: Contact PSM change by Spunky on 10-29-2008 at 04:46 PM

quote:
Originally posted by Leroux
I'm just gonna have to use Xniff instead

I have a feeling that the messages you'll need to look for will be formatted differently or used in a slightly different context (thus why Plus! doesn't seem to get them from WLM properly... it's like a new field rather than the psm (similar to how MediaPSM isn't the same as PSM, but they occupy the same space.)
RE: RE: Contact PSM change by ArkaneArkade on 10-29-2008 at 07:01 PM

I have a feeling that the messages you'll need to look for will be formatted differently or used in a slightly different context (thus why Plus! doesn't seem to get them from WLM properly... it's like a new field rather than the psm (similar to how MediaPSM isn't the same as PSM, but they occupy the same space.)



I have it working... or did, it randomly stopped now.  It is formatted slightly differently, and I think thats whats stopping Plus! detecting it, but it is still a PSM as far as I can tell, efter looking at Xniffs data for xbox and normal accounts.  I just don't understand why I was successfully getting the PSM from it yesterday, but not today.  Although I've just remembered what it was actually doing to give me it, so I'll do some testing.