What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Help with cancelling msgplus timer

Pages: (2): « First [ 1 ] 2 » Last »
Help with cancelling msgplus timer
Author: Message:
Rizu
New Member
*

Avatar

Posts: 12
– / Female / –
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
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
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
Profile E-Mail PM Find Quote Report
Rizu
New Member
*

Avatar

Posts: 12
– / Female / –
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
Profile E-Mail PM Find Quote Report
Rizu
New Member
*

Avatar

Posts: 12
– / Female / –
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
Profile E-Mail PM Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
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
Profile E-Mail PM Find Quote Report
Rizu
New Member
*

Avatar

Posts: 12
– / Female / –
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
Profile E-Mail PM Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
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. :)
4 8 15 16 23 42
03-11-2007 06:19 PM
Profile E-Mail PM Find Quote Report
Rizu
New Member
*

Avatar

Posts: 12
– / Female / –
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
Profile E-Mail PM Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
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
Profile E-Mail PM Find Quote Report
Rizu
New Member
*

Avatar

Posts: 12
– / Female / –
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
Profile E-Mail PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On