mIRC Homepage
Posted By: RusselB Play control timer - 25/05/05 05:38 AM
I'm looking for a way to add a timer to the following code so that when it's a certain person's turn (nick is stored is %spin.nick) they're given 4 minutes to respond, then sent a warning message that they have 1 minute to respond or they will be removed from the game. if they haven't responded within that minute then their nick is removed from the game. Players nicks are stored in %play.list. If the player is removed from the game, then the person that spun (%spin.last) is messaged to spin again.
I've included the full code for the TorD game section of the bot, rather than just the part that I think is relevant, just in case.

I have highlighted the sections that I think are relevant in red, for easy locating.

Code:
 #td on
on 10:text:!cheat &:?:{
  if (!$2) && (!%cheaters) {    .notice $nick No one is cheating  }
  elseif $2 == %spin.nick {      .notice $nick $2 cannot spin themselves    }
  elseif (!$istok(%play.list,$2,44)) {       .notice $nick $2 is not playing    }
  else {
    set %cheaters $addtok(%cheaters,$2,44)
    .notice $nick $2 is scheduled to be spun
  }
}

on 10:TEXT:!add *:#:{ 
  var %a = 1 
  while $gettok($2-,%a,32) { 
    var %b = $v1 
    if $istok(%watch,%b,44) {       .notice $nick %b is on a 5min play delay     } 
    else {
      mode %td.chan +v %b
      set %play.list $addtok(%play.list,%b,44) 
      /todr.timer.restart $gettok(%play.list,%b,44) $chan
    }
    inc %a 
  } 
  describe # 5 Current Players Are %play.list 
} 

on 10:TEXT:!remove *:#:{
  if ($2) { 
    var %x = 1 
    while ( %x <= $numtok($2-,32) ) { 
      mode %td.chan -v %b
      set %play.list $remtok(%play.list,$gettok($2-,%x,32),1,44) 
      set %cheaters $remtok(%cheaters,$gettok($2-,%x,32),1,44) 
      /todr.timer.pause $gettok($2-,%x,32)
      inc %x 
    } 
  }
  describe # 5 watches as $nick removes $2- from the playlist 
  if (!%play.list) describe # 5There are no players
  else describe # 5 :Current Players Are %play.list
  if $istok($2-,%spin.last,32) {    unset %spin.last   }
  if $istok($2-,%spin.nick,32) {    unset %spin.nick   }
}

on *:text:truth*:#:{  if $nick == %spin.nick {    set %spin.nick_choice T  } }
on *:text:dare*:#:{  if $nick == %spin.nick {    set %spin.nick_choice D  } }
on *:text:*choice*:#:{  if $nick == %spin.nick {      set %spin.nick_choice SC    }  }
on *:text:sc:#:{  if $nick == %spin.nick {      set %spin.nick_choice SC    }  }
on *:text:*who*turn*:#:{
  if !%spin.nick_choice {
    if $numtok(%play.list,44) > 1 {      describe # 5 says %spin.nick needs to pick Truth, Dare, %spin.last $+ 's choice, or !choose    }
    elseif $numtok(%play.list,44) == 1  {      describe # 5 says %play.list is the only player    }
    else describe # 5 says there are no players
  }
  elseif %spin.nick_choice == T  {
    describe # 5 reminds %spin.last that %spin.nick is waiting for a Truth query
    describe # 5 or %spin.nick needs to answer %spin.last $+ 's Truth query
  }
  elseif %spin.nick_choice == D {
    .notice %spin.last If you need to check %spin.nick $+ 's limits, type !showme %spin.nick
    describe # 5 reminds %spin.last that %spin.nick is waiting for a Dare
    describe # 5 or %spin.nick needs to complete %spin.last $+ 's dare
  }
  else describe # 5 It is %spin.nick $+ 's turn to spin
}

on *:text:!autoplay:#:{
  if !$hget(TD,$laddress($nick,Limits.)) {
    describe # is sorry to say that the autoplay feature requires $nick to have their limits set
    set %play_temp $addtok(%play_temp,$nick,44)
    .msg $nick To set your limits, type !limit your limits here
    .msg $nick Put your limits in place of your limits here
    .msg $nick For example: !limit scat, animals, kids, golden showers
  }
  elseif !$hget(TD,$+(Autoplay,$address)) {
    hadd -m TD $+(Autoplay,$address) on
    describe # is happy to announce that $nick has decided to be a permanent player
    mode %td.cahn +v $nick
    set %play.list $addtok(%play.list,$nick,44)
    /todr.timer.restart $nick $chan
    describe # 5 :Current Players Are %play.list
  }
  else {
    hdel TD $+(Autoplay,$address)
    describe # sighs as $nick has decided to no longer be a permanent player
  }
}

