Banscript, made for my bot on onlinegamesnet
Commands:
$addban
on *:TEXT:$addban *:*: {
if ($Nick isop $chan) {
writeini bans.ini $chan $2 $2
notice $nick $2 Is banned from $chan $+ .
mode $chan +b $2
}
}
on *:TEXT:$bans:#: {
if ($Nick isop $chan) {
notice $nick $+ $chan Bans.
var %c 0
var %t $ini(bans.ini, $chan, 0)
while (%c < %t) {
inc %c
notice $nick $readini(bans.ini, $chan, $ini(bans.ini, $chan, %c))
}
notice $nick $+ %c bans found.
}
else { notice $nick You lack access to $chan $+ .
}
}
on *:TEXT:$delban *:*: {
if ($Nick isop $chan) {
remini bans.ini $chan $2
notice $nick $2 Is unbanned from $chan $+ .
mode $chan -b $2
}
}
on *:TEXT:$kb *:*: {
if ($Nick isop $chan) {
writeini bans.ini $chan $address($2,2) $address($2,2)
mode $chan +b $address($2,2)
kick $2 $chan kickbanned by $nick
}
}
on *:JOIN:#: {
if ($readini(bans.ini, $chan, $address($nick, 2))) {
mode $chan +b $address($nick, 2)
kick $nick $chan Banned.
}
}
Well, please understand I wasn't trying to bust your chops or anything. I just can't stand redundant codes when they can be made better and effective. I'm in NO way an elite msl scripter; there are still people better than I am. I was trying to show you my approach of coding in msl, as well as demonstrate how a script can be done differently to other people who browse this thread. I hope I've been helpful and informative, and that's exactly my purpose of posting here at Hawkee.
Lego, instead of adding and deleting bans with the type 2 address, why not make a variable for $address($2,2) so you don't have to enter the exact address but the nickname to add and delete? Your script can be consolidated as such:
on @*:join:#:{
if $readini(bans.ini,#,$wildsite) {
ban -k # $nick 2 banned.
}
}
on @$*:text:/^\$(add|del)?(bans?)|(kb)\b/iS:#:{
if !%p {
inc -u4 %p
if $nick isop # {
var %type2 $address($2,2)
if $regml(1) = add {
writeini bans.ini # %type2 %type2
notice $nick $regml Is banned from # $+ .
mode # +b %type2
}
elseif $regml(1) = del {
remini bans.ini # %type2
notice $nick $2 Is unbanned from # $+ .
mode # -b %type2
}
elseif $regml(1) = bans {
notice $nick $+ # Bans.
var %c 0, %t $ini(bans.ini,#,0)
while (%c < %t) {
inc %c
notice $nick $readini(bans.ini,#,$ini(bans.ini,#,%c))
}
notice $nick $+ %c bans found.
}
else {
writeini bans.ini # %type2 %type2
ban -k # $2 2 kickbanned by $nick
}
}
else {
notice $nick You lack access to # $+ .
}
}
}
:)