# Simple number game

### By Gforce20 on Sep 22, 2007

This is the first piece of IRC code I've made without any help. It needs improvement (i.e. preventing somebody from jumping in at the last second to win), but I'm still just learning. If you have any ideas that would help this script out, please tell. :)

Commands:

!number [number]
Replace [number] with a number, preferrably one that you could reach by counting by 2s and 3s. (don't make it much higher than 100, unless you plan on playinb for a long time.)

!stopnumber
The game starter (whoever said !number) may say this to stop the game and unset the variables.

The idea of this number game is to reach the number stated at the beginning of the game (!number [this one]). Going over the number counts as a win.

Once the game is started, anybody on the channel may say 2 or 3 to add that value to the number. Enjoy!

``````on *:TEXT:!number *:#: {
if (%numgame == 1) { msg \$chan 12Game already in progress. }
if (%numgame != 1) {
msg \$chan \$nick has started the Number Game. Anybody on the channel may play.
msg \$chan 4RULES: You may not take two consecutive turns. Say either 2 or 3 to add that much to the current value. Numbers other than 2 and 3 aren't accepted.
msg \$chan If the game seems to be stuck, the game starter must type !stopnumber. The winner is the one that says the highest number, which in this case is4 \$2 . Going over is acceptable.
msg \$chan 12 The current number is 40
set %end \$2
set %numgame 1
set %currentnum 0
set %ender \$nick
}
}

on *:TEXT:2:#: {
if (%numgame == 1) && (%lastnick == \$nick) { msg \$chan 4You may not take 2 turns in a row!! }
if (%numgame == 1) && (%lastnick != \$nick) {
set %currentnum %currentnum + 2
set %lastnick \$nick
if (%currentnum < %end) { msg \$chan 12The number is now4 %currentnum }
if (%currentnum >= %end) {
msg \$chan 12 \$nick has won!!
unset %end
unset %currentnum
unset %lastnick
unset %ender
set %numgame 0
}
}
}

on *:TEXT:3:#: {
if (%numgame == 1) && (%lastnick == \$nick) { msg \$chan 4You may not take 2 turns in a row!! }
if (%numgame == 1) && (%lastnick != \$nick) {
set %currentnum %currentnum + 3
set %lastnick \$nick
if (%currentnum < %end) { msg \$chan 12The number is now4 %currentnum }
if (%currentnum >= %end) {
msg \$chan 12 \$nick has won!!
unset %end
unset %currentnum
unset %lastnick
unset %ender
set %numgame 0
}
}
}

ON *:PART:#: {
if ( \$nick == %ender ) {
msg \$chan 12The number game has been ended. (Game starter left)
unset %end
unset %currentnum
unset %lastnick
unset %ender
set %numgame 0
}
}

on *:TEXT:!stopnumber:#: {
if ( %numgame == 1 ) && ( \$nick == %ender ) {
msg \$chan 12The number game has been ended.
unset %end
unset %currentnum
unset %lastnick
unset %ender
set %numgame 0
}
}
``````

Jonesy44   -  May 18, 2008

Is this loaded in a second mIRC window?
Sure you loaded the whole script?
Eny errorous scripts above this one?
Are any of the commands doubling up?

wizard38   -  May 18, 2008

How i play this
!number 4 and then.....nothing

vegeto079   -  Mar 08, 2008

Oh, and I forgot to say, you should probably take out those two big blocks of code and put this:

``````on *:TEXT:*:#: {
if (\$1- != 2) && (\$1- != 3) { halt }
if (%numgame == 1) && (%lastnick == \$nick) { msg \$chan 4You may not take 2 turns in a row!! }
if (%numgame == 1) && (%lastnick != \$nick) {
set %currentnum %currentnum + \$1-
set %lastnick \$nick
if (%currentnum < %end) { msg \$chan 12The number is now4 %currentnum }
if (%currentnum >= %end) {
msg \$chan 12 \$nick has won!!
unset %end
unset %currentnum
unset %lastnick
unset %ender
set %numgame 0
}
}
}
``````
vegeto079   -  Mar 08, 2008

There\'s always little sill things you could do to shorten the script. I\'d review it and see if it works, but it seems you need 2 people to play, and nobody else is on right now ;P

``````  if (%numgame == 1) { msg \$chan 12Game already in progress. }
if (%numgame != 1) {
``````

can simply be

``````if (%numgame == 1) { msg \$chan 12Game already in progress. | HALT }
``````

and

``````     if (%currentnum < %end) { msg \$chan 12The number is now4 %currentnum }
if (%currentnum >= %end) {
``````

could simply be

``````if (%currentnum < %end) { msg \$chan 12The number is now4 %currentnum | HALT }
``````
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.