Shoutbox

[HELP] Adding a timer using var as interval (read for more details) - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [HELP] Adding a timer using var as interval (read for more details) (/showthread.php?tid=76685)

[HELP] Adding a timer using var as interval (read for more details) by Kriogenic on 08-10-2007 at 03:23 PM

Hey.

Ok I am adding a timer and I am using a variable as the interval but I want to do some maths to it IE times it by 60000 to get it into milisecond format...

My script you enter the minutes into a box and click ok so lets say 1 it executes this...

code:
var Time = config.GetControlText("IntervalTime");
AddTimer("updatepm", Time * 60000 );


This gives me an error basically its meant to go Time (Usually 1 or similar) gets times by 60000 to give how many miliseconds...

Help please >.<

Thanks,
Kriogenic.

RE: [HELP] Adding a timer using var as interval (read for more details) by Matti on 08-10-2007 at 03:27 PM

If you'd have posted the error, we could've seen much faster what's wrong. AddTimer is a child function of the MsgPlus object, so you need to use:

code:
var Time = config.GetControlText("IntervalTime");
MsgPlus.AddTimer("updatepm", Time * 60000 );
;)
RE: [HELP] Adding a timer using var as interval (read for more details) by Kriogenic on 08-10-2007 at 03:31 PM

I do that all the time... Always forget that... Then I always think the problem is something else >.<

My 2 biggest errors... Forgetting MsgPlus. and forgetting its cap sensative...

Thanks for your help.
Kriogenic.


RE: [HELP] Adding a timer using var as interval (read for more details) by roflmao456 on 08-10-2007 at 10:46 PM

A suggestion: If you keep doing this, you might want to just create a function:

code:
function AddTimer(TimerId, Interval){
    MsgPlus.AddTimer(TimerId, Interval);
}

RE: [HELP] Adding a timer using var as interval (read for more details) by LifelesS on 08-11-2007 at 12:49 AM

What I usually do is a function like

code:
function Timer(Id, TimeSec)
{
          return MsgPlus.AddTimer(Id, TimeSec*1000)
}


Or I just change the number of zeros, depending of what I want, to keep things easy
RE: [HELP] Adding a timer using var as interval (read for more details) by ShawnZ on 08-11-2007 at 01:23 AM

quote:
Originally posted by roflmao456
A suggestion: If you keep doing this, you might want to just create a function:

code:
function AddTimer(TimerId, Interval){
    MsgPlus.AddTimer(TimerId, Interval);
}


why not just AddTimer=MsgPlus.AddTimer?
RE: [HELP] Adding a timer using var as interval (read for more details) by markee on 08-11-2007 at 01:58 AM

quote:
Originally posted by roflmao456
A suggestion: If you keep doing this, you might want to just create a function:

code:
function AddTimer(TimerId, Interval){
    MsgPlus.AddTimer(TimerId, Interval);
}

You are better off just doing this to the whole lot
code:
with(MsgPlus){
   //put your code here
   AddTimer("updatepm", Time * 60000 );
   //put some more code here
}

This code is also very helpful if you are using the same object quite a few times in a small area, it just saves you writing it out all the time.
RE: [HELP] Adding a timer using var as interval (read for more details) by Kriogenic on 08-11-2007 at 06:41 AM

Hmm thanks. These ideas will help.

Thanks again people,
Kriogenic.