Number Guess Game

By RusselB on Apr 28, 2005

A simple number guess game using a randomly generated number.

To start: !num
To guess: !num guess

Also keeps track of the number of correct guesses each person has made

Added Apr. 29, 2005:
!max number --- Sets the maximum number and auto-configures the minium number
!min number --- Sets the minimum number and auto-configures the maximum number

Either or both can be used

Also modified the start part of the code per suggestion by xDaeMoN

Modified Sept. 25, 2005 to prevent someone from setting new high/low amounts while a game is in progress

on *:text:!max &:*:{
if (!%num) {
set %high $2
set %low $iif($int($calc($2/2)) < %low,$v1,$v2)
}
else .msg $nick Game in progress
}
on *:text:!min &:*:{
if (!%num) {
set %low $2
set %high $iif($calc($2 * 2) > %high,$v1,$v2)
}
else .msg $nick Game in progress
}
on *:TEXT:!num*:#:{
  if (!$2) && (%num) {
    .msg $nick Number Guess Game is Active
    .msg $nick To enter a guess use !num <your guess>
  }
  elseif (!$2) {
set %num on
set %low $iif(!%low,$r(1,$calc($ctime / 2)),%low)
set %high $iif(!%high,$r($calc(%low + 1),$ctime),%high)
var %avg = $r(%low,%high)
    describe # The mystery number is between 4 %low  and 4 %high 
  }
  elseif $2 == %avg {
    describe # congratulates 4 $nick  for guessing the mystery number in 5 $duration($calc($ctime - %start))) 
    inc %num.correct. $+ $nick
    describe # You have now correctly guessed %num.correct. $+ $nick mystery numbers correctly
unset %high
unset %low
unset %num
  }
  else {
    if ($2 >= %low) && ($2 <= %high) { $iif(%avg < $2, %low = $2, %high = $2) }
    describe # The mystery number is between 4 %low  and 4 %high 
  }
}

Comments

Sign in to comment.
jonypaul   -  May 26, 2006

i\'ve got the same prob...but another...i just cant stop the game...what is exactally the comand? cause if i dont stop it i can\'t configure it

 Respond  
masta_killer   -  Oct 20, 2005

yeah umm am i doin something wrong.. it doesnt seem to work
evil_noob The mystery number is between 12858 and 12858

!num 12858 * evil_noob The mystery number is between 12858 and 12858 !num <12858> * evil_noob The mystery number is between 12858 and 12858
 Respond  
RusselB   -  Apr 29, 2005

Thanks for the suggestions xDaeMoN. Code has been modified to accomodate them

 Respond  
xDaeMoN   -  Apr 28, 2005

I said in #1 to put a space because if people would just type !num, there is no output. You have to put a space after the !num when you type it so the script would be triggered.

 Respond  
xDaeMoN   -  Apr 28, 2005

Some prob: 1) There should be no space in !num & * in your text event. 2) You need to set your variables as global instead of local 3) It would be nice to give them a low number to guess instead of 5 figures or make it configurable

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.