mIRC Home    About    Download    Register    News    Help

Print Thread
#255898 30/11/15 11:59 AM
Joined: Apr 2015
Posts: 42
A
Artiiz Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Apr 2015
Posts: 42
Hello,

I have a question if something is possible making with my script.

So I'm using a countdown for Twitch, which counts the duration time to set date and time.
It looks like this:

And the script looks like this:
Code:
alias todate {
  var %month = 11
  var %day = 30
  var %year = 2015

  var %todate = $calc($ctime($+(%day,-,%month,-,%year) 14:00:00) - $ctime)
  if (%todate < 0) {
    inc %year
    %todate = $calc($ctime($+(%day,-,%month,-,%year) 14:00:00) - $ctime)
  }
  return %todate
}
on 1:text:*stream*:#yznb:{
  if ((%floodtest) || ($($+(%,floodtest.,$nick),2))) { return }
  set -u30 %floodtest On
  set -u60 %floodtest. $+ $nick On
  msg $chan @ $+ $nick Next stream starts in about $replace($duration($todate($2,$3)),hrs,h,hr,h,mins,m,secs,s,sec,s) $+
}


What I wanna know if possible, is to make so it says like this instead:

"Next stream starts in about 1h, 05m and 48s", instead of what is says now
"Next stream starts in about 1h 5m 48s".

Last edited by Artiiz; 30/11/15 12:24 PM.
Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Try use this code:

Code:
alias todate {
  var %month = 11
  var %day = 30
  var %year = 2015
  var %todate = $calc($ctime($+(%day,-,%month,-,%year) 14:00:00) - $ctime)
  if (%todate < 0) {
    inc %year
    %todate = $calc($ctime($+(%day,-,%month,-,%year) 14:00:00) - $ctime)
  }
  return %todate
}

alias -l fixdate {
  if (!$1-) { return }
  var %t = $replace($1-,hrs,h,hr,h,mins,m,min,m,secs,s,sec,s)
  if (*m* iswm %t) { 
    var %min = $gettok($gettok(%t,1,109),$numtok($gettok(%t,1,109),32),32)
    var %fm = %min $+ m
    var %fm2 = 0 $+ %fm
    if ($len(%fm2) == 3) {
      var %rep = $replace(%t,%fm,%fm2)
      var %t = $replace(%t,%t,%rep)
    }
  }
  if (*s* iswm %t) {
    var %s = $gettok(%t,$numtok(%t,32),32)
    var %t = $puttok(%t,and,$numtok(%t,32),32) %s
  }
  if (*h* iswm %t) { var %t = $replace(%t,h,h $+ $chr(44)) }
  if (%t) { return %t }
  elseif (!%t) { return 0 }
}

ON *:TEXT:*stream*:#yznb: {
  tokenize 32 $strip($1-)
  if ((%floodtest) || ($($+(%,floodtest.,$nick),2))) || (!$2) || (!$3) { return }
  set -u30 %floodtest On
  set -u60 %floodtest. $+ $nick On
  var %d = $duration($todate($2,$3))
  if (%d) { var %dur = $fixdate(%d) }
  if (%dur) { msg $chan @ $+ $nick Next stream starts in about  $+ %dur $+  }
}


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Apr 2015
Posts: 42
A
Artiiz Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Apr 2015
Posts: 42
It doesn't seem to be working.
I tried change the channel name to my own "#artiiz", to try use it in my own channel first.

When I type either stream or !stream nothing happens.

Joined: Dec 2015
Posts: 148
Vogon poet
Offline
Vogon poet
Joined: Dec 2015
Posts: 148
Code:
alias durationxx tokenize 32 $replacex($duration($1),wks,w,wk,w,secs,s,sec,s,mins,m,min,m,hrs,h,hr,h,days,d,day,d) | return $iif($0 > 2,$replacex($gettok($1-,1- $+ $calc($v1 -1),32),$chr(32),$chr(44) $+ $chr(32)) and $ [ $+ [ $0 ] ],$1 and $2)

Use that instead of $duration.

Edit:
A little bug fix, and just in case you want double digits for minutes, seconds and whatever:
Code:
alias durationx tokenize 32 $ddfix($replacex($duration($1),wks,w,wk,w,secs,s,sec,s,mins,m,min,m,hrs,h,hr,h,days,d,day,d),m,s) | return $iif($0 > 2,$replacex($gettok($1-,1- $+ $calc($v1 -1),32),$chr(32),$chr(44) $+ $chr(32)) and $ [ $+ [ $0 ] ],$1 and $2)

