Help with cancelling msgplus timer |
Author: |
Message: |
Rizu
New Member
Posts: 12
– / / –
Joined: Nov 2006
|
O.P. Help with cancelling msgplus timer
I've set up some msgplus timers to automatically send voice clips to my contacts, and I want to be able to cancel them by sending a command. This is a portion of the script:
quote: var ChatWnds = new Array();
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Message == "!s"){
ChatWnd.SendMessage("/vc 15");
ChatWnds[ChatWnds.length-1] = ChatWnd;
MsgPlus.AddTimer("Delay1"+[ChatWnds.length-1], 15300);
}
}
function OnEvent_Timer(TimerId){
switch(TimerId.substr(0,6)){
case "Delay1":
ChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
MsgPlus.AddTimer("Delay2"+[TimerId.substr(6)], 15300);
break;
case "Delay2":
ChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
}
}
So, how would I be able to properly call the syntax
MsgPlus.CancelTimer("Delay1"+[ChatWnds.length-1], 15300);
by using a message command?
I've tried several things such as else if but they have only rendered the script unusable. I'm completely out of ideas and can't find any help in the documentation.
This post was edited on 03-11-2007 at 04:24 AM by Rizu.
|
|
03-11-2007 03:23 AM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Help with cancelling msgplus timer
MsgPlus.CancelTimer only accepts 1 parameter... The name of the timer to cancel.
|
|
03-11-2007 04:49 AM |
|
|
Rizu
New Member
Posts: 12
– / / –
Joined: Nov 2006
|
O.P. RE: Help with cancelling msgplus timer
So, it would be like this?
MsgPlus.CancelTimer("Delay1"+[ChatWnds.length-1]);
I've used that instead, but it still is not working...
|
|
03-11-2007 05:01 AM |
|
|
Rizu
New Member
Posts: 12
– / / –
Joined: Nov 2006
|
O.P. RE: Help with cancelling msgplus timer
Clearly, I must be doing something wrong with triggering the command with a message, because those syntaxes work fine without the message command.
Here's what I'm trying to do:
quote: var ChatWnds = new Array();
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Message == "!s"){
ChatWnd.SendMessage("/vc 15");
ChatWnds[ChatWnds.length-1] = ChatWnd;
MsgPlus.AddTimer("Delay1"+[ChatWnds.length-1], 15300);
else if(Message == "!q"){
MsgPlus.CancelTimer("Delay1"+[ChatWnds.length-1]);
What's the proper way to trigger this command with a received message?
|
|
03-11-2007 05:50 PM |
|
|
foaly
Senior Member
Posts: 718 Reputation: 20
38 / /
Joined: Jul 2006
|
RE: Help with cancelling msgplus timer
quote: Originally posted by Rizu
code: var ChatWnds = new Array();
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Message == "!s"){
ChatWnd.SendMessage("/vc 15");
ChatWnds[ChatWnds.length-1] = ChatWnd;
MsgPlus.AddTimer("Delay1"+[ChatWnds.length-1], 15300);
else if(Message == "!q"){
MsgPlus.CancelTimer("Delay1"+[ChatWnds.length-1]);
the way you use the array is wrong...
you should call it like:
code: MsgPlus.CancelTimer("Delay1"+ChatWnds.length-1);
should work...
|
|
03-11-2007 06:02 PM |
|
|
Rizu
New Member
Posts: 12
– / / –
Joined: Nov 2006
|
O.P. RE: Help with cancelling msgplus timer
Yes, that does work. But I need a received message to trigger it, just like how "!s" will trigger the array and timer.
|
|
03-11-2007 06:07 PM |
|
|
vikke
Senior Member
Posts: 900 Reputation: 28
31 / /
Joined: May 2006
|
RE: Help with cancelling msgplus timer
code: var aChatWnds = new Array();
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Message == "!s"){
ChatWnd.SendMessage("/vc 15");
aChatWnds[aChatWnds.length-1] = ChatWnd;
MsgPlus.AddTimer("Delay1"+[aChatWnds.length-1], 15300);
else if(Message == "!q"){
MsgPlus.CancelTimer("Delay1"+aChatWnds.length-1);
}
}
I've also changed the ChatWnds name to aChatWnds, because MP!L uses that name. That should work, maybe we are handling wrong with the arrays, don't know.. If it does not work, give me the error.
|
|
03-11-2007 06:19 PM |
|
|
Rizu
New Member
Posts: 12
– / / –
Joined: Nov 2006
|
O.P. RE: Help with cancelling msgplus timer
It is still not working. Here's the complete script with your ammendments:
quote: var aChatWnds = new Array();
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Message == "!s"){
ChatWnd.SendMessage("/vc 15");
aChatWnds[aChatWnds.length-1] = ChatWnd;
MsgPlus.AddTimer("Delay1"+[aChatWnds.length-1], 15300);
else if(Message == "!q"){
MsgPlus.CancelTimer("Delay1"+aChatWnds.length-1);
}
}
function OnEvent_Timer(TimerId){
switch(TimerId.substr(0,6)){
case "Delay1":
aChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
MsgPlus.AddTimer("Delay2"+[TimerId.substr(6)], 15200);
break;
case "Delay2":
aChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
MsgPlus.AddTimer("Delay3"+[TimerId.substr(6)], 15200);
break;
case "Delay3":
aChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
MsgPlus.AddTimer("Delay4"+[TimerId.substr(6)], 15200);
break;
case "Delay4":
aChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
MsgPlus.AddTimer("Delay5"+[TimerId.substr(6)], 15200);
break;
case "Delay5":
aChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
MsgPlus.AddTimer("Delay6"+[TimerId.substr(6)], 15200);
break;
case "Delay6":
aChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
MsgPlus.AddTimer("Delay7"+[TimerId.substr(6)], 15200);
break;
case "Delay7":
aChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
MsgPlus.AddTimer("Delay8"+[TimerId.substr(6)], 15200);
break;
case "Delay8":
aChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
MsgPlus.AddTimer("Delay9"+[TimerId.substr(6)], 15200);
break;
case "Delay9":
aChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
MsgPlus.AddTimer("Delay10"+[TimerId.substr(6)], 15200);
break;
case "Delay10":
aChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
break;
}
}
This has only rendered the script unusable. Perhaps I should debug this?
This post was edited on 03-11-2007 at 06:28 PM by Rizu.
|
|
03-11-2007 06:24 PM |
|
|
foaly
Senior Member
Posts: 718 Reputation: 20
38 / /
Joined: Jul 2006
|
RE: Help with cancelling msgplus timer
you didn't fix the mistake when you create the timer...
code: aChatWnds[aChatWnds.length-1] = ChatWnd;
MsgPlus.AddTimer("Delay1"+aChatWnds.length-1, 15300);
else if(Message == "!q"){
you used the [] again...
|
|
03-11-2007 07:19 PM |
|
|
Rizu
New Member
Posts: 12
– / / –
Joined: Nov 2006
|
O.P. RE: Help with cancelling msgplus timer
I fixed that error, but it is still not working...
quote: var aChatWnds = new Array();
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Message == "!s"){
ChatWnd.SendMessage("/vc 15");
aChatWnds[aChatWnds.length-1] = ChatWnd;
MsgPlus.AddTimer("Delay1"+aChatWnds.length-1, 15300);
else if(Message == "!q"){
MsgPlus.CancelTimer("Delay1"+aChatWnds.length-1);
}
}
function OnEvent_Timer(TimerId){
switch(TimerId.substr(0,6)){
case "Delay1":
aChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
MsgPlus.AddTimer("Delay2"+TimerId.substr(6), 15200);
break;
case "Delay2":
aChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
|
|
03-11-2007 08:34 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|