quote:
Originally posted by matty
js code:
var oChatWnds = {};
function OnEvent_ChatWndSendMessage(pChatWnd, sMessage) {
if (sMessage.charAt(0) !== '/' && typeof oChatWnds[pChatWnd.Handle] === 'undefined') {
>>> oChatWnds[pChatWnd.Handle] = {<<<
>>> Message : sMessage,<<<
>>> i : 0<<<
>>> };<<<
MsgPlus.AddTimer(pChatWnd.Handle, 5000);
return '';
}
}
function OnEvent_Timer(sTimerId) {
var oChat = oChatWnds[sTimerId];
var Message = oChatWnds[sTimerId].Message.charAt(oChatWnds[sTimerId].i);
if (Message === '/') Message = '//';
++oChatWnds[sTimerId].i;
>>> oChat.SendMessage(Message);<<<
MsgPlus.AddTimer(sTimerId, 5000);
}
The oChat isn't actually a chat window, but just an object with
Message and
i properties.
Would this work?
js code:
var oChatWnds = {};
function OnEvent_ChatWndSendMessage(pChatWnd, sMessage) {
if (sMessage.charAt(0) !== '/' && typeof oChatWnds[pChatWnd.Handle] === 'undefined') {
oChatWnds[pChatWnd.Handle] = {
Message : sMessage,
i : 0,
Wnd : pChatWnd
};
MsgPlus.AddTimer(pChatWnd.Handle, 5000);
return '';
}
}
function OnEvent_Timer(sTimerId) {
var oChat = oChatWnds[sTimerId];
var Message = oChatWnds[sTimerId].Message.charAt(oChatWnds[sTimerId].i);
if (Message === '/') Message = '//';
++oChatWnds[sTimerId].i;
oChat.Wnd.SendMessage(Message);
MsgPlus.AddTimer(sTimerId, 5000);
}