on *:TEXT:!watch:#:{
  if $istok(%cheaters,$nick,44) {    set %cheaters $remtok(%cheaters,$nick,1,44)  }
  if $istok(%play.list,$nick,44) {
    set %play.list $remtok(%play.list,$nick,1,44)
    set %watch $addtok(%watch,$nick,44)
    .timer 1 300 set %watch $remtok(%watch,$nick,1,44)
    /todr.timer.pause $nick
    mode %td.chan -v $nick
    describe # 5 sighs as $nick decides to stop playing
    if (!%play.list)       describe # 5There are no players 
    else         describe # 5 :Current Players Are %play.list
    if ($nick == %spin.last)  unset %spin.last 
    if ($nick == %spin.nick)  unset %spin.nick 
  }
  else     describe # 5 whispers to $nick $+ , "you are not playing"  
}

on !*:PART:#:{
  todr.timer.pause $nick
  if $istok(%cheaters,$nick,44) {    set %cheaters $remtok(%cheaters,$nick,1,44)  }
  if $istok(%watch,$nick,44) { set %watch $remtok(%watch,$nick,1,44) }
  if $istok(%play.list,$nick,44) {
    set %play.list $remtok(%play.list,$nick,1,44)
    if (!%play.list) describe # 5There are no players 
    else         describe # 5 :Current Players Are %play.list
    if ($nick == %spin.last)  unset %spin.last 
    if ($nick == %spin.nick)  unset %spin.nick 
  }
}
on !*:QUIT:{
  todr.timer.pause $nick
  if $istok(%cheaters,$nick,44) {    set %cheaters $remtok(%cheaters,$nick,1,44)  }
  if $istok(%watch,$nick,44) { set %watch $remtok(%watch,$nick,1,44) }
  if $istok(%play.list,$nick,44) {    set %play.list $remtok(%play.list,$nick,1,44)  }
  if ($nick == %spin.last)  unset %spin.last 
  if ($nick == %spin.nick)  unset %spin.nick 
}
on !*:KICK:#:{
  todr.timer.pause $knick
  if $istok(%cheaters,$knick,44) {    set %cheaters $remtok(%cheaters,$knick,1,44)  }
  if $istok(%watch,$knick,44) { set %watch $remtok(%watch,$knick,1,44) }
  if $istok(%play.list,$knick,44) {
    set %play.list $remtok(%play.list,$knick,1,44)
    if (!%play.list) describe # 5There are no players 
    else         describe # 5 :Current Players Are %play.list
    if ($knick == %spin.last)  unset %spin.last 
    if ($knick == %spin.nick)  unset %spin.nick 
  }
}

on @*:NICK:{
  var %away.1 = afk,bbs,brb,bbl,bbiab,away
  set %watch $reptok(%watch,$nick,$newnick,44)
  var %a = 1
  while %a <= $numtok(%away.1,44) {
    var %away.2 = $gettok(%away.1,%a,44)
    if ($+(%away.2,*) iswm $newnick) || ($+(*,%away.2) iswm $newnick) {
      if $istok(%play.list,$nick,44) {
        describe %td.chan sighs as $nick stops playing
      }
      .auser idle $newnick
      set %play.list $remtok(%play.list,$nick,1,44)
      .mode %td.chan -v $nick
      set %cheaters $remtok(%cheaters,$nick,1,44)
      set %away $addtok(%away,$newnick,32)
      if ($nick == %spin.last) { unset %spin.last }
      if ($nick == %spin.nick) { unset %spin.nick }
      var %a = $numtok(%away.1,44)
    }
    inc %a 
  }
  set %play.list $reptok(%play.list,$nick,$newnick,44)
  if !$istok(%away,$newnick,32) && $hget(TD,$laddress($newnick,Autoplay)) {
    set %play.list $addtok(%play.list,$newnick,44)
    .mode %td.chan +v $newnick
    .ruser idle $nick
  }
  if (%play.list) {  describe %td.chan 5 :Current Players Are %play.list }
  else describe %td.chan 5 No players at present
}

