What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Display Picture switches back

Pages: (2): « First [ 1 ] 2 » Last »
Display Picture switches back
Author: Message:
Genesis Genome
New Member
*


Posts: 6
Joined: Feb 2009
O.P. Display Picture switches back
the flow of events goes like this:

Display Picture is changed
five second timer is triggered
after five seconds, the Display Picture is changed back to the original

I have had no problems getting this to work.
HOWEVER, occasionally a few seconds after it switches back to the original, it will switch again, back to the one it switched to.
ie, image A becomes image B for 5 seconds, turns back to image A but then after a few seconds goes back to image B and stays there until changed.

The fact that it only does this sometimes and not all the time leads me to think that it may not be a problem on my side but lag between the client and server and the server is switching it back, but I'm really not sure.

Does anyone know the true cause of this problem and has anyone found a (reasonable) work around for it?
02-02-2009 12:56 AM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Display Picture switches back
Post your code.

[code=js][/code]
02-02-2009 02:42 AM
Profile E-Mail PM Find Quote Report
Genesis Genome
New Member
*


Posts: 6
Joined: Feb 2009
O.P. RE: Display Picture switches back
Javascript code:
var DelayLength = 5000;
var FolderWithEmotes = "";
var DParray = new Array(
    "",
    "1.gif",
    "2.gif",
    "3.gif"
);
String.prototype.toArray = function(){
    return this.split(' ');
}
 
function OnEvent_Timer(timerID)
{
    if(timerID == "DPdelay")
    {
        Messenger.MyDisplayPicture = DParray[0];
    }
}
 
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    var index = 0;
    var msgwords = Message.toArray();
    for (var i=0;i<msgwords.length;i++){
 
        if(msgwords[i] == "blah"){
            index = 1;
        }
    }  
 
    if (index > 0) {
        DParray[0] = Messenger.MyDisplayPicture;
        Messenger.MyDisplayPicture = FolderWithEmotes + DParray[index];
        MsgPlus.AddTimer("DPdelay", DelayLength)
    }
    index = 0;
}


basically it scans a message for a word, and if its there it sets your DP to a specific image for a few seconds and then switches back.
And it does that, its just that sometimes it'll switch back to the temporary image.
02-02-2009 10:25 AM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Display Picture switches back
Is the the complete code? If so, some potential problems will arise. This is because you're using timers. And with timers you need to be extra carefull... always. And cope with a lot more situations than just the obvious ones.

For starters, you don't cancel the timer when some other user logs in to Messenger. It isn't even cancelled when you log out. This will produce errors and at the least unexpected behaviour when such events occur. Remember that timers are not user specific and that scripts start to run the second you start Messenger. So they are running even before you log in and continue to run until you completely quit the Messenger application; they don't stop running when you simply log out. So this is also true for timers. All this is way too often forgotten in extremely many scripts (including many in the official script DB), making them all not work properly!!

Second, whenever a message is send before the timer delay has passed, you will get the exact behaviour as you described as being the problem. This is because the second time the ChatWndSendMessage event is fired the 'original' DP in the array (at index 0) is overwritten with the temporary one from the previous event.

So, what you must do:
1) add the event for when the user signs out. In that event, cancel the timer which might still be running.

2) Add a check to see if the global array contains an 'original' DP at index 0. if so, do not write the current display picture to index 0. This because when this occurs, the current showing DP is not the user's original one but a temporary one from a previous 'word to DP' event.

3) In the timer event, after the original DP is set back, you also need to clear out index 0 of the global array to accomodate proper workings of point 2.


Note: there are limits in how often you can change your DP in a certain timespan. This means that scripts like this will always have some potential problems and limits and might not always work properly; there will always be times and situations when your original DP can not be set back.


Note for point 1: you can make it a bit more complicated in such a way that the timer isn't cancelled but continues to run when a user logs out. But, in that case you need to make the timer user specific (the name can contain the user ID to make it user specific) and check if the same user is still logged in before setting the DP back. This makes that the script will support multiple users and that it can cope with sudden unexpected disconnections and reconnections of Messenger. Ofcourse, you would also need an array per user, or in other words a two dimensional array containing the user's ID and the corresponding original DP, (and the index of the 'Word'-DP for that user).

;)

This post was edited on 02-02-2009 at 03:12 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
02-02-2009 02:59 PM
Profile PM Find Quote Report
Genesis Genome
New Member
*


Posts: 6
Joined: Feb 2009
O.P. RE: Display Picture switches back
According to the documentation, the timer is only created once when called and is destroyed after completion, so I don't understand your problem with the timer never going away.
It is created only when a matching word is found, and deletes itself 5 seconds later.

