All pastes #510527 Raw Edit

Something

public text v1 · immutable
·published 2007-05-25 22:46 UTC
rendered paste body
on *:TEXT:!numbers*:#:{
  if ($read(over.txt) == Started) { halt }  
  if (timerno == Active) { halt } 
  set %rnum $rand(1,25)
  write join.txt [ $+ [ $chan ] ] $nick
  msg $chan $nick has started the random number game. 2 minutes till game starts, type !join to join in.
  timerno 0 120 write over.txt Started 
}

on *:TEXT:!join*:#:{
  if ($read(over.txt) == Started) { timers off | halt }
  if ($lines(over.txt) = 10) { msg $chan We now have 10 players, type !guess 1-25 to start }
  if ($lines(over.txt) > 10) { notice $nick There is already a game going on! | halt }
  if ($nick == $read(over.txt,w,$nick) { halt }  
  write join.txt [ $+ [ $chan ] ] $nick
  msg $chan We now have $lines(join.txt) players.
}

on *:!guess*:#:{ 
  if ($read(over.txt) == Started) {
    if ($read(join.txt,$chan,$nick)) {   
      if ($nick == $ $+ %msg $read(join.txt,$chan,$nick)) {      
        write guess.txt [ $+ [ $chan ] ] $2
        msg $chan it's $ $+ %msg $read(join.txt,$nick) $+ 's turn.
        if ($2 == %rnum) {
          timer 0 5 msg $chan RIGHT!
          unset %msg          
          unset %rnum
          remove over.txt
          remove join.txt
        }
        else { timer 0 5 msg $chan $nick was WRONG. He was apprx, $calc(%rnum / $2 %rand 5) off. }
      }
    }
  }
}