Top

Count (Seconds)


mIRC Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  6.5 (of 2 scores)
Date Added  Feb 14, 2009
Last Updated  Mar 20, 2009
Tags  countdown 

Introduction

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)

Grab the Code

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

  (26)  RSS
Aucun50
Comments: 567
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 14, 2009 7:03 pm
Updated, it can now show time it has been running.
Kirby
Comments: 474
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 14, 2009 8:22 pm
Code:
      elseif (!%count) { msg No count started }
should be
Code:
      elseif (!%count) { msg $chan No count started }

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

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

right?
Aucun50
Comments: 567
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 14, 2009 9:26 pm
Yea it was late :) do you like the idea tho?
Kirby
Comments: 474
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 15, 2009 9:25 am
Yeah, I like the idea.
PunkTuReD
Comments: 480
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 15, 2009 9:24 pm
very nice, your coding is coming along nicely, keeptin it neat using elseif's etc.
gd work m8
RusselB
Comments: 162
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 17, 2009 9:59 pm
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.
Aucun50
Comments: 567
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 17, 2009 10:15 pm
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.
Korvin
Comments: 338
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 17, 2009 10:20 pm
i really hate your style =/ soooooo i decided to edit your code in my style. look over it.
Code:
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
  }
}
Aucun50
Comments: 567
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 17, 2009 10:58 pm
Besides the fact the your script is alot slower then mine its ok, and i like my style better :)
Korvin
Comments: 338
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 17, 2009 11:09 pm
slower? for what reason?
RusselB
Comments: 162
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 17, 2009 11:27 pm
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.
Korvin
Comments: 338
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 18, 2009 12:02 am
youre right =p i edited in notepad

ty fixed..


also this means that there was no way aucun couldve tested the speed.
Aucun50
Comments: 567
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 18, 2009 12:07 am
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)
RusselB
Comments: 162
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 18, 2009 12:50 am
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.
Korvin
Comments: 338
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 18, 2009 1:00 am
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.
RusselB
Comments: 162
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 18, 2009 2:48 am
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.\
Aucun50
Comments: 567
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 18, 2009 4:05 pm
Updated to use 5 counts at a time, op's can stop any count
Zmodem
Comments: 306
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 18, 2009 6:07 pm
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:

Code:
var %1 = $1, %2 = $2, %3 = $3, %c = $chan
Aucun50
Comments: 567
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 18, 2009 6:27 pm
Always thought $1 was faster then have it read from the var. The script running with 0% lag for me.
Zmodem
Comments: 306
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 19, 2009 12:04 pm
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! :)
Aucun50
Comments: 567
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 19, 2009 12:44 pm
Thanks for explaining that Zmodem
The_Almighty_Duelist
Comments: 86
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 27, 2009 8:08 am
Quote:
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. ^_^
Aucun50
Comments: 567
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 27, 2009 8:15 am
"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.
Kirby
Comments: 474
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 27, 2009 8:46 am
We all have different scripting habits/methods.
The_Almighty_Duelist
Comments: 86
 
mIRC Snippet:  Count (Seconds)
Posted on Feb 27, 2009 9:02 am
Quote:
"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
Aucun50
Comments: 567
 
mIRC Snippet:  Count (Seconds)
Posted on Mar 20, 2009 8:21 am
Updated fixed a little error

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  

Bottom