Someone requested a !protect and !deprotect script be made for mIRC, so here it is! It uses chanserv to set the +a and -a modes.
I’ve not tested extensively so errors are entirely possible, let me know if you spot any errors or have suggestions for improvements.
Please set the level yourself, this scriptlet is to be used as a guideline i wouldn’t recommend you all stick it in your scripts as everyone has permission to use it! If you wish to restrict it, have it check a users database or make use of mIRC users lists.
; !deprotect, !protect public commands
on *:TEXT:*:#:{
; set max usage, 3 commands in 2 seconds, this prevents people flooding you
hinc -mu2 usedprot max
if ($hget(usedprot,max) >= 3) return
if ($1 == !protect) {
;if already in raw processing, return
if (%pubcmd.prot.busy == $true) {
msg $chan Try again in a few moments.
return
}
; identify that protect was used
set %pubcmd.prot.usedprot $true
; set variable to let script know that a request is currently underway
set %pubcmd.prot.busy $true
; set which channel
set %pubcmd.prot.chan $chan
; set nickname as that specified or use nickname of user
if ($2 == $null) set %pubcmd.prot.nick $nick
else {
if ($2 !ison $chan) {
msg $chan $2 is not on $chan $+ $chr(46)
return
}
set %pubcmd.prot.nick $2
}
.enable #check_a
mode $chan a
}
if ($1 == !deprotect) {
if (%pubcmd.prot.busy == $true) {
msg $chan Try again in a few moments.
return
}
; identify that deprotect was used
set %pubcmd.prot.useddeprot $true
; set variable to let script know that a request is currently underway
set %pubcmd.prot.busy $true
set %pubcmd.prot.chan $chan
if ($2 == $null) set %pubcmd.deprot.nick $nick
else {
if ($2 !ison $chan) {
msg $chan $2 is not on $chan $+ $chr(46)
return
}
set %pubcmd.deprot.nick $2
}
.enable #check_a
mode $chan a
}
}
#check_a off
raw 388:*:{
; Check that this raw event occured
set %pubcmd.prot.388 $true
if ($3 == %pubcmd.prot.nick) {
msg %pubcmd.prot.chan $3 is already protected.
set %pubcmd.prot.isprotected $true
return
}
if ($3 == %pubcmd.deprot.nick) {
cs deprotect %pubcmd.prot.chan $3
set %pubcmd.prot.isprotected $true
return
}
}
raw 389:*:{
; If raw 388 didn't happen (i.e. no +a's)
if (%pubcmd.prot.388 == $null) {
if (%pubcmd.prot.usedprot == $true) {
cs protect %pubcmd.prot.chan %pubcmd.prot.nick
goto end
}
if (%pubcmd.prot.useddeprot == $true) {
msg %pubcmd.prot.chan %pubcmd.deprot.nick is already deprotected.
goto end
}
}
if (%pubcmd.prot.388 == $true) {
if (%pubcmd.prot.usedprot == $true) {
if (%pubcmd.prot.isprotected == $true) goto end
cs protect %pubcmd.prot.chan %pubcmd.prot.nick
goto end
}
if (%pubcmd.prot.useddeprot == $true) {
if (%pubcmd.prot.isprotected == $true) goto end
msg %pubcmd.prot.chan %pubcmd.deprot.nick is already deprotected.
goto end
}
}
:end
.unset %pubcmd.*prot.*
.disable #check_a
}
#check_a END
This script goes in remote, usage is as follows:
!protect
ChanServ sets mode +a nick1
!protect nick2
ChanServ sets mode +a nick2
Same with deprotect. Not much use if you’re not running an mIRC bot, but a nice look into how raw events work if you’re getting into it!
Enjoy.
Leave a Reply