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

Pages: (4): « First [ 1 ] 2 3 4 » Last »
Help with code
Author: Message:
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
O.P. Help with code
Me, with help of my friend, made this code (mainly my friend :P) and I want it to react on words that I have in a file. The problem is that it responds to anything now. In the file I have:
quote:
hi
hello
hey
howdy

My friend also told me that I should but the code in functions, I know what functions are and how they work but I don't really understand how I should do it. Help please? :D

JScript code:
var curWord = 0;
 
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {
    if(Origin != Messenger.MyName) {
    var parts = Message.split(" ");
    curWord = 0;
        while(1) {
       
         var ofr, ofr1, ofr2, a1, f1, txt; //ofr = open file read
            var ForReading = 1;
            ofr = new ActiveXObject("Scripting.FileSystemObject");
            ofr1 = ofr.OpenTextFile("C:\\Program\\Messenger Plus! Live\\Scripts\\B.O.T._ Being Optimized for Troubleshooting\\text.txt",ForReading);
            ofr2 = ofr1.ReadAll();
            ofr1.Close();
            var i;
            var Message = " ";
            while (i<10) {
        Message = ofr2.split("\r\n");
            }
        if(parts[curWord] == Message[i]){
     
        var ofa, ofa1, ofa2, a1, f1, txt; //ofa = open file answer
            var ForReading = 1;
            ofa = new ActiveXObject("Scripting.FileSystemObject");
            ofa1 = ofa.OpenTextFile("C:\\Program\\Messenger Plus! Live\\Scripts\\B.O.T._ Being Optimized for Troubleshooting\\text.txt",ForReading);
            ofa2 = ofa1.ReadAll();
            ofa1.Close();
           
            var sendMessage = " ";
        sendMessage = ofa2.split("\r\n");
           ChatWnd.SendMessage(sendMessage[Math.round(Math.random()%4)]);
        ofa2 = 0;
            break;
        }
       
        if(curWord == 150) {
            break;
        }
        curWord += 1;
    }
    }
} //function OnEvent

11-04-2008 07:38 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: Help with code
First, why do you use the long path in OpenTextFile(), while you can also use MsgPlus.ScriptFilesPath + "\\text.txt"?

Second.. Give me a couple of seconds and I'll try to figure something out..

I think you're doing things a bit too complicated..

[See last post]

This post was edited on 11-06-2008 at 07:43 PM by SmokingCookie.
11-04-2008 07:43 PM
Profile PM Find Quote Report
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
O.P. RE: Help with code
It works, just now when someone says anything it replies :|
11-05-2008 06:33 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: Help with code
Sorry for prev. post, forgot to read :P

I'm working on something for you ;)
See my first post

This post was edited on 11-05-2008 at 06:51 PM by SmokingCookie.
11-05-2008 06:50 PM
Profile PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
29 / Male / Flag
Joined: Nov 2006
Status: Away
RE: Help with code
iirc, activexobjects aren't recommended to be defined as a global variable
try this (looking at your code..):):
JScript code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MsgKind){
    if(Origin!=Messenger.MyName){
        var file=new ActiveXObject("Scripting.FileSystemObject").OpenTextFile(MsgPlus.ScriptFilesPath+"\\text.txt",1,1);
        var text=file.ReadAll().split("\r\n");
        file.close();
        for(i in text)if(new RegExp(text[i],"i").test(Message)){
            ChatWnd.SendMessage(text[Math.floor(Math.random()*text.length)]);
            break;
            }
     }
}


This post was edited on 11-05-2008 at 06:59 PM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
11-05-2008 06:57 PM
Profile PM Web Find Quote Report
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
O.P. RE: Help with code
Now it doesn't work at all :S
11-05-2008 07:00 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: Help with code
Got it!

[last post]

This post was edited on 11-06-2008 at 07:55 PM by SmokingCookie.
11-05-2008 07:30 PM
Profile PM Find Quote Report
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
O.P. RE: Help with code
Now it only does it once, if I don't close the window, I want it to reply everytime :o
11-06-2008 07:20 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: Help with code
Post updated ;)
11-06-2008 07:42 PM
Profile PM Find Quote Report
Jonte135
Junior Member
**


Posts: 57
– / – / Flag
Joined: Aug 2007
O.P. RE: Help with code
It worked most of the time, but when the friend that tested it said this:
quote:
I would need some sort of software *on* your computer, that was (1) running, (2) not being blocked by some AV or Firewall, and (3) able to send me screenshots or something like that of your desktop
it responded :| It shouldn't do that :(
Now it doesn't respond at all :|
11-06-2008 07:49 PM
Profile E-Mail PM Find Quote Report
Pages: (4): « First [ 1 ] 2 3 4 » 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