Me, with help of my friend, made this code (mainly my friend
) 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?
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