Number Game

By Warriorii on Aug 26, 2010

This little snippet will let u try and guess a number it has picked in the least amount of guess's. It will also let you know if your to high or to low on each guess, and it keeps the lowest score and the nick. Load it into a clean remote and save it as NumberGame.mrc. It will automatically create a file called highscore.ini and the rest is easy. It isnt much but at least i'm trying, Got to start somewhere hehehe.
Also if u decide to unload it you can click unset switches in the channel menu before you unload it and it will unset the games switches.
Triggers:

  1. !startgame = To start the game
  2. !guessnumber = To try and guess the number
  3. !stopgame = To stop the game
  4. !!help = To play these instructions at anytime.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;      Scripted on 8-1-10            ;;
;;      Updated: 12-9-10              ;;
;;      Updated: 6-13-11              ;;
;;      updated: 12-23-11             ;;
;;      Author Jon_2 AKA Warriorii    ;;
;;      Tested By Luvme4me            ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;You can only play in one channel at a time or all the channels will use the same guess's and scores
;=======================================================================================
on *:load: { echo 12 -a Jon_2's Number Game has been loaded. Type 4 !!help  12 for instructions at any time }
on *:unload: { unset -s %gswitch %tries %rn %guesses %high }
menu channel {
  Number Game
  .List Channel: if ($read numbergame.txt == $null) echo $+ $ja $+ 0,12 No Channel Has Been Set  $+ $ja | else /.play -e numbergame.txt
  ;.List Channel: /.play -e numbergame.txt
  .Check Low Score: if (%high == 50) echo 12 There is no Low Score yet | else echo $ja $+ 8,1 $read(highscore.ini) With %high Guesses  $+ $ja | { halt }
  .Remove User: write -c highscore.ini | unset  -s %high $chan
  .Open Highscore.ini:run notepad $scriptdirhighscore.ini
  .-
  .Send To $$1:send $$1 $script | /msg $chan 12Move NumberGame.mrc To main mIRC dir | /msg $chan 12then type===> 4 /load -rs NumberGame.mrc
  .Unset Switches: unset -s %rn %gswitch %high %tries %guesses
  .Add Channel: {
    if (!$read(numbergame.txt , w ,$chan)) {
      write numbergame.txt $chan
      echo  0,12 $chan added to numbergame.txt 
    }
    else echo 0,12 $chan Is already in numbergame.txt 
  }
  .Del Channel: {
    if ($read(numbergame.txt , w ,$chan)) {
      write -ds $+ $chan numbergame.txt
      echo $ka2 $+ 8,4 $chan Removed from numbergame.txt  $+ $ka2
    }
    else echo $ka $+ 9,1 $chan Is not in numbergame.txt  $+ $ka 
  }
}
on *:text:!numbergame*:#: {
  if (!$read(numbergame.txt , w ,$chan)) { return }
  msg $chan 12For help with triggers type !!help
  if (%high == $null) set %high 50
  if (%gswitch == on)  { msg $chan $ja $+ 8,1 There is a game in progress, Please finish this game first. Type !guess and your number or you can type !stopgame then type !numbergame  $+ $ja | { halt } }
  else set %rn $rand(0,1000) | { set %gswitch on | msg $chan 4 A new game is started. Type !guess and a number from 1 to 1000  | echo 3 -a %rn }
  if (%high == 50) { msg $chan 4Low score and it's owner will be shown at the end of this game. }
  else { msg $chan $ja $+ 8,1 $read(highscore.ini) holds Low Score of %high  $+ $ja }
}
on 1:text:!stopgame:#: {
  if (!$read(numbergame.txt , w ,$chan)) { return }
  if (%gswitch != on) msg $chan $ja $+ 8,1 There is no game to stop :/  $+ $ja
  if (%rn != $null) .msg $chan $ja $+ 8,1 The game has been stopped. The number was %rn $+ .  $+ $ja
  .timermsg1 off
  .timerguess1 off
  .timerguess off
  set %gswitch off | unset %tries | unset %rn | unset %guesses
}
on +1:text:*!guess*:#: {
  if (!$read(numbergame.txt , w ,$chan)) { return }
  inc %guesses
  inc %tries
  if (%gswitch != on) { msg $chan $ja $+ 9,1 There is no game in progress. To start a new game type !numbergame  $+ $ja | unset %tries | unset %guesses | halt }
  .timermsg1 1 60 msg $chan $ja $+ 8,1 Game has auto stopped.  $+ $ja
  .timerguess1 1 60 set %gswitch off
  .timerguess 1 60 unset %tries unset %rn unset %guesses
  if (%guesses => %high) { msg $chan $ja $+ 9,1 Sorry $nick $+ , you did not beat $read(highscore.ini) $+ 's low score of %high   $+ $ja | .timermsg1 off | .timerguess1 off | .timerguess off | set %gswitch off | unset %tries %rn %guesses  $+ $ja | halt }     
  ;if (%guesses => %high) { msg $chan $ja $+ 8,1 Sorry you did not beat $read(highscore.ini) $+ 's low score of %high  $+ $ja  | set %gswitch off | unset %tries | unset %rn | unset %guesses  $+ $ja | halt }     
  if (!$2) { msg $chan 0,4 ALERT!! 0,12MORON IN THE CHANNEL!!0,4 ALERT!! 0 7You must also type a number :/ | halt }
  elseif ($2 > 1000) { msg $chan 12That number is out of range $nick $+ , Please enter a valid number from 1 to 1000 | halt }
  elseif ($2 < %rn) { msg $chan Sorry that number is to low try again $nick | HALT }
  elseif ($2 > %rn) {  msg $chan Sorry that number is to high, try again $nick | HALT }
  elseif ($2 == %rn) { msg $chan $ja $+ 9,1 Congratulations $nick you guessed the number. It was %rn  $+ $ja | set %gswitch off | unset %guesses } 
  .timermsg1 off
  .timerguess1 off
  .timerguess off
  unset %rn
  msg $chan $ja $+ 9,1 You got the correct answer in %tries tries  $+ $ja
  if (%high == 50) { msg $chan 4Creating highscore.ini file and writing 1st low score nick. | write -c highscore.ini $nick | set %high %tries |  .timer1 1 4 msg $chan 12All Finished $nick }
  elseif (%tries < %high) { msg $chan $ja $+ 8,1 $read(highscore.ini) Held old record with %high tries  $+ $ja | write -c highscore.ini $nick | set %high %tries }
  unset %tries  %rn
}
alias ja return 14,5«15,4¤14,5»
on 1:text:!!help:#: {
  notice $nick 1. To start the game type !numbergame | notice $nick 2. To guess the number type !guess your number here | notice $nick 3. To stop the game type !stopgame
}

