NanaFreak, please beware that this won't work. You first set the SentAlready[ChatWnd.Handle] to 0 every time a message is received, even after you have set it to 1.
The correct way would be to do something like this:
code:
var SentAlready = new Array();
function OnEvent_ChatWndCreated(ChatWnd){
SentAlready[ChatWnd.Handle] = 0; //Set an element when a ChatWnd is opened
}
function OnEvent_ChatWndDestroyed(ChatWnd){
SentAlready.splice(ChatWnd.Handle, 1); //Delete the element when the ChatWnd is destroyed
}
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Message.match("Hey") && SentAlready[ChatWnd.Handle] == 0){
ChatWnd.SendMessage('Hi ' + Origin + '! Time to chat again :)');
SentAlready[ChatWnd.Handle] = 1;
}else{
ChatWnd.SendMessage(':yay:');
}
}
See? When a ChatWnd is created, an element in the array is set to 0. When "Hey" is received, that element is set to 1. When the ChatWnd is destroyed, the element is removed.