and the problem with changing dps to fast and overwriting the original I am well aware of, however even if I don't say anything at all, it will still sometimes switch back. so I know this is not the problem either.
02-02-2009 03:51 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Display Picture switches back
quote:
Originally posted by Genesis Genome
According to the documentation, the timer is only created once when called and is destroyed after completion, so I don't understand your problem with the timer never going away.
It is created only when a matching word is found, and deletes itself 5 seconds later.
The problem is that when the timer is started, the user could sign out and optionally sign back in on another account and when the timer is finished, the code gets executed on the wrong account. Therefore, it is wise to cancel your timers on sign out or, as mentioned by Cookie's footnote, make your timer ID contain user-specific details to determine the user and/or picture index.
quote:
Originally posted by Genesis Genome
and the problem with changing dps to fast and overwriting the original I am well aware of, however even if I don't say anything at all, it will still sometimes switch back. so I know this is not the problem either.
Well, in my opinion you shouldn't allow it to change more than 5 times per minute, since every time you change it, it has to be uploaded to the Messenger servers. Seeing that you already change it twice with a five second interval, you might run into some troubles. For example, you could add a timer after your "DPDelay" timer was executed to prevent changes for the next 20 seconds or so using some kind of global variable.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
02-02-2009 04:03 PM
Profile E-Mail PM Web Find Quote Report
Genesis Genome
New Member
*


Posts: 6
Joined: Feb 2009
O.P. RE: Display Picture switches back
Well, considering the chances of me sending a message that triggers the timer,logging out and logging into a second account I don't have, all within 5 seconds, the issue isn't on the top of my todo list.
but adding a second timer to prevent consecutive changes is a good idea, I'll have a play with that. thanks.
It seems like its just the server rejecting my changes after all, which is what I always suspected.
02-02-2009 04:10 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Display Picture switches back
quote:
Originally posted by Genesis Genome
It seems like its just the server rejecting my changes after all, which is what I always suspected.
Correct. When you update it too much, it'll simply ignore your requests or even send you annoying error pop-ups. If the servers didn't do that, there wouldn't be any problem - but they do. :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
02-02-2009 04:14 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: Display Picture switches back
quote:
Originally posted by Genesis Genome
According to the documentation, the timer is only created once when called and is destroyed after completion, so I don't understand your problem with the timer never going away.
It is created only when a matching word is found, and deletes itself 5 seconds later.
I never said the timer will never go away though. I said the timer will still be running when you log off (for whatever reason, it doesn't need to be explicitly be done by you) if the delay hasn't passed yet.

Also, a lot of stuff can happen in those 5 seconds. Stuff which you don't always have control over. Thus including but not limited to the user logging out _and_ the user sending another message.

Note that by logging out I mean eveything that involves the user logging out, thus this also means sudden and quick disconnections and reconnections and other network hickups which might/will occur.

This is something you _must_ take in account when working with timers or you _will_ have problems.

quote:
Originally posted by Genesis Genome
and the problem with changing dps to fast and overwriting the original I am well aware of, however even if I don't say anything at all, it will still sometimes switch back. so I know this is not the problem either.
Sorry, but it IS one of the problems you WILL encounter. Maybe not now, but later on for sure.

If it happens when you don't say anything at all then that can be caused by ANOTHER problem which was also explained before and which you apparently are aware of: there is a limit on how many times in a certain amount of time you can change the DP.

Then there is also yet ANOTHER problem which involves roaming. This might occur if you have selected the option "Always keep my DP the same nomatter where I sign in". The servers might not be able to update the DP serverside quickly enough (because of the limit) and detect that there was a DP change and thus send the one they do have back (which was actually your temporary one).

quote:
Originally posted by Genesis Genome
Well, considering the chances of me sending a message that triggers the timer,logging out and logging into a second account I don't have, all within 5 seconds, the issue isn't on the top of my todo list.
Which should be though! There are a lot more situations than you explicitly logging in and out in 5 seconds time. Moreover, the fixes are extremely basic, small and very easy. Not some complex stuff you need to take your time for to implement.

quote:
Originally posted by Genesis Genome
It seems like its just the server rejecting my changes after all, which is what I always suspected.
Together with the rest of the stuff which was explained. It is not just the server rejecting your changes.

I'm sorry to sound a bit grumpy here, but you came here seeking info/advise/help. We gave the exact info you needed and I gave the exact steps which you must do to fix everything there is to fix for as far as you can fix it (you can't fix the problem of the DP change limit as that is serverside). Besides, they are only a few lines of codes (like 4 lines maybe at the most), nothing complex at all.

Simply ignoring these simple but mandatory recommendations to make such script bug free as much as you can, and suggesting that the fixes we suggest are not important, or that we may even be wrong maybe, seems a bit strange to me when you come here to seek some help or advise (and a waste of time from the helpers too if you simply ignore their comments).

Nice idea for a script though...

But as said before also: such scripts will unfortunatly never be able to work properly because of the said limitations. But that does not mean you shouldn't fix the potential problems you already have now, with or without that serverside limitation.

So, adding another timer will NOT fix those other problems I talked about. In fact, it will make things worse and more complex (but not impossible) to cope with. Your choice of course...


;)

This post was edited on 02-02-2009 at 05:40 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
02-02-2009 04:29 PM
Profile PM Find Quote Report
Genesis Genome
New Member
*


Posts: 6
Joined: Feb 2009
O.P. RE: Display Picture switches back
Woh, I didn't mean to get you so riled up.
I know the script isn't perfect, and I know that the timer cancelling is important and should be there to reduce problems further down the road, but the reason I pushed these aside is because they were not relevant to my original question of "why does it switch back" (the answer being the server refuses to handle multiple quick changes)
I'm grateful of the help you've given me and all and I have fixed up these problems already.
Thanks again,
-Gen
02-02-2009 05:17 PM
Profile E-Mail PM 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