mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2015
Posts: 2
P
Bowl of petunias
OP Offline
Bowl of petunias
P
Joined: Mar 2015
Posts: 2
I am very new to MIRC and have been searching a while for a countdown timer.
i found this script:

on *:text:!countdown*:#: {
if ($2 = 5) {
}
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 !
}
else {
if ($2 > 5) {
msg $chan 1,12Sorry 13,12 $nick , 8,12but max countdown number for me is 5 !
}
}


This adds a countdown command. I want to repeat this countdown command say every 120 seconds. What needs to be added to this scrit? or is there something else i need to do? Please bare in mind im a complete n00b to all of this so any help will be very very greatfull. Will be using the command on my twitch channel.

Joined: Sep 2011
Posts: 32
F
Ameglian cow
Offline
Ameglian cow
F
Joined: Sep 2011
Posts: 32
Originally Posted By: perfectshots
I am very new to MIRC and have been searching a while for a countdown timer.
i found this script:

on *:text:!countdown*:#: {
if ($2 = 5) {
}
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 !
}
else {
if ($2 > 5) {
msg $chan 1,12Sorry 13,12 $nick , 8,12but max countdown number for me is 5 !
}
}


This adds a countdown command. I want to repeat this countdown command say every 120 seconds. What needs to be added to this scrit? or is there something else i need to do? Please bare in mind im a complete n00b to all of this so any help will be very very greatfull. Will be using the command on my twitch channel.


First, I think there's a bug in the code; you've got braces in the wrong place.

Second, turn the actual countdown code into an alias, and use the ON TEXT trigger to invoke the alias. You want your alias to just do the countdown; your trigger should invoke the alias, possibly via a timer if you want to issue the countdown command once and still have it repeat at regular intervals.

I'm not going to go into more detail, to encourage you to go really read the help file. It's really pretty straightforward.

Joined: Mar 2015
Posts: 2
P
Bowl of petunias
OP Offline
Bowl of petunias
P
Joined: Mar 2015
Posts: 2
I guess i must be thick, I spent three hours last night reading the help file and trying different things. I found a countdown alias previously, i tried that and i got it repeating on a timer but then for some reason it wouldn't send it to my chat on twitch even though everything else would send that i typed. Am i missing a channel command or something that will make it visable on twitch. (yes i was connected to twitch correctly and other stuff i sent through the bot displayed perfectly.)

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
You need to pass the channel name as a parameter

on *:text:!countdown*:#: { countdown # }

alias countdown { msg $1 Bøf }

Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Code:
on *:text:*:#: {
  if ($1 == !countdown) {
    if ($2 <= 5) {
      var %x = 1
      var %y = $2
      while (%x <= $2) {
        .timer 1  %y msg $chan %x
        if (%x == $2) { .timer 1 $calc(%x + 1) msg $chan GO!!!! }
        inc %x
        dec %y
      }
    }
    elseif ($2 > 5) {
      msg $chan 1,12Sorry 13,12 $nick , 8,12but max countdown number for me is 5 !
    }
  }
}


i tested this! and it works!!
Your Original Script Had Some Wrongs Closing Brackets.
Code:
on *:text:!countdown*:#: {
if ($2 = 5) {
}
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 !
}
;;Basically the on text event ends here because you have close the: if ($2 = 5) { right below it's self. Not big deal .. i have made worse mistakes :D

The Little Difference Between What I wrote Is that you can have a countdown from 5 or lower
e.g:
Quote:

|17:05:41| OrFeAsGr › !countdown 5
|17:05:42|  Athens › 5
|17:05:43|  Athens › 4
|17:05:45|  Athens › 3
|17:05:45|  Athens › 2
|17:05:47|  Athens › 1
|17:05:48|  Athens › GO!!!!

or
Quote:

|17:05:57|  OrFeAsGr › !countdown 3
|17:05:59|  Athens › 3
|17:06:00|  Athens › 2
|17:06:01|  Athens › 1
|17:06:02|  Athens › GO!!!!

I Hope I Helped! Good Luck smile
-OrFeAsGr-

Joined: May 2022
Posts: 78
F
Babel fish
Offline
Babel fish
F
Joined: May 2022
Posts: 78
Originally Posted by OrFeAsGr
Code
on *:text:*:#: {
  if ($1 == !countdown) {
    if ($2 <= 5) {
      var %x = 1
      var %y = $2
      while (%x <= $2) {
        .timer 1  %y msg $chan %x
        if (%x == $2) { .timer 1 $calc(%x + 1) msg $chan GO!!!! }
        inc %x
        dec %y
      }
    }
    elseif ($2 > 5) {
      msg $chan 1,12Sorry 13,12 $nick , 8,12but max countdown number for me is 5 !
    }
  }
}