Comments

Sign in to comment.
dma   -  Nov 12, 2015

i cant get this game to start and i typed everything it said to do... cheers

Sorasyn  -  Nov 12, 2015

It's 5 1/2 years old. I'd imagine it probably needs to be rebuilt.

Sign in to comment

Warriorii   -  Apr 22, 2012

Sorry it took so long to get those timers in there but there in there now and it works fine. Thanks Lucius
for suggesting the timers. I like the way it is now....here's the way i have them.

if (%gswitch != on) { msg $chan $ja $+ 9,1 There is no game in progress. To start a new game     type !numbergame  $+ $ja | unset %tries | unset %guesses | halt }
  .timermsg1 1 60 msg $chan $ja $+ 8,1 Game has auto stopped.  $+ $ja
  .timerguess1 1 60 set %gswitch off
  .timerguess 1 60 unset %tries unset %rn unset %guesses
 Respond  
Warriorii   -  Jan 20, 2011

The Walker, are u using the script in your mirc or a different mirc? if your using it in your mirc and trying to run it from the same mirc it's not going to work. you cant trigger your own script. try putting it in a different mirc, if you have a bot put it in there and try it, because everyone i have talked to says it is working fine for them. i even grabbed this script again and put it in one of my bots and tried it and it worked fine. anyway let me know how it turns out...
this came from my bot that is using the script check and see if they are exact. If they are different try grabbing all of the code again because i have updated it a few times.

