Simple Countdown Script

Published  Jul 06, 2011
Updated  Jul 07, 2011
0  9

Description

Normal !countdown irc script.

on *:text:!countdown*:#: {
  if ($2 = 5) {
}
    msg $chan 1,9Countdown started !
    timer 1 1 msg $chan 5
    timer 1 2 msg $chan 4
    timer 1 3 msg $chan 3
    timer 1 4 msg $chan 2
    timer 1 5 msg $chan 1
    timer 1 6 msg $chan Go !
  }
  else {
    if ($2 > 5) {
      msg $chan 1,12Sorry 13,12 $nick , 8,12but max countdown number for me is 5 !
    }
  }

or :

on $*TEXT:/^[!.]countdown/Si:#:{
  if (!$2) { notice $nick Please provide the time in seconds you want to count down from! | halt }

  elseif (%countdown [ $+ [ $nick ] ]) { notice $nick You still have a timer running! | halt }

  elseif ($2 > 5 || $2 < 1) { notice $nick I cant countdown from lower then 1 or higher then 5! You entered $2 wich isnt correct! | halt }

  else { notice $nick Started counting down from $2. | set $+(-u,$2) %countdown [ $+ [ $nick ] ] $true | .timer $+(countdown,$nick) $2 notice $nick The timer stopped after counting down from $2 $+ . | halt }

halt
}

Comments

Sign in to comment.
Bielie   -  Jul 07, 2011

I want to learn while looping :P I just cant take my head to it :(

 Respond  
napa182   -  Jul 06, 2011

nice different take on it jaytea
only thing is you forgot the Go! after it hits 1

 Respond  
jaytea   -  Jul 06, 2011

let's toss another method into the mix:

on *:text:!countdown &:#:{
  if ($2 isnum 1-10) && (!$timer(count)) {
    .timercount $2 1 msg # $!calc($timer(count).reps + 1)
  }
}
 Respond  
napa182   -  Jul 06, 2011

um TochA1551 you are missing a closing bracket.
Here is 4 different versions of it.

these are working examples only:

This one the trigger is !countdown <number 1-10>
you can do a countdown from any numbers from 1-10
Ex:

<~napa182> !countdown 4
<&Masonic> Countdown started!
<&Masonic> 4
<&Masonic> 3
<&Masonic> 2
<&Masonic> 1
<&Masonic> Go!

on $*:text:/^!countdown\s(\d+)$/iS:#: {
  if (!%count && $regml(1) isnum 1-10) { inc -u10 %count
    msg # 1,9Countdown started!
    var %a = $v1, %b = 1
    while (%a >= 0) {
      $+(.,timerc,%b) 1 %b msg # $iif(%a = 0,Go!,%a)
      dec %a
      inc %b
    }
  }
}

Second one is almost like the one the author posted without the error messages. It counts down from 5.
Trigger is !countdown
Ex:

<~napa182> !countdown
<&Masonic> Countdown started!
<&Masonic> 5
<&Masonic> 4
<&Masonic> 3
<&Masonic> 2
<&Masonic> 1
<&Masonic> Go!

on $*:text:/^!countdown$/iS:#: {
  if (!%count) { inc -u10 %count
    msg # 1,9Countdown started!
    var %a = 5, %b = 1
    while (%a >= 0) {
      $+(.,timerc,%b) 1 %b msg # $iif(%a = 0,Go!,%a)
      dec %a
      inc %b
    }
  }
}

This one is like the one the author posted with the error messages
Trigger is !countdown 5
Ex:

<~napa182> !countdown 4
<&Masonic> Sorry napa182, but max countdown number for me is 5!

<~napa182> !countdown
<&Masonic> Sorry napa182, but you need to type !countdown 5

<~napa182> !countdown 99
<&Masonic> Sorry napa182, but max countdown number for me is 5!

<~napa182> !countdown 5
<&Masonic> Countdown started!
<&Masonic> 5
<&Masonic> 4
<&Masonic> 3
<&Masonic> 2
<&Masonic> 1
<&Masonic> Go!

on $*:text:/^!countdown?\s?(\d+)?$/iS:#: {
  if (!%count) { inc -u10 %count
    if ($regml(1) != 5 || !$regml(1)) { 
      msg # 1,12Sorry 13,12 $nick $+ , 8,12but $iif(!$regml(1),$&
        you need to type !countdown 5,max countdown number for me is 5!)
    }
    else {
      msg # 1,9Countdown started!
      var %a = 5, %b = 1
      while (%a >= 0) {
        $+(.,timerc,%b) 1 %b msg # $iif(%a = 0,Go!,%a)
        dec %a
        inc %b
      }
    }
  }
}

