on *:start: {
if ($exists(Hangman.ini)) {
set %hangman.status $readini(Hangman.ini, General, Status)
set %hangman.chan $readini(Hangman.ini, General, Channel)
window @debug | aline @debug INI File was read from.
}
else {
writeini Hangman.ini General Status Offline
set %hangman.status $readini(Hangman.ini, General, Status)
set %hangman.chan $?="What is the name of the channel you want to run this in?"
writeini Hangman.ini General Channel %hangman.chan
window @debug | aline @debug INI File updated.
}
}
on *:text:*:%hangman.chan: {
if ($1 == !hmrun) {
if (%hangman.status == Offline) {
set %hangman.status Online
msg %hangman.chan Hangman is now online, you may start a game with !hmstart | halt
}
elseif (%hangman.status == Online) {
set %hangman.status Online
msg %hangman.chan Hangman is already running, no need to run it. | halt
}
else { notice $me Wrong syntax. Use !hmrun only if bot is offline. | halt }
}
if ($1 == !hmshutdown) {
if (%hangman.status == Offline) {
msg %hangman.chan Bot is already offline, aborting.
halt
}
else {
set %hangman.status Offline
msg %hangman.chan Hangman is now offline, sorry, maybe another time. | halt
}
}
if ($1 == !hmstop) { stop_hangman }
if ($1 == !hmstart) { start_hangman }
if ($1 == !join) {
if (%hangman.status == Online) {
if ($hget(Players,$+($nick,.joined)) = $true) {
msg %hangman.chan Sorry but you already have registered, let other people play.
halt
}
elseif (%players > 3) { msg %hangman.chan We have all 3 players registered and ready to play. Game will begin. | start }
else {
hadd Players $+($nick,.joined) $true
inc %players
msg %hangman.chan $nick has joined the game! We have %players out of 3 to possibly join.
}
}
if (%hangman.status == Offline) {
msg %hangman.chan Bot is not currently running, we will not be accepting players at this time, sorry. | halt
}
if (%hangman.status == Running) {
msg %hangman.chan Hangman is currently running, please wait until the game is over to sign up. | halt
}
}
if ($1 == !guess) {
if ($2 == $null) { msg %hangman.chan $nick Sorry but you need to actually guess the letter (Syntax: !guess <letter>) | halt }
elseif ($2 == A) || ($2 == a) { set %curr.letter $2 | set %curr.letter.guess $reptok(%curr.word.masked,%curr.letter.guess,1,46) }
elseif ($2 == B) || ($2 == b) { set %curr.letter $2 | set %curr.letter.guess $reptok(%curr.word.masked,%curr.letter.guess,1,46) }
elseif ($2 == C) || ($2 == c) { set %curr.letter $2 | set %curr.letter.guess $reptok(%curr.word.masked,%curr.letter.guess,1,46) }
elseif ($2 == D) || ($2 == d) { set %curr.letter $2 | set %curr.letter.guess $reptok(%curr.word.masked,%curr.letter.guess,1,46) }
elseif ($2 == E) || ($2 == e) { set %curr.letter $2 | set %curr.letter.guess $reptok(%curr.word.masked,%curr.letter.guess,1,46) }
elseif ($2 == F) || ($2 == f) { set %curr.letter $2 | set %curr.letter.guess $reptok(%curr.word.masked,%curr.letter.guess,1,46) }
}
alias start_hangman {
if (%hangman.status == Offline) { msg %hangman.chan The bot is not running. If you want to start it up, type !hmrun | halt }
elseif (%hangman.status == Running) { msg %hangman.chan Hangman game is already running, please wait! | halt }
else { set %hangman.status Online | begin }
}
alias stop_hangman {
if (%hangman.status == Offline) { msg %hangman.chan The bot is not running at this moment, sorry. If you want to start it up, type !hmrun | halt }
elseif (%hangman.status == Running) { msg %hangman.chan The current game has been stopped.
set %hangman.status off
unset %player* | unset %curr* | unset %nick*
hfree Players
}
else { halt }
}
alias begin {
if (%hangman.status == Online) {
if ($hget(Players) == $null) {
hmake -s Players 10
msg %hangman.chan Hangman is now started. To participate, please do !join, remember up to 5 people at a time please.
}
else { msg %hangman.chan Hangman is now started. To participate, please do !join, remember up to 5 people at a time please. | halt }
}
elseif (%hangman.status == Running) { msg %hangman.chan Hangman is currently being played. To turn it off type !hmstop. }
else { msg %hangman.chan The bot is offline at the moment, sorry, please try later. | halt }
}
on *:unload: { window -c @debug }
alias start {
set %hangman.status Running | set %curr.round 1
msg %hangman.chan Round %curr.round is now underway and our first word is:
set %curr.word $read($scriptdir\words.txt)
set %curr.word.masked $str($+(_,$chr(32)),$len(%curr.word))
msg %hangman.chan %curr.word.masked
}