i tested this! and it works!!
Your Original Script Had Some Wrongs Closing Brackets.
Code
on *:text:!countdown*:#: {
if ($2 = 5) {
}
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 !
}
;;Basically the on text event ends here because you have close the: if ($2 = 5) { right below it's self. Not big deal .. i have made worse mistakes :D
The Little Difference Between What I wrote Is that you can have a countdown from 5 or lower
e.g:
Quote
|17:05:41| OrFeAsGr !countdown 5
|17:05:42|  Athens 5
|17:05:43|  Athens 4
|17:05:45|  Athens 3
|17:05:45|  Athens 2
|17:05:47|  Athens 1
|17:05:48|  Athens GO!!!!
or
Quote
|17:05:57|  OrFeAsGr !countdown 3
|17:05:59|  Athens 3
|17:06:00|  Athens 2
|17:06:01|  Athens 1
|17:06:02|  Athens GO!!!!
I Hope I Helped! Good Luck smile
-OrFeAsGr-

Doesn't work to me on mirc 6.35

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Yes. Yes it does work in 6.35 - It doesn't work correctly, but it does work.
Whenever you report a problem with a script, it helps if you described what's the problem. Does it not do anything at all, or does it do the wrong thing, or does it generate errors in the status window, etc

Oh, and most of all, please tell us what we're supposed to do to make the script work, so we don't have to read the entire thread or analyze a script to figure it out.

First of all, you may want to consider upgrading your v6.35, since there have been many bug fixes and new features added since then. If you click on the "news" link at the top of this page, there's a link to the versions.txt that lists most but not all of the changes between versions, with the newer changes at the top. That is a huge file, and your v6.35 is mentioned on row 3160, so you can see there's been a lot of changes since then.

One of the most important changes was a fix that prevents irc:// chat links at a webpage from launching your mirc.exe using a mirc.ini and scripts that are located on someone else's webpage, and you can imagine what would happen then. You should immediately go to options/irc/catcher and uncheck the box below "chat links" that is labeled "enable support". I'm not saying this eliminates the risk, but it can't hurt. But also, the chat links support is enabled by default, so if your mirc.ini gets destroyed during a computer crash, it gets restored with default settings, and that can cause chat links to be enabled before you realize it happened.

If your reason for using 6.35 is that you use an irc server that does not support the UTF8 encoding, the newer mIRC has an option to disable that and use the old codepages instead. If you have another script that works on the old version and won't work on the newer one, come by #mircscripting on SwiftIRC or Undernet servers, or #mirc on Libera.Chat EFnet etc, and there may be someone who can help fix the script so it can work with newer versions.

- -

First thing to check when a script does not work: go to the options menu of script editor and make sure that "identifier warning" is enabled. It is disabled by default, and if you make a spelling error in a script that makes it call $identifier_that_does_not_exist then this setting creates an error message and stops the script, so you can be alerted for the need to fix the script. Without the option checkboxed, the identifier returns a blank string, which can cause a script to mis-behave when the identifier should always return *something*.

Next, make sure you do not have another ON TEXT event handler in that same script file on a row above it that would intercept message instead of this script.

When I run this code in 6.35, it works mostly correctly, with the only problem being that sometimes one of the countdown numbers is delayed by 1 second and shows out of order. So it would show "5", and then 2 seconds later it would show "3" then "4" then continue the countdown. I even had the "Go" display before the "1".

This problem with the timer does not exist in the newer mIRC, and would require redesigning your script completely to evade the bug when it runs in 6.35

Because this sends out 5 messages so quickly, it's possible that your anti-flood settings can delay some of these countdown messages, which is something that cannot be eliminated.

Also, your script cannot tell the difference between "!countdown 6.5" and "!countdown abc". If they use "!countdown 4.5", it counts down from 4, but never shows the "GO"

So come on by one of the help channels and see if there's someone that can help you with getting setup in one of the newer versions.

Joined: May 2022
Posts: 78
F
Babel fish
Offline
Babel fish
F
Joined: May 2022
Posts: 78
Originally Posted by maroon
Yes. Yes it does work in 6.35 - It doesn't work correctly, but it does work.
Whenever you report a problem with a script, it helps if you described what's the problem. Does it not do anything at all, or does it do the wrong thing, or does it generate errors in the status window, etc

Oh, and most of all, please tell us what we're supposed to do to make the script work, so we don't have to read the entire thread or analyze a script to figure it out.

First of all, you may want to consider upgrading your v6.35, since there have been many bug fixes and new features added since then. If you click on the "news" link at the top of this page, there's a link to the versions.txt that lists most but not all of the changes between versions, with the newer changes at the top. That is a huge file, and your v6.35 is mentioned on row 3160, so you can see there's been a lot of changes since then.

One of the most important changes was a fix that prevents irc:// chat links at a webpage from launching your mirc.exe using a mirc.ini and scripts that are located on someone else's webpage, and you can imagine what would happen then. You should immediately go to options/irc/catcher and uncheck the box below "chat links" that is labeled "enable support". I'm not saying this eliminates the risk, but it can't hurt. But also, the chat links support is enabled by default, so if your mirc.ini gets destroyed during a computer crash, it gets restored with default settings, and that can cause chat links to be enabled before you realize it happened.

If your reason for using 6.35 is that you use an irc server that does not support the UTF8 encoding, the newer mIRC has an option to disable that and use the old codepages instead. If you have another script that works on the old version and won't work on the newer one, come by #mircscripting on SwiftIRC or Undernet servers, or #mirc on Libera.Chat EFnet etc, and there may be someone who can help fix the script so it can work with newer versions.

- -

First thing to check when a script does not work: go to the options menu of script editor and make sure that "identifier warning" is enabled. It is disabled by default, and if you make a spelling error in a script that makes it call $identifier_that_does_not_exist then this setting creates an error message and stops the script, so you can be alerted for the need to fix the script. Without the option checkboxed, the identifier returns a blank string, which can cause a script to mis-behave when the identifier should always return *something*.

Next, make sure you do not have another ON TEXT event handler in that same script file on a row above it that would intercept message instead of this script.

When I run this code in 6.35, it works mostly correctly, with the only problem being that sometimes one of the countdown numbers is delayed by 1 second and shows out of order. So it would show "5", and then 2 seconds later it would show "3" then "4" then continue the countdown. I even had the "Go" display before the "1".

This problem with the timer does not exist in the newer mIRC, and would require redesigning your script completely to evade the bug when it runs in 6.35

Because this sends out 5 messages so quickly, it's possible that your anti-flood settings can delay some of these countdown messages, which is something that cannot be eliminated.

Also, your script cannot tell the difference between "!countdown 6.5" and "!countdown abc". If they use "!countdown 4.5", it counts down from 4, but never shows the "GO"

So come on by one of the help channels and see if there's someone that can help you with getting setup in one of the newer versions.

Thanks for kind reply sir.
I created a new file called "timer.mrc", and I copied Your code
Of course I loaded it.
Then I tried to write !countdown 5 and nothing happened at all. No error messages nore in status window. Simply doesn't work.
I tested it also on 7.65
All warning messages on editor are active.
Thanks again

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
First, you say this is my code. It is not my code, as I would have coded it completely differently.
Now you add additional information which would have solved the problem after the first message.
It looks like you are saying that you are typing the countdown trigger into the same mirc that had this script loaded. The ON TEXT event is for incoming text, not for your own text.
You will need to have 2 nicks to test this. If the script is loaded into the mirc for nick1, then nick2 will need to type the countdown trigger.

If you MUST test it with 1 mirc, then you must change the first line of the script where it has
on *:text:*:#: {
and change to
on *:text:*:?: {

which makes it respond only in a query window instead of in a channel. Then you can query yourself like
//query $me
... while you are on a network, and then the incoming message will trigger the ON TEXT handler

But then be sure to change the :?: back to :#: so it sees the channel messages again. If you want this to respond only to countdown in 1 channel, then you should change the :#: into the actual channelname such as :#fernet:

Joined: May 2022
Posts: 78
F
Babel fish
Offline
Babel fish
F
Joined: May 2022
Posts: 78
Originally Posted by maroon
First, you say this is my code. It is not my code, as I would have coded it completely differently.
Now you add additional information which would have solved the problem after the first message.
It looks like you are saying that you are typing the countdown trigger into the same mirc that had this script loaded. The ON TEXT event is for incoming text, not for your own text.
You will need to have 2 nicks to test this. If the script is loaded into the mirc for nick1, then nick2 will need to type the countdown trigger.

If you MUST test it with 1 mirc, then you must change the first line of the script where it has
on *:text:*:#: {
and change to
on *:text:*:?: {

which makes it respond only in a query window instead of in a channel. Then you can query yourself like
//query $me
... while you are on a network, and then the incoming message will trigger the ON TEXT handler

But then be sure to change the :?: back to :#: so it sees the channel messages again. If you want this to respond only to countdown in 1 channel, then you should change the :#: into the actual channelname such as :#fernet:

Thanks sir and sorry if I'm not really expert. So:what can I do if I want it to work just with my input?

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
If you want it to work with your own input, you can use the ON INPUT event handler to look for you typing 'ciao', as you can find in the F1 help or at

https://en.wikichip.org/wiki/mirc

Or is much simpler for you to create a custom alias named 'ciao', and then you can invoke it by typing /ciao in channel. Something like:

Code
alias ciao {
  msg $chan $chr(22) ciao! $chr(22)
}

Or for this case, instead of looking at everything you type to see if it is '!countdown', you can create an alias like this that reacts to /countdown 5, and is my attempt to modify the existing script as little as possible

Code
alias countdown {
  if ($window($active).type !isin channel query) { echo -ag must be typed in a channel or query window! | return }
  if ($1 isnum 1-5) {
    var %x 1
    var %y $int($1)
    while (%x <= $int($1)) {
      .timer 1 %y msg $unsafe( $active %x )
      if (%x == $int($1)) { .timer 1 $calc(%x + 1) $unsafe( msg $active GO!!!! ) }
      inc %x
      dec %y
    }
  }
  else { echo -ag error must use 1-5 like: /countdown 4 }
}

Reminder that the above doesn't work in the 6.35 you were first using because of how timers are handled there, as I described in the earlier post. Also, the above alias uses the newer $unsafe identifier that defends against strings created by not-you, which in this case is a channel name containing ,$word or ,%word which is extremely unlikely but can be a big problem if it does happen.

Assuming it's not needed, you can either remove the $unsafe( ) wrapper or you can add an alias that is ignored by newer mIRC that already has this built-in, but in 6.35 it would give most of the functionality of the $unsafe identifier:

Code
alias unsafe { return $!decode( $encode($1,m) ,m) }

But is a good habit to be in where you use $unsafe for strings that you did not create, as described in the above wikichip link for 'msl injection'


Link Copied to Clipboard