Ok, that took awhile. laugh

Note that I can't guarantee this will work and that I didn't mess anything up because I can't test it where I am at right now. Try it out and see if it works or if there are problems. If you have a problem, please post the problem with as many details as possible (check active and status for error messages).

Besides changing your channel names, you can change the red numbers...

The 30 is the time to join. Change to whatever you want. (This is in 2 spots).

The 2 is the number of minimum players required for the competition. You don't want 1 doing it or that person will always get 20 points. You may want a higher number than 2... it's up to you. (This is in 2 spots).

The 120 is the time to complete the competition. After that time (2 minutes), the competition ends even if players still have points. The reason for that is because someone may stop playing and not !leave. Raise this if needed. 5 minutes (300) may be better... just try it out and see how well it works.

The final red part is the delay for a person to answer a question when in the competition. Right now, they can only use !5050 once ever 5 seconds while in the competition. There is no error message if they try more quickly (that prevents flooding the bot off from the error message). This part is to help prevent flooding. Change it or remove it if you feel like it. -u5 is for 5 seconds. Change 5 if you want a different number.

Code:
on *:text:!comp5050:[color:red]#yourchan[/color]: {
  if ($hget(Game) == $null) {
    hmake Game 50
    hload Game 5050.txt
    .timerGame -o 0 10 hsave Game 5050.txt
  }
  if (%5050comp != $null) { msg $chan 50/50 Competition already started.  To join, type !join5050 | return }
  set %5050comp 1
  msg $chan 50/50 Competition started.  To join, type !join5050.  [color:red]2[/color] player minimum required to play.  Competition will start in [color:red]30[/color] seconds.  You must be joined by then to play.
  .timer5050compstart 1 [color:red]30[/color] 5050compstart
}

on *:text:!join5050:[color:red]#yourchan[/color]: {
  if (%5050comp == 1) {
    .notice $nick You have joined the 50/50 Competition.
    hinc Game Competition.players
    hadd Game Competition.nicks $hget(Game,Competition.nicks) $nick
    hadd Game $+(Competition.,$nick) 20 0
  }
  elseif (%5050comp == $null) {
    .notice $nick No competition has been started.  To start a competition, type !comp5050.
  }
  else {
    .notice $nick The 50/50 Competition has already started.  You cannot join a competition that has already started.
  }
}

on *:text:!leave:[color:red]#yourchan[/color]: {
  if (%5050comp != null) {
    if ($hget(Game,$+(Competition.,$nick)) != $null) {
      .notice $nick You have left the 50/50 Competition before finishing.
      hdec Game Competition.players
      hdel Game $+(Competition.,$nick)
      hadd Game Competition.nicks $remtok($hget(Game,Competition.nicks),$nick,32)
      if ($hget(Competition.players) == 0 && %5050comp == 2) {
        Complete5050Comp
      }
    }
    else { .notice $nick You aren't in the competition. }
  }
  else {
    .notice $nick No competition has been started, so you cannot leave one.  To start a competition, type !comp5050.
  }
}

alias 5050compstart {
  if ($hget(Game,Competition.players) >= [color:red]2[/color]) {
    msg $chan 50/50 Competition has begun.  Type !5050 to guess.
    set %5050comp 2
    .timer5050comp 1 [color:red]120[/color] 5050CompTimeOut
  }
  else {
    msg $chan Not enough players for the competition --  Competition closed.
    unset %5050comp
    hdel -w Game Competition*
  }
}

