quote:
Originally posted by roflmao456
Welcome to the forum!
code:
var word = new Array(
"your",
"words",
"here"
);
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind){
if(Origin != Messenger.MyName){
for(i=0;i<word.length;i++){
if(Message.search(word[i]) != -1){
MsgPlus.PlaySound("path\\to\\sound\\file");
}
}
}
}
i'm not sure if that will work but you can try.
btw, for a single backslash ( \ ) you have to put two. so
\\
will result in a single backslash
Your code can be made a little better, the use of a regular expression means that you only have to make the one if statement rather than 2 and the for statement. Also you might want to look at using things other than a search method because it doesn't give much that you can work with after (I know there was nothing in this case but it can be useful later and a good habit to get into).
code:
var word = new Array(
"your",
"words",
"here"
);
var re = RegExp("\b"+word.join("\b|\b")+"\b","i");
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind){
if(Origin != Messenger.MyName && re.test(Message)){
MsgPlus.PlaySound("path\\to\\sound\\file");
}
}
This code does exactly the same as roflmao456's code anyway, I think the problem might be in the path that you are making. Please make sure that you use the \\ and that you start from the drive letter and double check that the file exists where you are looking.
If that doesn't work then please try this code:
code:
MsgPlus.PlaySound("path\\to\\sound\\file");
This is just to make sure that the sound file is work and that you have the right path to it. It should make the sound when you save the script. I advise you to get rid of this once it has worked or else every time you start messenger then you will hear the sound.
If you keep having troubles can you please copy and paste the path that you are using to the file so that we can just double check you are doing it correctly and also make sure that you have your sound on (you'd be amazed at how many people don't think of the little things).