on *:text:!play:#:{
  if $istok(%play.list,$nick,44) {    describe # 5 whispers to $nick $+ , "you are already playing" | halt }
  if !$hget(TD,$laddress($nick,Limits.)) {
    .hadd TD $+(Limits.,$address) snuff sex, kiddie sex, incest, child pornography, animal sex or rape
    .msg $nick Your limits have been temporarily set to those of the server
    .msg $nick To set your personal limits, type !limits your limits here
    .msg $nick Put your limits in place of your limits here
    .msg $nick For example: !limit scat, animals, kids, golden showers
  }
  set %play.list $addtok(%play.list,$nick,44)
  mode %td.chan +v $nick
  .ruser idle $nick
  set %watch $remtok(%watch,$nick,1,44)
  describe # 5 smiles as $nick decides to play
  describe # 5 Current Players Are %play.list
  /todr.timer.restart $nick $chan
}
on *:text:!players:*:{
  if (%play.list) {
    .msg $nick 5 Current Players: %play.list
    if (%spin.last)       .msg $nick 5 The last person to spin was: %spin.last
    if (%spin.nick)       .msg $nick 5 The last person to be chosen was: %spin.nick
  }
  else     .msg $nick 5 There is no game currently going
}

on *:text:!play*list:*:{
  if (%play.list) {
    .msg $nick 5 Current Players: %play.list
    if (%spin.last)       .msg $nick 5 The last person to spin was: %spin.last
    if (%spin.nick)       .msg $nick 5 The last person to be chosen was: %spin.nick
  }
  else     .msg $nick 5 There is no game currently going
}

 [color:red] on 10:TEXT:!spinfor &:*:{
  if (%spin.nick_choice == t) {
    .hinc -m Truths $right($address($2,0),-2)
    .hinc -m Truths 0
  }
  elseif (%spin.nick_choice == d) {
    .hinc -m Dares $right($address($2,0),-2)
    .hinc -m Dares 0
  }
  else {
    .hinc -m SC $right($address($2,0),-2)
    .hinc -m SC 0
  }
  unset %spin.nick_choice
  set %cheat $gettok(%cheaters,1,44)
  set %cheaters $remtok(%cheaters,%cheat,1,44)
  if !%cheat {
    if $numtok(%play.list,44) == 1 {      describe # It appears that %play.list is the only player    }
    elseif ($numtok(%play.list,44) == 2) {
      set %spin.nick $remtok(%play.list,$$2,1,44)
      set %spin.last $$2
      describe # 5 looks at  %spin.nick  $+ , and says " $+ $$2 wishes to know 'Truth, Dare, $$2 $+ 's Choice, # $+ 's choice with !choose?"
      .timer 1 3 .notice %spin.nick 4You were picked! Truth, Dare, $$2 $+ 's Choice, !choose?
    }
    else {
      while %spin.nick == $$2 {
        set %spin.nick $gettok(%play.list,$r(1,$numtok(%play.list,44)),44)
      }
      set %spin.last $$2
      .timer 1 1 describe # 5 grins as $nick spins the bottle for $$2
      .timer 1 3 describe # 5 gasps happily as it halts, pointing to %spin.nick
      .timer 1 5 describe # 4 %spin.nick  $+ 5, Truth, Dare, $$2 $+ 's Choice, or !choose?
      .timer 1 6 .notice %spin.nick 4You were picked! Truth, Dare, $$2 $+ 's Choice, or !choose?
    }
  }
  else {
    set %spin.nick %cheat
    unset %cheat
    set %spin.last $$2
    if $numtok(%play.list,44) == 2 {
      describe # 5 looks at %spin.nick $+ , and says " $+ $$2 wishes to know 'Truth, Dare, $$2 $+ 's Choice, # $+ 's choice with !choose?"
      .timer 1 3 .notice %spin.nick 4You were picked! Truth, Dare, $$2 $+ 's Choice, !choose?
    }
    elseif $numtok(%play.list,44) > 2 {
      .timer 1 1 describe # 5 grins as $nick spins the bottle for $$2
      .timer 1 3 describe # 5 gasps happily as it halts, pointing to %spin.nick
      .timer 1 5 describe # 5 %spin.nick  $+ , Truth, Dare, $$2 $+ 's Choice, or !choose?
      .timer 1 6 .notice %spin.nick 4You were picked! Truth, Dare, $$2 $+ 's Choice, or !choose?
    }
    else {
      .timer 1 1 describe # 5 grins as $nick spins the bottle for $$2
      .timer 1 3 describe # 5 gasps happily as it halts, pointing to %spin.nick
      .timer 1 5 describe # 4 %spin.nick  $+ 5, Truth, Dare, $$2 $+ 's Choice, or !choose?
      .timer 1 6 .notice %spin.nick 4You were picked! Truth, Dare, $$2 $+ 's Choice, or !choose?
    }
  }
}

on *:TEXT:!spin:#:{
  if (!$istok(%play.list,$nick,44)) {
    describe # Sorry $nick $+ , but I don't see your name in the players list
    .msg $nick type !play if you wish to play
    halt
  }
  elseif ($nick != %spin.nick) && $istok(%play.list,%spin.nick,44) {    
    describe # 5 whispers to $nick $+ , Sorry..but it's not your turn to spin 
    .msg %spin.nick Reminder that it's your turn to spin
    halt
  }
  if (%spin.nick_choice == t) {
    .hinc -m Truths $right($address($nick,0),-2)
    .hinc -m Truths 0
  }
  elseif (%spin.nick_choice == d) {
    .hinc -m Dares $right($address($nick,0),-2)
    .hinc -m Dares 0
  }
  else {
    .hinc -m SC $right($address($nick,0),-2)
    .hinc -m SC 0
  }
  unset %spin.nick_choice
  set %cheat $gettok(%cheaters,1,44)
  set %cheaters $remtok(%cheaters,%cheat,1,44)
  if $numtok(%play.list,44) == 1 {      .describe # 5apologizes to $nick $+ . It appears you are the only player.    }
  else {
    if (!%cheat) {
      if $numtok(%play.list,44) == 2 {
        set %spin.last $nick
        set %spin.nick $remtok(%play.list,$nick,1,44)
        describe # 5 looks at  %spin.nick  $+ , and says " $+ $nick wishes to know 'Truth, Dare, $nick $+ 's Choice, or $me $+ 's choice with !choose?"
        .timer 1 3 .notice %spin.nick 4You were picked! Truth, Dare, $nick $+ 's Choice, or !choose?
        halt
      }
      else {
        if (!%spin.nick) { set %spin.nick $nick }
        while %spin.nick == $nick {          set %spin.nick $gettok(%play.list,$rand(1,$numtok(%play.list,44)),44)        }
        set %spin.last $nick
        .timer 1 1 describe # 5 grins as $nick spins the bottle...
        .timer 1 3 describe # 5 gasps happily as it halts, pointing to %spin.nick
        .timer 1 5 describe # 5 %spin.nick $+ , Truth, Dare, $nick $+ 's choice, !vote or !choose
        .timer 1 6 .notice %spin.nick 4You were picked! Truth, Dare, $nick $+ 's Choice, !vote or !choose?
        halt
      }
    }
    if $numtok(%play.list,44) == 2 {
      set %spin.nick %cheat
      set %spin.last $nick
      describe # 5 looks at %spin.nick $+ , and says " $+ $nick wishes to know 'Truth, Dare, $nick $+ 's Choice, or $me $+ 's choice with !choose?"
      .timer 1 3 .notice %spin.nick 4You were picked! Truth, Dare, $nick $+ 's Choice, or !choose?
      halt
    }
    else {
      set %spin.nick %cheat
      set %spin.last $nick
      .timer 1 1 describe # 5 grins as $nick spins the bottle...
      .timer 1 3 describe # 5 gasps happily as it halts, pointing to %spin.nick
      .timer 1 5 describe # 5 %spin.nick $+ , Truth, Dare, $nick $+ 's Choice, !vote or !choose? 
      .timer 1 6 .notice %spin.nick 4You were picked! Truth, Dare, $nick $+ 's Choice, !vote or !choose?
      halt
    }
  }
}
 [/color] 
on *:text:!vote:#:{
  if ($numtok(%play.list,44) < 3) { describe # Sorry, there must be at least 3 players for voting }
  elseif ($nick == %spin.nick) {
    describe # %spin.nick has decided to let the other players decide if they get a Truth or a Dare
    describe # Those eligible to vote will be pm'd by the bot and Only votes cast in the pm window will be tabulated
    /vote.for.truth.or.dare
  }
  elseif ($nick == %spin.last) && (%spin.nick_choice == sc) {
    describe # %spin.nick decided to let %spin.last decide Truth or Dare, and now %spin.last is handing the decision to the other players
    describe # Those eligible to vote will be pm'd by the bot and Only votes cast in the pm window will be tabulated
    /vote.for.truth.or.dare
  }
}

on $10:text:/!c[dt] /i:?:{ 
  var %a = $mid($1,2) $+ .txt,%b = $remove(cd.txtct.txt,%a), $& 
    %c = $iif(%a = ct.txt,truthed,dared),%n = .notice $nick $2 
  if (!$2) && ($1 == !ct) { .play $nick ct.txt 2000 }
  elseif (!$2) && ($1 == !cd) { .play $nick cd.txt 2000 }
  else {
    if ($read(%a,w,$2)) { 
      write -dl $readn %a 
      %n is no longer being %c 
      halt  
    } 
    if ($read(%b,w,$2)) { 
      write -dl $readn %b 
      %n is no longer being $remove(trutheddared,%c) 
    } 
    write %a $2 
    %n has been %c 
  }
} 

on *:TEXT:!choose:#:{
  set %choice $iif($read(cd.txt,w,$nick),B,A)
  set %choice $iif($read(ct.txt,w,$nick),A,$r(A,B))
  if (%choice == A) {
    set %choice Truth
    set %spin.nick_choice T
  }
  else {
    set %choice Dare
    set %spin.nick_choice D
  }
  describe # 5 randomly picks %choice for4 %spin.nick 
}