on *:text:!5050:[color:red]#yourchan[/color]: {
  [color:green]; Create the table for scores and set it to load/save automatically so no data loss will occur.[/color]
  if ($hget(Game) == $null) {
    hmake Game 50
    hload Game 5050.txt
    .timerGame -o 0 10 hsave Game 5050.txt
  }
  [color:green]; If competition isn't started, proceed normally.  Else, go to the Else and run the competition part.[/color]
  if (%5050comp != 2) {
    [color:green]; Check the random number 1 or 2.  If it's a 1, kick or kick/ban them.[/color]
    if ($rand(1,2) == 1) {
      [color:green]; Count the number of kicks and add them to the hash table.[/color]
      hadd Game $+($nick,.kicks) $calc($hget(Game,$+($nick,.kicks)) + 1)
      [color:green]; If the number of kicks is divisible by 5, ban and kick the person for 5 minutes.[/color]
      if ($calc($hget(Game,$+($nick,.kicks)) % 5) == 0) {
        if ($me isop $chan) {
          ban -ku300 $chan $nick You have lost the 50/50 and suffer a 5 minute ban.
        }
        else {
          msg $chan You have lost the 50/50 and would have suffered a 5 minute ban if I was an op.
        }
      }
      [color:green]; If the number of kicks isn't divisible by 5, just kick the person.[/color]
      elseif ($me isop $chan) {
        kick $chan $nick You lost the 50/50.
      }
      else {
        msg $chan You lost the 50/50 and would have been kicked if I was an op.
      }
    }
    [color:green]; If the random number is 2, give points.[/color]
    else {
      [color:green]; Add points to the hash table.[/color]
      hinc Game $+($nick,.points)
      msg $chan You have won the 50/50 and received 1 point for a total of $hget(Game,$+($nick,.points)) points.
    }
  }
  [color:green]; Competition section[/color]
  else {
    [color:red]if (%compdelay. $+ $nick != $null) { return }
    set -u5 %compdelay. $+ $nick 1[/color]
    if ($istok($hget(Game,Competition.nicks),$nick,32) {
      if ($gettok($hget(Game,$+(Competition.,$nick)),1,32) > 0) {
        if ($rand(1,2) == 1) {
          msg $chan $nick lost a life -- $gettok($hget(Game,$+(Competition.,$nick)),1,32) lives remaining.
          hadd Game $+(Competition.,$nick) $calc($gettok($hget(Game,$+(Competition.,$nick)),1,32) - 1) $gettok($hget(Game,$+(Competition.,$nick)),2,32)
          if ($gettok($hget(Game,$+(Competition.,$nick)),1,32) == 0) {
            msg $chan $nick has no more lives.
            hdec Game Competition.players
          }
          if ($hget(Game,Competition.players) == 0) {
            Complete5050Comp
          }
        }
        else {
          hadd Game $+(Competition.,$nick) $gettok($hget(Game,$+(Competition.,$nick)),1,32) $calc($gettok($hget(Game,$+(Competition.,$nick)),1,32) + 1)
          msg $chan $nick has won a point for a total of $gettok($hget(Game,$+(Competition.,$nick)),2,32) points.
        }
      else {
        .notice $nick You don't have any more lives.  Wait until the competition finishes.
      }
    }
    else {
      .notice $nick You aren't in the competition.  Try again after the competition is over.
    }
  }
}

[color:green]; Allow viewing scores with !won (to see your own) or !won nick (to see a nick's points).[/color]
on *:text:!won*:[color:red]#yourchan[/color]: {
  if ($2 != $null) {
    if ($hget(Game,$+($2,.points)) != $null) {
      msg $chan $2 has won $hget(Game,$+($2,.points)) points in the 50/50.
    }
    else {
      msg $chan $2 has not won any points in the 50/50.
    }
  }
  else {
    if ($hget(Game,$+($nick,.points)) != $null) {
      msg $chan You have won $hget(Game,$+($nick,.points)) points in the 50/50.
    }
    else {
      msg $chan You have not won any points in the 50/50.
    }
  }
}

alias Complete5050Comp {
  var %winner.nick = None
  var %winner.points = 0
  var %c = 1
  var %i = $gettok($hget(Game,Competition.nicks),0,32)
  while (%c <= %i) {
    if ($gettok($hget(Game,$+(Competition.,$gettok($hget(Game,Competition.nicks),%c,32))),2,32) > %winner.points) {
      var %winner.points = $gettok($hget(Game,$+(Competition.,$gettok($hget(Game,Competition.nicks),%c,32))),2,32)
      var %winner.nick = $gettok($hget(Game,Competition.nicks),%c,32)
    }
    inc %c
  }
  msg $chan 50/50 Competition Ended.
  msg $chan 50/50 Competition Winner: %winner.nick with %winner.points points!
  if (%winner.nick != None) {
    hinc Game $+(%winner.nick,.points) 20
  }
  unset %5050comp
  hdel -w Game Competition.*
  .timer5050comp off
}

alias 5050CompTimeOut {
  msg $chan Time's Up!
  Complete5050Comp
}

Last edited by Riamus2; 10/10/05 06:12 PM.

Invision Support
#Invision on irc.irchighway.net