I haven't posted or wrote anything in a while and gotten a bit rusty with MSL but I'm back with my first script in a while...even if it is common. And sorry for it being long, forgot a few ways to shorten it.
on *:TEXT:!bomb*:#:{
if ($2 == $null) {
goto self
}
else {
goto other
}
:self
set %bomb on
set %bomb.time $rand(15,40)
set %bomb.nick $nick
set %bomb.color $rand(1,5)
.msg # %bomb.nick has just had a bomb placed in front of them. They have %bomb.time seconds to defuse it! Colors are: 4Red, 12Blue, 8Yellow, 9Green, 13Pink00.
.timerbomb 1 %bomb.time kick # %bomb.nick 4~~~~14BOOOOOOOM YOU DIED4~~~~
halt
:other
set %bomb on
set %bomb.time $rand(15,40)
set %bomb.nick $2
set %bomb.color $rand(1,5)
if ($2 !ison #) { .msg # $2 is not on #. | halt }
else {
.msg # $nick has just had a bomb placed in front of them. They have %bomb.time seconds to defuse it! Colors are: 4Red, 12Blue, 8Yellow, 9Green, 13Pink00.
.timerbomb 1 %bomb.time kick # %bomb.nick 4~~~~14BOOOOOOOM YOU DIED4~~~~
halt
}
}
on *:TEXT:*:#:{
if ($nick == %bomb.nick) {
if (Red == $$1 && %bomb.color == 1) { .msg # Congrats %bomb.nick $+ , you defused the bomb! | .timerbomb off | halt }
elseif (%bomb.color == 1 && Blue == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 1 && Yellow == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 1 && Green == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 1 && Pink == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
if (Blue == $$1 && %bomb.color == 2) { .msg # Congrats %bomb.nick $+ , you defused the bomb! | .timerbomb off | halt }
elseif (%bomb.color == 2 && Red == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 2 && Yellow == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 2 && Green == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 2 && Pink == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
if (Yellow == $$1 && %bomb.color == 3) { .msg # Congrats %bomb.nick $+ , you defused the bomb! | .timerbomb off | halt }
elseif (%bomb.color == 3 && Red == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 3 && Blue == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 3 && Green == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 3 && Pink == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
if (Green == $$1 && %bomb.color == 4) { .msg # Congrats %bomb.nick $+ , you defused the bomb! | .timerbomb off | halt }
elseif (%bomb.color == 4 && Red == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 4 && Blue == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 4 && Yellow == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 4 && Pink == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
if (Pink == $$1 && %bomb.color == 5) { .msg # Congrats %bomb.nick $+ , you defused the bomb! | .timerbomb off | halt }
elseif (%bomb.color == 1 && Red == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 1 && Blue == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 1 && Yellow == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
elseif (%bomb.color == 1 && Green == $$1) { .msg # Too bad... | .timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~ | halt }
.timerbomb off
}
}
not only is it undocumented, it is more than likely unintended too. as tempting as it can be to showcase one's knowledge of little known esoteric parser quirks, we must remember that there is a time and a place for such things :P it's not advisable to demonstrate usage of those quirks without further explanation and a word of caution.
it is not easy to infer, even with context, the meaning of $(,code), the help file does not explain its tendency to evaluate twice when used that way, and it's something that could very likely be fixed in a later version.
once upon a time it was discovered that $(,,code) evaluated 'code' and returned an overall result of $null. this was before /noop and $regsubex() existed, /.echo -q was considered longer and more cumbersome, and $(,, ) appeared to provide a convenient way to use identifiers like $regsub() and $findfile() inline while discarding their result. and it was until, without warning, it was modified to behave similar to $(, code). this broke quite a few scripts and served as a warning: do not get in the habit of using undocumented features, especially if perfectly documented and more readable alternatives exist!
alias -l pwr2kck if $iif($pos(~&@%,$left($nick($1,$me).pnick,1),1),$v1,9) < $iif($pos(~&@%,$left($nick($1,$2).pnick,1),1),$v1,9) { return $true }
on $*:TEXT:/^(!BOMB.*|Red|Blue|Yellow|Green|Pink)$/iS:#:{
tokenize 32 $regml(1)
if !$timer(bomb) && $1 == !bomb {
if $2 == $me { .msg # Nice try $nick $+ , but I $iif($r(0,1),wasn't scripted,didn't fall off the script truck) yesterday! | halt }
set %bomb.chan #
set %bomb.time $r(15,40)
set %bomb.nick $iif($2,$2,$nick)
set %bomb.color $gettok(Red|Blue|Yellow|Green|Pink,$r(1,5),124)
if %bomb.nick !ison # { .msg # $2 is not on # $+ . | halt }
.msg # %bomb.nick has just had a bomb placed in front of them. They have %bomb.time seconds to defuse it! Colors are: Red, Blue, Yellow, Green, Pink.
.timerbomb 1 %bomb.time $!iif($pwr2kck(%bomb.chan,%bomb.nick),kick,msg) # %bomb.nick ~~~~BOOOOOOOM YOU DIED~~~~
}
elseif $timer(bomb) && $nick == %bomb.nick {
if $1 == %bomb.color {
.msg # Congrats %bomb.nick $+ , you defused the bomb!
.timerbomb off
}
else { .msg # Too bad... | .timerbomb -e }
}
}
____________________________________________________________________________________________________________________________________________________________
i think this can be like this
on *:text:*:#:{
if $1 == !bomb {
set %bomb.time $r(15,40)
set %bomb.nick $iif($2,$2,$nick)
set %bomb.color $r(1,5)
if $2 !ison # { .msg # $2 is not on #. | halt }
.msg # %bomb.nick has just had a bomb placed in front of them. They have %bomb.time seconds to defuse it! Colors are: 4Red, 12Blue, 8Yellow, 9Green, 13Pink00.
.timerbomb 1 %bomb.time kick # %bomb.nick 4~~~~14BOOOOOOOM YOU DIED4~~~~
}
elseif $nick == %bomb.nick {
tokenize 32 red bleue yellow green pink $1
if $(,$+($,%bomb.color)) == $6 {
.msg # Congrats %bomb.nick $+ , you defused the bomb!
.timerbomb off
}
else {
.msg # Too bad...
.timer 1 3 kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~
.timerbomb off
}
unset %bomb.*
}
}
PS: not tested i dont have mIRC here
Good job Napa.
I'm just gonna restate that as the total script and make use of .timer -e
and eliminate one of the set variables. Also, need ops to use kick command.
on @*:TEXT:!bomb*:#:{
set %bomb.time $r(15,40)
set %bomb.color $gettok(Red|Blue|Yellow|Green|Pink,$r(1,5),124)
if $2 {
if ($2 !ison #) { .msg # $2 is not on #. | halt }
set %bomb.nick $2
}
else { set %bomb.nick $nick }
.msg # %bomb.nick has just had a bomb placed in front of them. $&
They have %bomb.time seconds to defuse it! Colors are: 4Red, 12Blue, 8Yellow, 9Green, 13Pink00.
.timerbomb 1 %bomb.time kick # %bomb.nick 4~~~~14BOOOOOOOM YOU DIED4~~~~
}
on $*:TEXT:/^(Red|Blue|Yellow|Green|Pink)$/iS:#:{
if ($nick = %bomb.nick) {
$iif($regml(1) = %bomb.color,.msg # Congrats %bomb.nick $+ , you defused the bomb!,.timerbomb -e)
.timerbomb off
}
}
_______________________________________________________________________________________________________
way too much redundancy within the snippet....
you can set the color var like
set %bomb.color $gettok(Red|Blue|Yellow|Green|Pink,$r(1,5),124)
then do the defused part something like this
on $*:TEXT:/^(Red|Blue|Yellow|Green|Pink)$/iS:#:{
if ($nick = %bomb.nick) {
$iif($regml(1) = %bomb.color,.msg # Congrats $&
$+(%bomb.nick,$chr(44)) you defused the bomb!,kick # %bomb.nick 4~~~~14BOOOOOOOM 4~~~~)
.timerbomb off
unset %bomb.*
}
}