this is a random slap that i made
the command is !slap and it should choose a random message
and i have tryed it and it does work
on *:TEXT:!slap*:#: {
if (%flood [ $+ [ $nick ] ]) { return }
set -eu3 %flood [ $+ [ $nick ] ] $true
msg $chan 4 $nick 3gets ready to slap someone
set %slap $rand(1,6)
if (%slap == 1) msg $chan 3slaps 4 $2 3around a bit with a large trout
if (%slap == 2) msg $chan 3slaps 4 $2 3around the head with a ruler
if (%slap == 3) msg $chan 3slaps 4 $2 3on the head with an eskimo
if (%slap == 4) msg $chan 4 $2 3just go slapped muhahahaha
if (%slap == 5) msg $chan 3slaps 4 $2 $+ 's 3ass
set %kick $rand(1,2)
if (%slap == 1) kick $chan $nick 4I just kicked you out the channel for slapping people
if (%slap == 2) kick $chan $nick 4stop slapping people
}
The reasoning behind Jethro_'s way is to add flood protection, toclafane1 (since he didn't explicitly say so, I will lol). This will protect users of your script from getting hit with flood attacks. Also, with the setup of the lines below the goto, it is very easy to add more lines if you want more than 5 choices.
Bielie, this line of code doesn't make sense:> notice $nick $iif($read(slapreasons.txt),$v1,No slap reason found)How can a stored message not be found? $read(slapreasons.txt) will read any line at random if the text file exists. It should have been:
notice $nick $iif($isfile(slapreasons.txt),$read(slapreasons.txt),slapreasons.txt isn't found)
toclafane, you can do it like so, which will be more safer:
alias -l rgame {
goto $rand(1,5)
:1 | return slaps %2 around a bit with a large trout
:2 | return slaps %2 around the head with a ruler
:3 | return slaps %2 on the head with an eskimo
:4 | return %2 just go slapped muhahahaha
:5 | return slaps %2 $+ 's ass
}
on *:TEXT:$($iif(!slap * iswm $strip($1),$1)):#:{
if (!%fp) { inc -u3 %fp | set -u3 %2 $2 | msg # $rgame }
}
Use /slapreasons (reason) to add slap reasons
on *:TEXT:!slap*:{
if (%flood [ $+ [ $nick ] ]) { return }
set -eu3 %flood [ $+ [ $nick ] ] $true
notice $nick $iif($read(slapreasons.txt),$v1,No slap reason found)
halt
}
alias slapreasons {
/echo writing $1- into the slapreasons.txt file!
/write slapreasons.txt $1-
}