[suggestions]
on *:text:!s truth:#:{ set %oldtruth $on.text.!s.truth.or.dare(%oldtruth,truth.txt) }
on *:text:!s dare:#:{ set %olddare $on.text.!s.truth.or.dare(%olddare,dare.txt) }

[timers]
on *:TEXT:!timer*:*:{
  if ($2 isnum 1-) {
    if $nick isop %td.chan {      todr.timer.stop $nick $2    }
    else .msg $nick Sorry..Only Ops can stop timers in advance
  }
  else {    todr.msg.timerlist $nick  }
}
;
;$1 = $nick
alias todr.msg.timerlist {
  hadd -m todr.timerlists $+($$1,.)
  hdel -w todr.timerlists $+($1,.*)
  var %m = $timer(0)
  var %c = 1
  var %i = 1
  while (%i <= %m) {
    if (.todr.* iswm $timer(%i)) {
      hadd -mu600 todr.timerlists $+($nick,.,%c) $timer(%i)
      .msg $1 Timer $chr(35) %c : $duration($timer(%i).secs) remaining for $gettok($timer(%i),2,46) : " $gettok($timer(%i).com,2-,34) "
      inc %c
    }
    inc %i
  }
  if (%c == 1) { .msg $1 There are no timers active }
}
;
;$1 = $nick
;$2 = number ( does not represent timer number x )
alias todr.timer.stop {
  if ($hget(todr.timerlists,$+($1,.,$2))) {
    var %timername = $v1
    if ($timer(%timername)) {
      describe %td.chan anounces that $gettok(%timername,2,46) $+ 's timer is stopped for " $gettok($timer(%timername).com,2-,34) "
      timer $+ %timername off
      hdel todr.timers timer $+ %timername
      hdel todr.timers tm2go $+ %timername
    }
    else { .msg $1 That timer has gone off or was already canceled. }
  }
  else { .msg $1 What timer was that?, try doing a !timer on its own to get a list of them. }
}
;
;
;
on *:text:!truthlist*:*:{
  if (!$2) { .play $nick truth.txt }
  elseif ($2 <= $lines(truth.txt)) { describe # $read(truth.txt,$2) }
  else .msg $nick Sorry, Truth $2 not found
}
on *:text:!darelist*:*:{
  if (!$2) { .play $nick dare.txt }
  elseif ($2 <= $lines(dare.txt)) { describe # $read(dare.txt,$2) }
  else .msg $nick Sorry, Dare $2 not found
}
on 10:TEXT:!truthfor & *:#:{ 
  set %spinnick_choice t
  set %truthnick $2
  describe # 5 Watches as 1 $nick  sets the egg timer to 4 5mins  for 12 %truthnick $+ 's  truth, " $3- " 
  timer 1 300 describe # 5 hears the egg timer ding, time up for %truthnick $+ 's truth, " $3- " 
} 

on *:TEXT:!truth*:#:{ 
  set %spinnick_choice t
  if ($nick == %spin.last) { 
    set %truthnick %spin.nick 
    describe # 5 Watches as 1 $nick  sets the egg timer to 4 5mins  for 12 %truthnick $+ 's  truth, " $2- " 
    timer 1 300 describe # 5 hears the egg timer ding, time up for %truthnick $+ 's truth, " $2- " 
  } 
  elseif ($nick != %spin.nick) {    describe # 5 looks to $nick and laughs... "Sorry, you were not the one that spun the bottle"  } 
} 

on 10:TEXT:!darefor*:#:{ 
  if !$2 {
    .notice $nick The format for the !darefor command is !darefor <time> <nick> <name/description of dare>
    .notice $nick <time> is optional, but if you don't include it, the time will be set for 15mins
    halt
  }
  set %dare $iif(($1 == !darefor),$2-,$remove($1-,!darefor))
  tokenize 32 %dare
  if (!$duration($1)) && ($1 !isnum) {
    set %dare $instok(%dare,15,1,32)
    tokenize 32 %dare
  }
  if ($1 isnum) {      set %daretime $calc(60 * $1)    }
  elseif ($numtok($1,58)) {        set %daretime $duration($1)      }
  if $2 !ison %td.chan {
    .notice $nick Sorry, but I don't see $2 in %td.chan
    halt
  }
  set %darenick $2
  if !$3 {        .notice $nick Please use !darefor $1 $2 <name/description of dare>  |     halt      }
  describe # 5 Watches as 1 $nick  sets the egg timer to 4 $duration(%daretime)  for 12 %darenick $+ 's  dare, " $3- " 
  ;
  ;
  ;            timer 1 %daretime describe # 5 hears the egg timer ding, time up for %darenick $+ 's dare, " $3- " 
  todr.timer %darenick %daretime describe # 5 hears the egg timer ding, time up for %darenick $+ 's dare, " $3- "
  ;
  ;
}
on *:TEXT:!dare*:#:{ 
  if !$2 {
    .notice $nick The format for the !dare command is !dare <time> <name/description of dare>
    ;    .notice $nick <time> is optional, but if you don't include it, the time will be set for 15mins
    halt
  }
  set %spinnick_choice d
  if ($nick == %spin.last) { 
    set %darenick %spin.nick 
    set %dare $iif(($1 == !dare),$2-,$remove($1-,!dare))
    if $istok(%dare,%darenick,32) { set %dare $remtok(%dare,%darenick,1,32) }
    if $numtok(%dare,124) { set %dare $remove(%dare,$chr(124)) }
    tokenize 32 %dare
    if (!$duration($1)) && ($1 !isnum) {
      set %dare $instok(%dare,15,1,32)
      tokenize 32 %dare
    }
    if !$2 {
      .notice $nick Please use !dare $1 <name/description of dare>
      halt
    }
    if ($numtok($1,58)) {        set %daretime $duration($1)      }      
    elseif ($1 isnum) { set %daretime $calc(60 * $1)    }
    if %daretime == 0 { set %daretime 900 }
    describe # 5 Watches as 1 $nick  sets the egg timer to 4 $duration(%daretime)  for 12 %darenick $+ 's  dare, " $2- " 
    ;
    ;
    ;            timer 1 %daretime describe # 5 hears the egg timer ding, time up for %darenick $+ 's dare, " $2- "
    todr.timer %darenick %daretime describe # 5 hears the egg timer ding, time up for %darenick $+ 's dare, " $2- "
    ;
    ;
  } 
  else if ($nick != %spin.nick) {    describe # 5 looks to $nick and laughs... "Sorry, you were not the one that spun the bottle"  } 
}
#td end