menu channel {
  Number Game
  .Set Channel:set %ng #$?"Enter Name Of Channel Here, Without The #" | echo $ja $+ 11,1 Channel is set to %ng  $+ $ja
  .Check Set Channel: echo  $ja $+ 8,1 Number Game will be played in %ng  $+ $ja
  .Check Low Score: if (%high == 50) echo 12 There is no Low Score yet | else echo $ja $+ 8,1 $read(highscore.ini) With %high Guesses  $+ $ja | { halt }
  .Remove User: write -c highscore.ini | unset  -s %high %ng
  .Open Highscore.ini:run notepad $scriptdirhighscore.ini
 Respond  
Warriorii   -  Dec 28, 2010

If your set channel line looks like this then it should work. I have some friends that is using it and it seems to be working great for them.

.Set Channel:set %ng #$?"Enter Name Of Channel Here, Without The #" | echo $ja $+ 11,1 Channel is set to %ng  $+ $ja 

Added some updates: added help at the bottom and fixed it so when there is a new install it will say there is no low score when u first start the game.

 Respond  
TheWalker   -  Dec 10, 2010

Oke is Solved that problem, i have juse the wrong script :s, bute now i gave donwload the correct script, i typ my channelname, bute he don't reacting.

example

Number Game
.Set Channel:set %ng #$? blabla | echo $ja $+ 11,1 Channel is set to %ng $+ $ja
.Check Set Channel: echo $ja $+ 8,1 Number Game will be played in %ng $+ $ja

 Respond  
TheWalker   -  Dec 10, 2010

I have 2 comps, 1 i work on, and 1 for the bot, thats where i placed the script.

 Respond  
TheWalker   -  Dec 10, 2010

The only thing that i have done is to copy te Original script and place it in te remote, without rewritting it.

 Respond  
napa182   -  Dec 10, 2010

hmm did you put it in it's own remote cuz Im not getting a bracket error.
also what one did you put in ur remotes the one the person posted or a rewrite from someones comment?

 Respond  
TheWalker   -  Dec 10, 2010

Hi, I'm new here, I have downloadt the script, but i get a warning when i want to activat it, te warning is: 'There seems to be a bracket miss-match somewhere around line 8''. Can somewhone help me with this, sorry for the bad english.

 Respond  
Lucius   -  Aug 30, 2010

you might want to add in an extra 2 vars. %rnlow 1 %rnhigh 1000
then when they guess too high it changes the high number to the one they guessed and the same for too low.

ex:
%rn = 500
guess 300 ... make %rnlow 300
(msg number is now between 300 & 1000 - so many tries)
guess 550 ... make %rnhigh 550
(msg number is now between 300 & 550 - so many tries)

completely up to you though.
As for unsetting the game if nobody plays for so long, you should use named timers on each command so it resets the timers whenever someone uses a command.
ex:

timer_rn 1 600 msg # game reset through inactivity.
timer_rn2 1 600 unset %rn*
timer_rn3 1 600 unset %tries
etc etc

I don't use timers much so you may have to test it, but to memory it's fine like that, I put 600 for a 10 minute reset.
there is a way to use -u but I can't remember it this early in the morning.

 Respond  
Warriorii   -  Aug 28, 2010

thanks Lucius i'll see if i can add that right now.

I took out the goto's and used the elseif statements
Thanks again Lucius, that looks a lot better without the goto's

 Respond  
Warriorii   -  Aug 28, 2010

Thanks Jethro_

I also added a !stopgame trigger and an !instructions trigger. Probably don't need the instructions trigger but thought i would add it just in case.

 Respond  
Jethro   -  Aug 27, 2010

Very, very nice. Warriorii. It looks much cleaner and organized than before. Keep up the good work.

 Respond  
Warriorii   -  Aug 27, 2010

I took those goto's out you were talking about out, and also used an else statement instead of the "if (%gswitch != on)" let me know what you think, I tested it and it seemed to work fine.

 Respond  
Warriorii   -  Aug 27, 2010

Ok JethrO_ I'll give that a try and see if i can do it right loool Thanks alot for yours and everyones help on this. i'll let ya know if i get it to work. Again thanx

 Respond  
Jethro   -  Aug 27, 2010

Warriorii, judging by your example, you don't need two if conditions really. This is a true or false scenario, so you can just do:

if (%gswitch == on) {
;no need for goto. Just put the routine here
}
else {
set %rn $rand(0,1000)
set %gswitch on
msg %ng 4 A new game has started. Type !guess and a number from 1 to 1,000 Good Luck!
echo 3 -a %rn
}

Again, this suggestion is based on the example of your latest post above.

 Respond  
Warriorii   -  Aug 26, 2010

i see what u mean about the ==on and !=on but they both have to be there because when the game start if the var on isnt in the vars the game wont start... look at it again here. maybe u can understand my bad scripting lol

if (%gswitch == on) goto play
if (%gswitch != on) { set %rn $rand(0,1000) | set %gswitch on | msg %ng 4 A new game has started. Type !guess and a number from 1 to 1,000 Good Luck! | echo 3 -a %rn }

once the switch is on then the goto play skips the line set %gswitch on but on a new game the switch is set to off therefore the second line comes into play. I know u guys know a whole lot more than i could ever start to know or ever will know. i just do this little bit of scripting because i like to script so much and i enjoy your comments and wish i could do it better. thanks and i'll look at it and see if can do anything. but if anyone want to change it and repost it please feel free to do so

 Respond  
WorldDMT   -  Aug 26, 2010

@jethro_ if you want power the dodge is better 425HP bcz my BMW is 300HP

@SunnyD this is an e.g

on *:text:*:%ng:{
  if $istok(!newgame.!guess,$strip($1),46) && %fld {
    inc -u3 %fld
    if $strip($1) == !newgame {
      if (!%high) set %high 15
      if (%gswitch == on) msg %ng $ja $+ 8,1 There is a game in progress, Please finish this game first. Type !guess and your number  $+ $ja
      else {
        set %rn $r(0,1000)
        set %gswitch on
        msg # 4 A new game has started. Type !guess and a number from 1 to 1,000 Good Luck! 
        echo 3 -a %rn
      }
      if ($read(highscore.ini)) msg # $ja $+ 8,1 $v1 holds Low Score of %high  $+ $ja
    }
  }
  else {
    if %gswitch != on {
      msg # $ja $+ 9,1 There is no game in progress. To start a new game type !newgame  $+ $ja
      unset %tries
      halt
    }
    inc %tries
    if $2 == %rn {
      msg # $ja $+ 9,1 Congratulations $nick you guessed the number. It was $2  $+ $ja
      set %gswitch off
      unset %rn
      msg # $ja $+ 9,1 You got the correct answer in %tries tries  $+ $ja
      if %tries < %high {
        if ($read(highscore.ini)) msg # $ja $+ 8,1 $v1 Held old record with %high tries  $+ $ja
        write -c highscore.ini $nick
        set %high %tries
      }
      unset %tries
    }
    else msg # Sorry that number is to $iif($2 < %rn,low,hight) try again
  }
}
alias ja return 14,5«15,4¤14,5»
 Respond  
Jethro   -  Aug 26, 2010

Using goto with a bunch if conditions is deemed inefficient. You either use goto or if statements on its own sparingly. If I were you, I'd use goto in this fashion:

alias test {
  goto $iif(!$1,$null,$iif($1 = 2,yes,no))
  :no
  echo -a blah!
  halt
  :yes
  echo -a Aha!
  halt
  :error
  echo -a * You didn't specify a number 1 or something else!
  reseterror
}

You can put :yes or :no anywhere in the script. Goto jumps from point B to point A and vice versa.

 Respond  
Lucius   -  Aug 26, 2010
on *:text:*!newgame*:%ng: {
  if (%high == $null) set %high 15
  if (%gswitch == on) {  msg %ng $ja $+ 8,1 There is a game in progress, Please finish this game first. Type !guess and your number  $+ $ja | HALT }
  else { set %rn $rand(0,1000) | set %gswitch on | msg %ng 4 A new game has started. Type !guess and a number from 1 to 1,000 Good Luck!  | echo 3 -a %rn
    msg %ng $ja $+ 8,1 $read(highscore.ini) holds Low Score of %high  $+ $ja
  }
}

for example...

The goto play was only needed to skip the if which was actually the opposite of the previous one (you could use else as I did, or leave it there, because the variable cannot be == on (and also) != on.
The goto game was redundant because it was the end anyway, you could just use halt.

same for the !guess trigger with the goto parts. goto is only useful if you need to get to that section of the script from multiple points, if it's only used once, it is easier to do this:

  if ($2 < %rn) goto tolow
  if ($2 > %rn) goto tohigh
  if ($2 == %rn) goto won
  else goto nogame
  :tolow
  msg %ng Sorry that number is to low try again
  halt
  :tohigh
  msg %ng Sorry that number is to high, try again
  halt
  :won
  msg %ng $ja $+ 9,1 Congratulations $nick you guessed the number.   ETC ETC

INSTEAD USE:

if (!$2) { msg %ng You forgot to type a number! | HALT }
  elseif ($2 < %rn) { msg %ng Sorry that number is to low try again | HALT }
  elseif ($2 > %rn) {   msg %ng Sorry that number is to high, try again | HALT }
  else {
    msg %ng $ja $+ 9,1 Congratulations $nick you guessed the number. ETC ETC

I also added in one for if there is no number. You can add that at the start to quick stop it, or let it inc the %tries if you wish first, so it counts as a bad guess.

I tend to put the goto etc command inside unobtainables so I know they will not activate accidentally like this

  if (%ex == %ex2) { goto example }
  if (1 == 2) {
    :example
    blah blah script stuff
  }

hope that wasn't too impossible for you to understand, I know how it can be looking at a different style and feeling lost. (for me it's regex @_@)

 Respond  
Jethro   -  Aug 26, 2010

Nice car, WorldDMT. :P I'm thinking about buying a BMW, but I've also been thinking about the Dodge Challenger SRT8 for a while...Hmmm. Decision..decision...decision!!! :P :P

lol Excuse me for being off-topic. Yeah WorldDMT, show them what you mean by not using the goto command. Remember not every one has the decent knowledge when it comes to MSL. It's best to demonstrate your suggestion rather than just tell them without one.

 Respond  
Sorasyn   -  Aug 26, 2010

@WorldDMT "why use goto command??? you code can be shorter faster and better"

Explain how so, Telling them it could be faster and better doesnt really elaborate itself.

 Respond  
WorldDMT   -  Aug 26, 2010

why use goto command??? you code can be shorter faster and better

u have to add an anti flood and make sure if highscore.ini exist

 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.