timer help

Posted by Guest1 on Wed 21 Aug 2002 07:05 AM — 6 posts, 23,449 views.

USA #0
This is probably simpler than I think, but this is what I'm wanting to do:

Whenever I cast a particular spell, I want a message to come up (a grouptell message) 5 minutes later warning the spell is about to drop.

The way I -think- I should do this is to have the existing alias I have that casts the spell to also call a subroutine. The subroutine will enable the timer which is set to fire every 5 mins. Once it's enabled, theoretically it should then fire in 5 minutes time and give the warning message. I would also have it call another script when it fires which disables the timer itself. So far so good.

Does this sound right, or is there an easier way around this?

Also, with another existing timer I have that fires every 1 minute with a message, when I first activate (enable) it, it sends the message then too, which I don't want to happen with this new timer I am planning on setting up. So, is there an easier way to do what I want?

I am wondering if there is some type of vbs routine I can do that when I cast the spell, the subroutine basically says 'wait 5 minutes, then send this message' ..but I don't know if that is possible, and if so, I don't know the correct syntax. Can anyone help?
Australia Forum Administrator #1
This is very simple. A fairly recent script routine will do that for you. Just get the alias to call a script, eg. NotifyUs, which looks like this:


sub NotifyUs (sName, sLine, wildcards)
  world.doafter 5 * 60, "gtell Spell XXX is about to expire"
end sub


DoAfter takes seconds as its first argument, so 5 * 60 would be 5 minutes (or you could just use 300).

No timer should fire when first enabled, this certainly shouldn't. The DoAfter timer is a "on-shot" timer so you don't need to disable it - it will only do its stuff once.

Your problem with enabling timers might be that they are already expired, so once enabled they fire.

Try using ResetTimer first (which resets it back to 0 seconds elapsed) and then enable it.
USA #2
..ok, more info which I can't locate in help; when I use
world.ResetTimers
in a subroutine, am I able to specify which timer(s) to reset, or does it have to reset all of them?
USA #3
Excellent :) Thanks for that script Nick, exactly what I needed.
Australia Forum Administrator #4
Yes you can do one, check out ResetTimer (not resettimers).
USA #5
That's great, thanks for your help Nick, you just solved a number of problems for me :)