I figured out a workaround using $ltimer. If anyone has a similar problem with a timer, here is my workaround.
When you run the command, check if $ltimer = $null. This should be true as long as a timer hasn't run on the script yet. Then have an elseif statement that checks if $ltimer = Anno (my timer's name is Anno). When this is true, it will turn the timer off. The problem is when you try to run the command a second time, $ltimer = Anno, so it will just run the off commands. The fix for this is when you turn the timer off, make a dummy timer that turns off after 2 seconds. This will set(in my case)$ltimer = Dummy. So add another elseif statement to check if $ltimer = Dummy to turn on the timer.
on *:TEXT:!anno:#: {
if ($nick isop # && $ltimer = $null) {
.timerAnno 0 5 /play # C:\Users\user\Desktop\announcements.txt
msg $chan Announcer On
}
elseif ($nick isop # && $ltimer = Dummy) {
.timerAnno 0 5 /play # C:\Users\user\Desktop\announcements.txt
msg $chan Announcer On
}
elseif ($nick isop # && $ltimer = Anno) {
.timerAnno off
msg $chan Announcer Off
.timerDummy 0 2 .timerDummy off
}
}
on *:TEXT:!resetanno:#: {
.timerDummy 1 2 .timerDummy off
msg $chan Announcer Reset
}
I also added a reset command called !resetanno. This command just turns the Dummy timer on and off quickly so that $ltimer = Dummy. This is helpful in case $ltimer gets stuck returning the name of your original timer, and wont turn off.