Count (Seconds)

By Aucun50 on Feb 14, 2009

It's a simple game that counts down (in seconds)

Commands are:
!countdown (number can't be over 500000) (id can be set)
!countstarted (id) (shows who started it what number it is counting down from and how much time has passed)
!viewcount (id) (shows what the countdown number is at)
!countstop (id) (stops the count only the person who started it can stop it, it shows who stopped it, what is was counting down from and how much time had passed)
!countpause (id) (pauses the countdown)
!countrestart (id) (starts the countdown again)
!viewid (id) (Status on the id)

on *:TEXT:*:#: {
  tokenize 32 $strip($1-)
  if ( %flood [ $+ [ $nick ] ] == $null ) {
    set -u4 %flood [ $+ [ $nick ] ] 1
    if (!countdown == $1) {
      if ($3) && ($3 >= 5) { goto count2 }
      if (!$2) { msg $chan Useage: !countdown (second), are you can set a Id to it Useage: !countdown (number) (Id) | halt }
      elseif ($2) && ($2 >= 500001) { msg $chan Sorry number is to big | halt }
      else { goto count }
      :count
      if (%count5) && (%count4) && (%count3) && (%count2) && (%count) && ($2) { msg $chan There is already 5 counts going | halt } 
      if (!%count) { .timer 1 2 set -z %count $2 | set %countp1.1 $2 | set %countp2.1 $nick | msg $chan It will now count down from $2 (Count Id 1) | halt }
      elseif (!%count2) { .timer 1 2 set -z %count2 $2 | set %countp1.2 $2 | set %countp2.2 $nick | msg $chan It will now count down from $2 (Count Id 2) | halt }
      elseif (!%count3) { .timer 1 2 set -z %count3 $2 | set %countp1.3 $2 | set %countp2.3 $nick | msg $chan It will now count down from $2 (Count Id 3) | halt }
      elseif (!%count4) { .timer 1 2 set -z %count4 $2 | set %countp1.4 $2 | set %countp2.4 $nick | msg $chan It will now count down from $2 (Count Id 4) | halt }
      elseif (!%count5) { .timer 1 2 set -z %count5 $2 | set %countp1.5 $2 | set %countp2.5 $nick | msg $chan It will now count down from $2 (Count Id 5) | halt }
      :count2
      if ($3 == 1) && (!%count) { .timer 1 2 set -z %count $2 | set %countp1.1 $2 | set %countp2.1 $nick | msg $chan It will now count down from $2 (Count Id 1) | halt }
      elseif ($3 == 2) && (!%count2) { .timer 1 2 set -z %count2 $2 | set %countp1.2 $2 | set %countp2.2 $nick | msg $chan It will now count down from $2 (Count Id 2) | halt }
      elseif ($3 == 3) && (!%count3) { .timer 1 2 set -z %count3 $2 | set %countp1.3 $2 | set %countp2.3 $nick | msg $chan It will now count down from $2 (Count Id 3) | halt }
      elseif ($3 == 4) && (!%count4) { .timer 1 2 set -z %count3 $2 | set %countp1.3 $2 | set %countp2.3 $nick | msg $chan It will now count down from $2 (Count Id 3) | halt }
      elseif ($3 == 5) && (!%count5) { .timer 1 2 set -z %count5 $2 | set %countp1.5 $2 | set %countp2.5 $nick | msg $chan It will now count down from $2 (Count Id 5) | halt }
      else { msg $chan Error Entering Infomation }
    }
    if (!viewcount == $1) {
      if (!$2) { msg $chan You need to type a count Id ranging from 1 to 5 | halt }
      if ($2 == 1) && (%count) { msg $chan $calc(%countp1.1 - %count) has gone by. Count has been running for $duration($calc(%countp1.1 - %count)) }
      elseif ($2 == 2) && (%count2) { msg $chan $calc(%countp1.2 - %count2) has gone by. Count has been running for $duration($calc(%countp1.2 - %count2)) }
      elseif ($2 == 3) && (%count3) { msg $chan $calc(%countp1.3 - %count3) has gone by. Count has been running for $duration($calc(%countp1.3 - %count3)) }
      elseif ($2 == 4) && (%count4) { msg $chan $calc(%countp1.4 - %count4) has gone by. Count has been running for $duration($calc(%countp1.4 - %count4)) }
      elseif ($2 == 5) && (%count5) { msg $chan $calc(%countp1.5 - %count5) has gone by. Count has been running for $duration($calc(%countp1.5 - %count5)) }
      elseif ($2 == 1) && (%count.pause1) { msg $chan That count has been stopped by %countp2.1 }
      elseif ($2 == 2) && (%count.pause2) { msg $chan That count has been stopped by %countp2.2 }
      elseif ($2 == 3) && (%count.pause3) { msg $chan That count has been stopped by %countp2.3 }
      elseif ($2 == 4) && (%count.pause4) { msg $chan That count has been stopped by %countp2.4 }
      elseif ($2 == 5) && (%count.pause5) { msg $chan That count has been stopped by %countp2.5 }
      else { msg $chan Count Id doesn't exist }
    }
    if (!countstarted == $1) {
      if (!$2) { msg $chan You need to type a count Id ranging from 1 to 5 | halt }
      if ($nick isop $chan) || ($nick == %countp2.1) && ($2 == 1) { msg $chan $calc(%countp1.1 - %count) has gone by. Count has been running for $duration($calc(%countp1.1 - %count)), Count stated by %countp2.1 it was set to countdown from %countp1.1 }
      elseif ($nick isop $chan) || ($nick == %countp2.2) && ($2 == 2) { msg $chan $calc(%countp1.2 - %count2) has gone by. Count has been running for $duration($calc(%countp1.2 - %count2)), Count stated by %countp2.2 it was set to countdown from %countp1.2 }
      elseif ($nick isop $chan) || ($nick == %countp2.3) && ($2 == 3) { msg $chan $calc(%countp1.3 - %count3) has gone by. Count has been running for $duration($calc(%countp1.3 - %count3)), Count stated by %countp2.3 it was set to countdown from %countp1.3 }
      elseif ($nick isop $chan) || ($nick == %countp2.4) && ($2 == 4) { msg $chan $calc(%countp1.4 - %count4) has gone by. Count has been running for $duration($calc(%countp1.4 - %count4)), Count stated by %countp2.4 it was set to countdown from %countp1.4 }
      elseif ($nick isop $chan) || ($nick == %countp2.5) && ($2 == 5) { msg $chan $calc(%countp1.5 - %count5) has gone by. Count has been running for $duration($calc(%countp1.5 - %count5)), Count stated by %countp2.5 it was set to countdown from %countp1.5 }
      else { msg $chan Count Id doesn't exist }
    }
    if (!countstop == $1) {
      if (!$2) { msg $chan No count Id typed | halt }
      if ($nick isop $chan) || ($nick == %countp2.1) && ($2 == 1) && (%count) { unset %count %countp1.1 %countp2.1 | msg $chan $nick stopped the count number 1 }       
      elseif ($nick isop $chan) || ($nick == %countp2.2) && ($2 == 2) && (%count2) { unset %count2 %countp1.2 %countp2.2 | msg $chan $nick stopped the count number 2 }
      elseif ($nick isop $chan) || ($nick == %countp2.3) && ($2 == 3) && (%count3) { unset %count3 %countp1.3 %countp2.3 | msg $chan $nick stopped the count number 3 }
      elseif ($nick isop $chan) || ($nick == %countp2.4) && ($2 == 4) && (%count4) { unset %count4 %countp1.4 %countp2.4 | msg $chan $nick stopped the count number 4 }
      elseif ($nick isop $chan) || ($nick == %countp2.5) && ($2 == 5) && (%count5) { unset %count5 %countp1.5 %countp2.5 | msg $chan $nick stopped the count number 5 }
      else { msg $chan Count Id doesn't exist }
    }
    if (!countpause == $1) {
      if (!$2) { msg $chan No count Id typed | halt }
      if ($nick isop $chan) || ($nick == %countp2.1) && ($2 == 1) && (%count) { set %count.pause1 $calc(%countp1.1 - %count) | unset %count | msg $chan Count 1 was paused by $nick }
      elseif ($nick isop $chan) || ($nick == %countp2.2) && ($2 == 2) && (%count2) { set %count.pause2 $calc(%countp1.2 - %count2) | unset %count2 | msg $chan Count 2 was paused by $nick }
      elseif ($nick isop $chan) || ($nick == %countp2.3) && ($2 == 3) && (%count3) { set %count.pause3 $calc(%countp1.3 - %count3) | unset %count3 | msg $chan Count 3 was paused by $nick }
      elseif ($nick isop $chan) || ($nick == %countp2.4) && ($2 == 4) && (%count4) { set %count.pause4 $calc(%countp1.4 - %count4) | unset %count4 | msg $chan Count 4 was paused by $nick }
      elseif ($nick isop $chan) || ($nick == %countp2.5) && ($2 == 5) && (%count5) { set %count.pause5 $calc(%countp1.5 - %count5) | unset %count5 | msg $chan Count 5 was paused by $nick }
      else { msg $chan Count Id doesn't exist }
    }
    if (!countrestart == $1) {
      if (!$2) { msg $chan No count Id typed | halt }
      if ($nick isop $chan) || ($nick == %countp2.1) && ($2 == 1) && (%count.pause1) { set -z %count %count.pause1 | unset %count.pause1 | msg $chan Count 1 restarted by $nick }
      elseif ($nick isop $chan) || ($nick == %countp2.2) && ($2 == 2) && (%count.pause2) { set -z %count %count.pause2 | unset %count.pause2 | msg $chan Count 2 restarted by $nick } 
      elseif ($nick isop $chan) || ($nick == %countp2.3) && ($2 == 3) && (%count.pause3) { set -z %count %count.pause3 | unset %count.pause3 | msg $chan Count 3 restarted by $nick }
      elseif ($nick isop $chan) || ($nick == %countp2.4) && ($2 == 4) && (%count.pause4) { set -z %count %count.pause4 | unset %count.pause4 | msg $chan Count 4 restarted by $nick }
      elseif ($nick isop $chan) || ($nick == %countp2.5) && ($2 == 5) && (%count.pause5) { set -z %count %count.pause5 | unset %count.pause5 | msg $chan Count 5 restarted by $nick }
      else { msg $chan Count Id doesn't exist }
    }
    if (!viewid == $1) {
      if ($2 == 1) && (%count) { msg $chan Id in use }
      elseif ($2 == 2) && (%count2) { msg $chan Id in use }
      elseif ($2 == 3) && (%count3) { msg $chan Id in use }
      elseif ($2 == 4) && (%count4) { msg $chan Id in use }
      elseif ($2 == 5) && (%count5) { msg $chan Id in use }
      else { msg $chan Id not in use }
    }
  }
}

Comments

Sign in to comment.
cptpan   -  Sep 24, 2012

What the fuck? I can't get this working right at all. Is it just too old?

 Respond  
Aucun50   -  Mar 20, 2009

Updated fixed a little error

 Respond  
Tamaki   -  Feb 27, 2009

"Am I to understand that this means that you are not a good script writer if you don't use /elseif ?"

That means that elseif looks neater then else in my opinion less lines.

ok ^_^ thanks for the clarification!

nice script btw

 Respond  
Kirby   -  Feb 27, 2009

We all have different scripting habits/methods.

 Respond  
Aucun50   -  Feb 27, 2009

"Am I to understand that this means that you are not a good script writer if you don't use /elseif ?"

That means that elseif looks neater then else in my opinion less lines.

 Respond  
Tamaki   -  Feb 27, 2009

very nice, your coding is coming along nicely, keeptin it neat using elseif's etc.
gd work m8

Am I to understand that this means that you are not a good script writer if you don't use /elseif ? The reason i use Else { then /if is that it makes it easier for me to see and understand. (I'm not nagging or complaining or trying to start anything) I just like to code that way. ^_^

 Respond  
Aucun50   -  Feb 19, 2009

Thanks for explaining that Zmodem

 Respond  
Zmodem   -  Feb 19, 2009

No, the %var is faster. The main reason is because instead of having to reference $[N/I] over and over, and mIRC re-calculates it everytime, static %variables never change and are in your code, itself, rather than referencing back to parsing out the identifiers through calculations.

However, if you're seeing no lag, I wouldn't see the need, so awesome! :)

 Respond  
Aucun50   -  Feb 18, 2009

Always thought $1 was faster then have it read from the var. The script running with 0% lag for me.

 Respond  
Zmodem   -  Feb 18, 2009

Just a quick hint: You can DRASTICALLY improve speed in the event by setting a variable to common used identifiers that don't require dynamic-values. ie: $chan will always be $chan, as well as $1 and $2.

At the beginning of the event, try setting a temporary variable to the commonly used identifiers. ie:

var %1 = $1, %2 = $2, %3 = $3, %c = $chan
 Respond  
Aucun50   -  Feb 18, 2009

Updated to use 5 counts at a time, op's can stop any count

 Respond  
RusselB   -  Feb 18, 2009

While usage of the halt statement will prevent the extra processing of the if statements that follow the if statement that matches, Aucun's usage of if/elseif is not completely misused, however, I admit, it could be better coded.

As I have stated before, the only way to tell for sure which is faster, is to time test each of the codes, ensuring that the timing was set and relayed from the same general locations in both scripts... Ideally the timings should be done between exactly the same locations, however, due to the difference in the number of ON TEXT events in the two scripts, this is not possible.\

 Respond  
Korvin   -  Feb 18, 2009

truth be told i believe that mine would be faster, but only by a miniscule amount, and you completely misuse the elseifs, also my ifs wouldnt slow it down.

i believe this on account ofmy halts, it doesnt have to check every if, as yours does.

 Respond  
RusselB   -  Feb 18, 2009

The $gettok is necessary for all of the modifications to be accurate.
You're right, however, about having to process multiple if's rather than if/elseif/else being slower.
As to the actual overall speed, it's difficult to say if Korvin's corrected code would be faster or slower than your original code, Aucun50, due to the fact that your code uses multiple ON TEXT events, which, in reality, do a built in if (the event has to check if the matchtext section matches the entry or not).
Additionally, a true speed test would have to be checked between the same two points in the two scripts, which is difficult to do, based on the fact that one uses a single event, and the other multiple events.

 Respond  
Aucun50   -  Feb 18, 2009

Don't have to test the speed i can tell by the unnecessary $gettok in there and all the if's and no elseif (Witch are faster)

 Respond  
Korvin   -  Feb 18, 2009

youre right =p i edited in notepad

ty fixed..

also this means that there was no way aucun couldve tested the speed.

 Respond  
RusselB   -  Feb 17, 2009

I don't know about speed, but the $gettok items in your code, Korvin, are missing parameters that should be included. Specifically the parameter that identifies the token separator.

 Respond  
Korvin   -  Feb 17, 2009

slower? for what reason?

 Respond  
Aucun50   -  Feb 17, 2009

Besides the fact the your script is alot slower then mine its ok, and i like my style better :)

 Respond  
Korvin   -  Feb 17, 2009

i really hate your style =/ soooooo i decided to edit your code in my style. look over it.

on *:TEXT:*:#: {
  tokenize 32 $strip($1-)
  var %w = !countdown,!viewcount,!countstarted,!countstop,!countpause,!countrestart
  if ( %flood $+ $nick == $null ) {
    set -u2 %flood $+ $nick 1
    if ($1 == $gettok(%w,1,44)) {
      if (%count) { msg $chan There is a game going already | halt }
      if ($2 >= 100001) { msg $chan Sorry number is to big | halt }
      if (!$2) { msg $chan Usage: !countdown (second) | halt }
      set -z %count $2 | msg $chan It will now count down from $2, to view it type !viewcount | set %count2 $2 | set %count3 $nick 
    }
    if (!%count) {
      if ($1 == $gettok(%w,1,44)) {
        if ($v1 = 1) { msg $chan Countdown is now over from %count2 | unset %count2 | unset %count3 | halt }
        msg $chan %count | var %t $calc(%count2 - %count) | var %t2 $duration(%t) | msg $chan I have been running for %t2 
      }
      if ($1 == $gettok(%w,1,44)) {
        msg $chan The count was set to %count2 and $calc(%count2 - %count) seconds has gone by so far, the count was started by %count3 | var %t $calc(%count2 - %count) | var %t2 $duration(%t) | msg $chan Count can be stopped by %count3 with !stopcount, i have been running for %t2 
      }
      if ($1 == $gettok(%w,1,44)) {
        if ($nick !== %count3) { msg $chan You didn't start the count  | halt }
        msg $chan Count stopped by $nick it was set to %count2 and $calc(%count2 - %count) seconds had passed | unset %count %count2 %count3 %countpause
      }
      if ($1 == $gettok(%w,1,44)) {
        if ($nick !== %count3) { msg $chan You didn't start the count | halt }
        set %countpause %count | msg $chan Count is now paused, to start is again tpye !countrestart | unset %count
      }
      if ($1 == $gettok(%w,1,44)) {
        if (%countpause) {
          if ($nick !== %count3) { msg $chan You didn't pause or start the count | halt }
          msg $chan Count started after stop | set -z %count %countpause
          halt
        }
        msg $chan The count was never paused
      }
    }
    msg $chan No countdown started 
  }
}
 Respond  
Aucun50   -  Feb 17, 2009

Thank you russelB, the reason i set 100000 to max is because if it's to high of a number it wont count down right, I'll add some more features to it as you suggested.

 Respond  
RusselB   -  Feb 17, 2009

What reason, if any, did you pick a maximum time of 100000 seconds (aka 1day 3hrs 46mins 40secs)?
Suggestions for improvements:
1) Allowing multiple timers to run.
2) Make game multi-channel and multi-network ready.
3) Allow channel op to be able to stop the game if the person that started it leaves the room for any reason. Especially if the person is kicked and/or banned.
4) Change your unset line to read unset %count* (noting as how all of your variables start with %count)

All in all, a nice idea, and good scripting. 7/10 from me.

 Respond  
PuNkTuReD   -  Feb 15, 2009

very nice, your coding is coming along nicely, keeptin it neat using elseif's etc.
gd work m8

 Respond  
Kirby   -  Feb 15, 2009

Yeah, I like the idea.

 Respond  
Aucun50   -  Feb 14, 2009

Yea it was late :) do you like the idea tho?

 Respond  
Kirby   -  Feb 14, 2009
      elseif (!%count) { msg No count started }

should be

      elseif (!%count) { msg $chan No count started }

and

      if (%count) && ($nick !== %count3) { msg You didn't start the count }

should be

      if (%count) && ($nick !== %count3) { msg $chan You didn't start the count }

right?

 Respond  
Aucun50   -  Feb 14, 2009

Updated, it can now show time it has been running.

 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.