alias ddfix {
  var %d = $1
  while ($2) {
    var %d = $iif($wildtok(%d,* $+ $2,1,32),$replacex(%d,$v1,$base($gettok($v1,1,$asc($2)),10,10,2) $+ $2),%d)
    tokenize 32 - $3-
  }
  return %d
}


Joined: Apr 2015
Posts: 42
A
Artiiz Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Apr 2015
Posts: 42
Originally Posted By: Dazuz
Code:
alias durationx tokenize 32 $replacex($duration($1),wks,w,wk,w,secs,s,sec,s,mins,m,min,m,hrs,h,hr,h,days,d,day,d) | return $iif($0 > 2,$replacex($1- [ $+ [ $calc($v1 -1) ] ],$chr(32),$chr(44) $+ $chr(32)) and $ [ $+ [ $0 ] ],$1 and $2)

Use that instead of $duration.


So I should replace this:
Code:
var %d = $duration($todate($2,$3))


With this?:
Code:
var %d = alias durationx tokenize 32 $replacex($duration($1),wks,w,wk,w,secs,s,sec,s,mins,m,min,m,hrs,h,hr,h,days,d,day,d) | return $iif($0 > 2,$replacex($1- [ $+ [ $calc($v1 -1) ] ],$chr(32),$chr(44) $+ $chr(32)) and $ [ $+ [ $0 ] ],$1 and $2)

Joined: Dec 2015
Posts: 148
Vogon poet
Offline
Vogon poet
Joined: Dec 2015
Posts: 148
Replace:
Code:
var %d = $duration($todate($2,$3))

With this:
Code:
var %d = $durationx($todate($2,$3))

And add this on its own line above/below/middle/whatever:
Code:
alias durationx tokenize 32 $replacex($duration($1),wks,w,wk,w,secs,s,sec,s,mins,m,min,m,hrs,h,hr,h,days,d,day,d) | return $iif($0 > 2,$replacex($gettok($1-,1- $+ $calc($v1 -1),32),$chr(32),$chr(44) $+ $chr(32)) and $ [ $+ [ $0 ] ],$1 and $2)


If you want double digits for minutes/seconds/whatever, add this instead:
Code:
alias durationx tokenize 32 $ddfix($replacex($duration($1),wks,w,wk,w,secs,s,sec,s,mins,m,min,m,hrs,h,hr,h,days,d,day,d),m,s) | return $iif($0 > 2,$replacex($gettok($1-,1- $+ $calc($v1 -1),32),$chr(32),$chr(44) $+ $chr(32)) and $ [ $+ [ $0 ] ],$1 and $2)

alias ddfix {
  var %d = $1
  while ($2) {
    var %d = $iif($wildtok(%d,* $+ $2,1,32),$replacex(%d,$v1,$base($gettok($v1,1,$asc($2)),10,10,2) $+ $2),%d)
    tokenize 32 - $3-
  }
  return %d
}



Edit:
Just to be safe, here's the whole thing:
Code:
alias todate {
  var %month = 11
  var %day = 30
  var %year = 2015

  var %todate = $calc($ctime($+(%day,-,%month,-,%year) 14:00:00) - $ctime)
  if (%todate < 0) {
    inc %year
    %todate = $calc($ctime($+(%day,-,%month,-,%year) 14:00:00) - $ctime)
  }
  return %todate
}
on 1:text:*stream*:#yznb:{
  if ((%floodtest) || ($($+(%,floodtest.,$nick),2))) { return }
  set -u30 %floodtest On
  set -u60 %floodtest. $+ $nick On
  msg $chan @ $+ $nick Next stream starts in about $durationx($todate($2,$3)) $+ .
}
alias durationx tokenize 32 $ddfix($replacex($duration($1),wks,w,wk,w,secs,s,sec,s,mins,m,min,m,hrs,h,hr,h,days,d,day,d),m,s) | return $iif($0 > 2,$replacex($gettok($1-,1- $+ $calc($v1 -1),32),$chr(32),$chr(44) $+ $chr(32)) and $ [ $+ [ $0 ] ],$1 and $2)
alias ddfix {
  var %d = $1
  while ($2) {
    var %d = $iif($wildtok(%d,* $+ $2,1,32),$replacex(%d,$v1,$base($gettok($v1,1,$asc($2)),10,10,2) $+ $2),%d)
    tokenize 32 - $3-
  }
  return %d
}

Last edited by Dazuz; 01/12/15 05:04 PM.

Link Copied to Clipboard