What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » 2 Scripting questions.

2 Scripting questions.
Author: Message:
apex
Junior Member
**


Posts: 20
Joined: Mar 2008
O.P. 2 Scripting questions.
Hi all, as me being starter in scripting, and most of u being advanced, i think u guys could help me out!

I made a script that checks if the first symbol is "~".

Wich is simple to do by:
code:
if(Message.substring(0,1) == "~") { //do what needs to be done}


And know i want to make a feature to let people change the symbol/word they want the script to listen on. And also more then 1 symbol/point, so is their any option to let the script check the first WORD, in stead of what numbers are inside the (), as in (0,1).


The second question:
The Script autmatically detects the name of the Person you are chatting with.
Wich is did this way:
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
    if (test == "on")
    {
        var name = MsgPlus.RemoveFormatCodes(Origin);
        if (name == Banned1 || name == Banned2 || name == Banned3 || name == Banned4 || name == Banned5 || name == Messenger.Myname) {
            if(Message.substring(0,1) == "~") {
                damessage = Message.substring(1,500);
                ChatWnd.SendMessage("");
                Debug.Trace("Trace it!");
            }
        } else {
            if(Message.substring(0,1) == "~") {
                damessage = Message.substring(1,500);
                Messenger.MyPersonalMessage = "" + name.substring(0,25) + " says: " + damessage + "  - You're message here? put a ~ in front of it!";
                ChatWnd.SendMessage("Your auto message" );
                Debug.Trace("trace some text");
                MsgPlus.DisplayToast("It's a toast!");
            }
        }
    }
}


So is their an option to let him return the contacts E-Mail in stead of his name?
I tried changing "Origin" to "E-Mail"  or " Mail"  or "Adres" but it didn't work!
Anyone knows how to create this?


~Apex

p.s. If I didn't make myself clear, plz tell me, my english isn't perfect!
05-18-2008 05:08 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: 2 Scripting questions.
First question:

Try this:

code:
// code retrieves first word ONLY

var FirstWord;

function OnEvent_CatWndReceiveMessage(pChatWnd,sMessage,mOrigin,kMessageKind) {
if(mOrigin != Messenger.MyName) { // Optional!!
switch(sMessage.charAt(0)) { // I prefer charAt fo single characters than substring(0,1)
case "~":
FirstWord = sMessage.split(" ",1);
break;
}
}
}


Workin' on your 2nd..

This post was edited on 05-18-2008 at 05:33 PM by SmokingCookie.
05-18-2008 05:25 PM
Profile PM Find Quote Report
apex
Junior Member
**


Posts: 20
Joined: Mar 2008
O.P. RE: 2 Scripting questions.
So that will also work if you make it "hi" of anything else with more then 1 symbol?
05-18-2008 05:30 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: 2 Scripting questions.
Yes..

charAt is 0-based.. 0 is the first symbol, 1 is the second etc..

I'm currently working on some code for your 2nd question..

Second question:

code:

function OnEvent_ChatWndReceiveMessage(pChatWnd,mOrigin,sMessage,kMessageKind) {
    if(test == "on") {
        var cContacts = pChatWnd.Contacts;
        var e = new Enumerator(Contacts);
        for(i = 0; !e.atEnd(); e.moveNext()) {
            Contact = e.item();
            cEmail = Contact.Email;
        }
        if(cEmail != BannedEmail1 || BannedEmail2 /* and so on*/ || Messenger.MyEmail) {
            if(sMessage.charAt(0) == "~") {
                damessage = Message.substring(1,500);
                pChatWnd.SendMessage("");
                Debug.Trace("Trace it!");
            }
        } else {
            if(sMessage.charAt(0) == "~") {
                damessage = sMessage.substring(1,500);
                Messenger.MyPersonalMessage = "" + name.substring(0,25) + " says: " + damessage + "  - Your message here? put a ~ in front of it!";
                pChatWnd.SendMessage("Your auto message" );
                Debug.Trace("trace some text");
                MsgPlus.DisplayToast("It's a toast!");
            }
        }
    }
}


This should do the trick.

Btw, I have the Dutch version of your script installed ;)

Good work (Y)

EDIT:: Maybe "Your message here? put a ~ in front of it!" should be "Your message here? Type "~<message>".. This is shorter so there's more room for the contact's mesage :P

This post was edited on 05-18-2008 at 05:45 PM by SmokingCookie.
05-18-2008 05:34 PM
Profile PM Find Quote Report
apex
Junior Member
**


Posts: 20
Joined: Mar 2008
O.P. RE: RE: 2 Scripting questions.
quote:
Originally posted by SmokingCookie


Btw, I have the Dutch version of your script installed ;)

Good work (Y)

EDIT:: Maybe "Your message here? put a ~ in front of it!" should be "Your message here? Type "~<message>".. This is shorter so there's more room for the contact's mesage :P

First of all: Thanks for ur answer, realy helps me allot!
Second: TY for using my script :D
Third: When u say: "Typ "~<Message>" some people (in my list...) didn't get it and did like:
"~<Hi there!!>"

And your message can be as long as u want sinds it just takes room from the "Ur Message here" part.


So im going to work with some ur code snipets, lets see were it gets me!!
05-18-2008 05:53 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: 2 Scripting questions.
Hey, just make it through the 100 posts so you can give me a REP +1 :P (just joking :P ).
If you have any question, I'll be there :P .

BTW, what's your main language?
05-18-2008 05:57 PM
Profile PM Find Quote Report
apex
Junior Member
**


Posts: 20
Joined: Mar 2008
O.P. RE: 2 Scripting questions.
I tried to VOTE for u, but i indeed saw u need 100 posts :P

My main language is Dutch :)
05-18-2008 06:05 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: 2 Scripting questions.
Hallo mede-Hollander :P

I already got the idea because "And your message can be as long as u want sinds it just takes room from the "Ur Message here" part." :P

Anyway, happy scripting.
Again, if you need help, I'm almost 24/7 online :P
05-18-2008 06:30 PM
Profile 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