2 Scripting questions. - 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: 2 Scripting questions. (/showthread.php?tid=83797)
2 Scripting questions. by apex on 05-18-2008 at 05:08 PM
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!
RE: 2 Scripting questions. by SmokingCookie on 05-18-2008 at 05:25 PM
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..
RE: 2 Scripting questions. by apex on 05-18-2008 at 05:30 PM
So that will also work if you make it "hi" of anything else with more then 1 symbol?
RE: 2 Scripting questions. by SmokingCookie on 05-18-2008 at 05:34 PM
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
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
RE: RE: 2 Scripting questions. by apex on 05-18-2008 at 05:53 PM
quote: Originally posted by SmokingCookie
Btw, I have the Dutch version of your script installed
Good work
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
First of all: Thanks for ur answer, realy helps me allot!
Second: TY for using my script
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!!
RE: 2 Scripting questions. by SmokingCookie on 05-18-2008 at 05:57 PM
Hey, just make it through the 100 posts so you can give me a REP +1 (just joking ).
If you have any question, I'll be there .
BTW, what's your main language?
RE: 2 Scripting questions. by apex on 05-18-2008 at 06:05 PM
I tried to VOTE for u, but i indeed saw u need 100 posts
My main language is Dutch
RE: 2 Scripting questions. by SmokingCookie on 05-18-2008 at 06:30 PM
Hallo mede-Hollander
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."
Anyway, happy scripting.
Again, if you need help, I'm almost 24/7 online
|