The last one is a version that has 2 different triggers:
Also you can do a countdown from any numbers from 1-10

!countdown <number 1-10> will message the channel
@countdown <number 1-10> will notice the nick

Ex:

<~napa182> @countdown 3
-Masonic- Countdown started!
-Masonic- 3
-Masonic- 2
-Masonic- 1
-Masonic- Go!

<~napa182> !countdown 4
<&Masonic> Countdown started!
<&Masonic> 4
<&Masonic> 3
<&Masonic> 2
<&Masonic> 1
<&Masonic> Go!

on $*:text:/^([!@])countdown\s(\d+)$/iS:#: {
  if (!%count && $regml(2) isnum 1-10) { inc -u10 %count
    var %a = $v1, %b = 1, %c = $iif($regml(1) = !,.msg #,.notice $nick)
    %c 1,9Countdown started!
    while (%a >= 0) {
      $+(.,timerc,%b) 1 %b %c $iif(%a = 0,Go!,%a)
      dec %a
      inc %b
    }
  }
}

Yes I was bored...

Keep at it....

 Respond  
KilllerX   -  Jul 06, 2011

Wouldn't you be able to make an alias as such

Alias countdown {

umm I am not good at this. but do something like

.timercalc 1 1 .set %timer. [ $+[ $nick ] ] $calc( $+ $2 - 1) | .timercalcr .read %timer. [ $+[ $nick ] ]
.timercalc 1 2 .set %timer. [ $+[ $nick ] ] $calc( $+ %timer. [ $+[ $nick ] ] - 1) | .timercalcr .read %timer. [ $+[ $nick ] ]
}

So on... Now don't count me on this. but what I see it doing is a basic countdown. If you use the $2 as the begining number then have it write the number it equals as a file number. then have it read it. take it away count it down. wouldn't that work also?

 Respond  
Bielie   -  Jul 06, 2011

Uhm i know from experience that 50/50 use . or !

About the halts. Idk why i do it its kind of my bug :P I keep hearing it but it then ruin anything though :P

 Respond  
napa182   -  Jul 06, 2011

@TochA1551 you should have posted this as a snippet rather than a script. also maybe name an silence your timers.
and to Bielie why all the halts? and why the 2 diff triggers ie:" ! . "? just use 1 if you are not going to use 1 for message an the other for notice.

 Respond  
Bielie   -  Jul 06, 2011

This script has multiple things that wont work. You have to remove

You couldv used something much simpler with the same effect:


on $*TEXT:/^[!.]countdown$/Si:#:{
 if (%flood [ $+ [ $nick ] ]) { halt }
 set -u2 %flood [ $+ [ $nick ] ] $true

 if (%flood2 [ $+ [ $chan ] ]) { notice $nick Please wait 10seconds before counting down again! | halt }
 set -u10 %flood2 [ $+ [ $chan ] ] $true

 msg $chan Countdown Started!
 timer 1 1 msg $chan 5
 timer 1 2 msg $chan 4
 timer 1 3 msg $chan 3
 timer 1 4 msg $chan 2
 timer 1 5 msg $chan 1
 timer 1 6 msg $chan Go! | halt }
}

This is simple msl code but it will work better and safer then urs. I recommend using $chan for scripts that use multiple timers. Timers will cause spam and no one likes that. Unless its for fun ;D

Next time post your code in the Code section of your post.

The if ($2 > 5) { is unecesary since the script doesnt care what you type in the $2 section. It will just always count down from 5 to 0.

What you are trying to do looks like this:

on $*TEXT:/^[!.]countdown/Si:#:{
  if (!$2) { notice $nick Please provide the time in seconds you want to count down from! | halt }

  elseif (%countdown [ $+ [ $nick ] ]) { notice $nick You still have a timer running! | halt }

  elseif ($2 > 5 || $2 < 1) { notice $nick I cant countdown from lower then 1 or higher then 5! You entered $2 wich isnt correct! | halt }

  else { notice $nick Started counting down from $2. | set $+(-u,$2) %countdown [ $+ [ $nick ] ] $true | .timer $+(countdown,$nick) $2 notice $nick The timer stopped after counting down from $2 $+ . | halt }

halt
}
 Respond  
irchainscriptz   -  Jul 06, 2011

you can use the

for your snippet, makes it look better and easier to read.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.