#vote on
;This code EXPECTS the following variables, it is your responcability to ensure there there.
;%play.list %spin.nick %spin.last
;This code creates 6 variables, they are erased when the vftod.clean.up alias is triggered, also any timers created well be destroyed.
;%td.chan - channel of Truth or Dare
;%vftod.Truth - count of votes for truth
;%vftod.Dare - count of votes for dare
;%vftod.Skip - count of votes for skip
;%vftod.list - list of voters (voter names well be removed as they vote)
;%vftod.voters - total number of voters
;
;
;You init the voting by running /vote.for.truth.or.dare
; Nicks are msged 1 per second until all the list is messaged (excluding %spin.nick %spin.last)
; Then a 60 count to a reminder is started
; Then a 120 second count to voting closes is started
;
;If the reminders are triggered then only yet to vote nicks are msged (1 per second)
;If all votes are received or the Truth votes or Dare votes become over 50% then voting closes ( reminders will also be cancelled )
;When voting closes equal votes check is performed and one is chosen, then channel is msged as to the result. YOU NEED TO ADD CODE HERE FOR TRUTH OR DARE
;
;
alias vote.for.truth.or.dare {
  vftod.clean.up
  set %vftod.Truth 0
  set %vftod.Dare 0
  set %vftod.Skip 0
  set %vftod.list $remtok($remtok(%play.list,%spin.nick,1,44),%spin.last,1,44)
  set %vftod.voters $numtok(%vftod.list,44)
  ;
  var %i = %vftod.voters
  while (%i) {
    .timer $+ $+(.vftod.vote.msg.,%i) 1 %i msg $!( $+ $gettok(%vftod.list,%i,44) $+ ,) You are requested to vote for $!( $+ %spin.nick $+ ,) to take a Truth or a Dare, please reply with T, D, Truth, Dare, or to pass S or Skip, you have around 2 minutes to respond.
    dec %i
  }
  .timer.vftod.reminder 1 $calc(60 + %vftod.voters) vftod.reminder  .timer.vftod.close.voting 1 $calc(120 + %vftod.voters) vftod.close.voting
}

