This is my anti slapper script. I was getting tired of seeing people make their anti slap scripts and having them spam every time anybody slapped anyone. Pretty basic, just stick it in your remotes, and wait for someone to attack you in some way.
this script will only respond if you are the person being slapped, and will not be set off more than once every 15 seconds to avoid being kicked out of channels for flooding
one of my first scripts, any examples of how I may clean the code up, or make it more efficient will be appreciated
also.....I'm not too sure how to get a script to set a variable to a certain value without it constantly resetting it, which can be bad if the variable was meant to be a certain value but gets reset every time the script is executed, so you may have to type " /set %beat off " to set the variable to its default value before running this script.
on *:action:*:#: {
if (slaps isin $1- ) || (hits isin $1- ) || (whacks isin $1- ) || (wacks isin $1- ) || (attacks isin $1- ) || (kicks isin $1- ) || (throws isin $1- ) && ( $me isin $1- ) {
if ( $me isin $1- ) && ( %beat == off ) { set %beat $rand(1,8) }
if ( $me isin $1- ) && ( %beat == 1 ) { describe # blocks $nick $+ 's attack and beats six shades of shit out of their pets | set %beat on | .timer 1 15 set %beat off | halt }
elseif ( $me isin $1- ) && ( %beat == 2 ) { describe # drops dead on the ground | set %beat on | .timer 1 15 set %beat off | halt }
elseif ( $me isin $1- ) && ( %beat == 3 ) { describe # ducks and takes aim with an M16 | set %beat on | .timer 1 15 set %beat off | halt }
elseif ( $me isin $1- ) && ( %beat == 4 ) { describe # $replace( $1- , $me , $nick ) | set %beat on | .timer 1 15 set %beat off | halt }
elseif ( $me isin $1- ) && ( %beat == 5 ) { describe # throws rocks at $nick | set %beat on | .timer 1 15 set %beat off | halt }
elseif ( $me isin $1- ) && ( %beat == 6 ) { describe # beats $nick like a red-headed step child | set %beat on | .timer 1 15 set %beat off | halt }
elseif ( $me isin $1- ) && ( %beat == 7 ) { describe # gets up off the ground and roundhouse kicks $nick in the face | .timer 1 15 set %beat off | halt }
elseif ( $me isin $1- ) && ( %beat == 8 ) { describe # does an evasive backflip and throws ninja stars at $nick 4,1 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ $nick 4,1 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ | .timer 1 15 set %beat off | halt }
}
else { halt }
}
look in to while loops and tokens you can use them to make this script into somthing like this
on *:action:*:#:{
var %sl = slaps,hits,whacks,wacks,attacks,kicks,throws, %x = $numtok(%sl,44)
while (%x) {
if ($istok($1-,$gettok(%sl,%x,44),32) && $me isin $1- && !%spam) {
var %ap blocks $nick $+ 's attack and beats six shades of shoot out of their pets|drops dead on the ground|ducks and takes aim with an M16|beats $nick like a red-headed step child|gets up off the ground and roundhouse kicks $nick in the face|does an evasive backflip and throws ninja stars at $nick ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ $nick ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤|throws rocks at $nick
describe # $gettok(%ap,$r(1,7),124)
set -u15 %spam on
}
dec %x
}
}
or you can do
on *:action:*:#:{
if ($regex($1-,/(slaps|hits|whacks|wack|attacks|kicks|throws)/i) && $me isin $1- && !$($+(%,spam,.,$nick),2)) {
var %ap blocks $nick $+ 's attack and beats six shades of shoot out of their pets|drops dead on the ground|ducks and takes aim with an M16|beats $nick like a red-headed step child|gets up off the ground and roundhouse kicks $nick in the face|does an evasive backflip and throws ninja stars at $nick ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ $nick ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤|throws rocks at $nick
describe # $gettok(%ap,$r(1,7),124)
set -u3 $+(%,spam,.,$nick) on
}
}