mIRC Home    About    Download    Register    News    Help

Print Thread
#241043 17/03/13 12:34 AM
Joined: Jun 2008
Posts: 12
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Jun 2008
Posts: 12
Hi all, I'm currently working on a simple countdown script that makes use of hash tables. I just want it to take $ctime and then subtract 8 hours (28800 seconds) from it to accommodate the PST timezone.

This is my current script:

Code:
on *:text:!setevent*:*:{
  if !$ctime($2-) {
    say $nick -> Unknown format. Please use this format: January 1 1970 00:00:00 
  }
  elseif $ctime($2-) < ($ctime -  28800) {
    say $nick -> Sorry, but $2- is a past date.
  }
  else {
    .hadd -m event  $ctime($2-) $2-
    say $nick -> Event date: $2- has been set.
  }
}
on *:text:!event:*:{
  if !$hget(event,1).item {
    say $nick -> Sorry, no event date has been set.
  }
  elseif $hget(event,1).item < ($ctime - - 28800) {
    say $nick -> event date has been passed.
  }
  else {
    say $nick -> Next event in: $duration($calc($hget(event,1).item - ($ctime - 28800))) PogChamp
  }
}

on *:text:!delevent:*:{ 
  if ($nick isop $chan) { 
    say $nick -> Countdown has been deleted.
    .hdel event $hget(event,1).item 
  } 
  else { 
    say $nick -> You're not a mod. 
  } 
} 

on *:start:{
  if !$hget(event) { .hmake event 100 }
  if $exists(event.hsh) { .hload event event.hsh }
}



If someone could point me in the right direction, that would be most appreciated.

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Your if statements aren't using $calc() and they should be:

elseif $ctime($2-) < $calc($ctime - 28800) {

elseif $hget(event,1).item < $calc($ctime - 28800) {

Joined: Jun 2008
Posts: 12
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Jun 2008
Posts: 12
Oh, of course. That's logical. I thought that mirc could handle the calculation on it's own.

Now I know. Thank you. smile


Link Copied to Clipboard