on *:TEXT:T:?:{ vftod.reply $nick T }
on *:TEXT:Truth:?:{ vftod.reply $nick T }
on *:TEXT:D:?:{ vftod.reply $nick D }
on *:TEXT:Dare:?:{ vftod.reply $nick D }
on *:TEXT:S:?:{ vftod.reply $nick S }
on *:TEXT:Skip:?:{ vftod.reply $nick S }
;
alias vftod.reply {
  if ($istok(%vftod.list,$1,44)) {
    if     ($2 == T) { inc %vftod.Truth }
    elseif ($2 == D) { inc %vftod.Dare }
    else             { inc %vftod.Skip }
    set %vftod.list $remtok(%vftod.list,$1,44)
    msg $1 Vote Recorded, thankyou for your time.
    var %vftod.more.than.half = $int($calc((%vftod.voters - %vftod.Skip) / 2 + 1))    
    if ((!%vftod.list) || (%vftod.Truth >= %vftod.more.than.half) || (%vftod.Dare >= %vftod.more.than.half)) {      vftod.close.voting    }
  }
}
;
alias vftod.reminder {
  var %i = $numtok(%vftod.list,44)
  while (%i) {
    .timer $+ $+(.vftod.reminder.msg.,%i) 1 %i msg $!( $+ $gettok(%vftod.list,%i,44) $+ ,) You are requested to vote for $!( $+ %spin.nick $+ ,) to take a Truth or a Dare, please reply with T or D or Truth or Dare, to pass you may enter S or Skip, you have around 1 minute to respond. (this is a reminder)
    dec %i
  }
}
;
alias vftod.close.voting {
  if (%vftod.Truth == %vftod.Dare) {
    $iif($rand(0,1),inc %vftod.Truth,inc %vftod.Dare)
  }
  if (%vftod.Truth > %vftod.Dare) {
    msg %td.chan %spin.nick will be getting a Truth from %spin.last by a voting of ( $+ %vftod.Truth $+ ) : ( $+ %vftod.Dare $+ )
    set %spin.nick_choice T
  }
  else {
    msg %td.chan %spin.nick will be getting a Dare from %spin.last by a voting of ( $+ %vftod.Dare $+ ) : ( $+ %vftod.Truth $+ )
    set %spin.nick_choice D
  }
  vftod.clean.up
}
;
alias vftod.clean.up {
  unset %vftod.*
  .timer.vftod.* off
}
#vote end
 
© mIRC Discussion Forums