What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Need a counter for a specific contact

Need a counter for a specific contact
Author: Message:
chadchoud
New Member
*


Posts: 3
Joined: Sep 2008
O.P. Need a counter for a specific contact
Well I'm checking bad words from users.

code:
times = 0;
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
    var Contacts = ChatWnd.Contacts;
    var e = new Enumerator(Contacts);
    var Contact = e.item();
    if (Message == "some bad word here") {
        times = times + 1;
        MsgPlus.DisplayToast("Look man", Origin + " sent a bad word");
        ChatWnd.SendMessage("This is your warning number: " + times);
        if (times == 1) {
            ChatWnd.SendMessage("One more time and you'll be blocked.");
        }
        else if (times >= 2) {
            Contact.Blocked = true;
        }
    }
}

Ok my problem is with the global variable. Say contact X says this bad word, then contact Y says it, Y gets blocked because times gets equal 2 at Y's message. What I need to know is if it' possible fr every contact to hold its own counter.

Sorry if my idea is a bit noob, but it will let me understand other concepts.

Thank you.
09-18-2008 08:04 PM
Profile E-Mail PM Find Quote Report
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
RE: Need a counter for a specific contact
I would recommend using an array to hold the count data.
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
09-18-2008 08:17 PM
Profile PM Web Find Quote Report
chadchoud
New Member
*


Posts: 3
Joined: Sep 2008
O.P. RE: RE: Need a counter for a specific contact
quote:
Originally posted by MeEtc
I would recommend using an array to hold the count data.

Can you please explain how?
Arrays don't really exist in the MPLdocs I have (the chm file).
09-18-2008 08:19 PM
Profile E-Mail PM Find Quote Report
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
RE: Need a counter for a specific contact
No, an array structure has nothing to do with the messenger plus documentation, its in the JScript documentation from Microsoft.
http://www.microsoft.com/downloads/details.aspx?f...BB9&displaylang=en

snippet from the docs:
quote:
Traditionally, array elements are given numeric indices, starting at zero. It is these elements that interact with the length property. Nevertheless, because all arrays are also objects, they support expando properties as well. Note, though, that expando properties do not interact with the length property in any way. For example:

// An array with three elements
var myArray = new Array(3);

// Add some data
myArray[0] = "Hello";
myArray[1] = 42;
myArray[2] = new Date(2000, 1, 1);

// This will display 3, the length of the array
window.alert(myArray.length);

// Add some expando properties
myArray.expando = "JScript!";
myArray["another Expando"] = "Windows";

// This will still display 3, since the two expando properties
// don't affect the length.
window.alert(myArray.length);
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
09-18-2008 08:30 PM
Profile PM Web Find Quote Report
chadchoud
New Member
*


Posts: 3
Joined: Sep 2008
O.P. RE: Need a counter for a specific contact
Fine. I created
code:
count = new Array();
outside the function then inside it I replaced times with count[Contact.Email] so that it becomes:
code:
count[Contact.Email] = count[Contact.Email] + 1;
But
code:
Debug.Trace(count[Contact.Email]);
prints:
-1.#IND

What's wrong now?

Edit: Solved. Had to check if it's != null. :)

This post was edited on 09-18-2008 at 09:09 PM by chadchoud.
09-18-2008 08:56 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