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

[Help] ChatWndReceiveMessage function
Author: Message:
SquidWeed
New Member
*


Posts: 5
Joined: Jan 2009
O.P. [Help] ChatWndReceiveMessage function
Hello,
I'm new to scripting in msgPlus.
I made a script that sends a message as soon as it recieves one.
for some reason, after a random amount of messages recieved, ChatWndReceiveMessage function stops responding.
It start responding again only when the next message is recieved.

I would like to know why it stops responding, and how can I stop this from happening?

tnx in advance,
SquidWeed
01-28-2009 10:52 PM
Profile E-Mail PM Find Quote Report
djdannyp
Elite Member
*****

Avatar
Danny <3 Sarah

Posts: 3546
Reputation: 31
38 / Male / Flag
Joined: Mar 2006
RE: [Help] ChatWndReceiveMessage function
Can you post your code?
[Image: 1ftt0hpk-signature.png]
AutoStatus Script || Facebook Status Script
5426 days, 8 hours, 49 minutes, 59 seconds ago
01-28-2009 11:04 PM
Profile E-Mail PM Find Quote Report
SquidWeed
New Member
*


Posts: 5
Joined: Jan 2009
O.P. RE: [Help] ChatWndReceiveMessage function
function OnEvent_Initialize(MessengerStart)
{
activated=false;
contact=null;
msgs=new Array("bb","cya","have fun","good night");
}

function OnEvent_ChatWndSendMessage(ChatWnd,Message){
    if(Message == "*bye*"){
        activated=!activated;
        var e = new Enumerator(ChatWnd.Contacts);
        contact=e.item();
    }
}
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind){
    if(activated && contact.Name==Origin) ChatWnd.SendMessage(msgs[Math.ceil(Math.random()*msgs.length)]);
}
01-28-2009 11:15 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: [Help] ChatWndReceiveMessage function
Messenger Plus! Live has a built-in flood protection on the ChatWnd.SendMessage function, which prevents a script from sending lots and lots of messages - I think the limit was 10 or 15 or so. I guess that's what you've encountered here, and there's nothing you can do to make it send more. Perhaps you could add a delay of 1 or 2 seconds in your ReceiveMessage event with MsgPlus.AddTimer and OnEvent_Timer to somehow work around this problem, although I'm not very sure whether it'll stop the flood protection.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
01-29-2009 04:50 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: [Help] ChatWndReceiveMessage function
quote:
Originally posted by Matti
Messenger Plus! Live has a built-in flood protection on the ChatWnd.SendMessage function, which prevents a script from sending lots and lots of messages - I think the limit was 10 or 15 or so. I guess that's what you've encountered here, and there's nothing you can do to make it send more. Perhaps you could add a delay of 1 or 2 seconds in your ReceiveMessage event with MsgPlus.AddTimer and OnEvent_Timer to somehow work around this problem, although I'm not very sure whether it'll stop the flood protection.


IIRC flood protection is at 15 messages at which point the user needs to send a message for it to be reset
<Eljay> "Problems encountered: shit blew up" :zippy:
01-29-2009 06:31 PM
Profile PM Find Quote Report
SquidWeed
New Member
*


Posts: 5
Joined: Jan 2009
O.P. RE: [Help] ChatWndReceiveMessage function
I already tried to add a delay of 2 seconds, it didn't work.
And I'm not sure it's a flood protection, because It never gets to 15 messages, the number of messages sent is between 3 to 12.

Besides that, I'm sending only one message at the time so basically it's not flooding, it's an auto-respond

tnx for your replies!
01-30-2009 02:44 AM
Profile E-Mail PM Find Quote Report
SquidWeed
New Member
*


Posts: 5
Joined: Jan 2009
O.P. RE: [Help] ChatWndReceiveMessage function
any other suggestions?
02-17-2009 10:33 PM
Profile E-Mail PM Find Quote Report
SquidWeed
New Member
*


Posts: 5
Joined: Jan 2009
O.P. RE: [Help] ChatWndReceiveMessage function
Last bump I guess, :(
02-22-2009 11:34 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Help] ChatWndReceiveMessage function
Your code is wrong. What is happening is that the random number generated can potentially be 4 because the length of the array is 4. However an Array is zero based meaning it starts counting at 0 not 1. Therefore you need to have msgs.length-1. Like so: When you are using Math.floor you do not need to subtract 1 from the length of the array
js code:
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind){
    if(activated && contact.Name==Origin) ChatWnd.SendMessage(msgs[Math.floor(Math.random()*msgs.length)]);
}

You need to use Math.floor not Math.ceil. Math.floor will round down to the nearest integer where Math.ceil rounds upwards.

This post was edited on 02-23-2009 at 02:22 PM by matty.
02-22-2009 11:49 PM
Profile E-Mail PM Find Quote Report
« 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