
[ How to use evaluation brackets on a flood protection by CoolMaster ]
 [ Version: 1.0 ]


Evaluation brackets (some ppl call them variable array) are powerfull tool
for mIRC Scripters, and one of the most misunderstood. 

One of most questions on #ScriptsHelp && #Script3rs on PTnet is:

" How can I make a good flood protection? I tried the following code

on @*:text:*:#:{ 
inc %flood 
.timer 1 6 unset %flood 
if (%flood >= 3) { kick # $nick Please don't flood | unset %flood }
}

but this is triggered for all nicks and all channels, if nick Jakininha said 2 lines
and morkonzinho said one i kick morkonzinho! Why this happen?"


The answer is very very simple, the variable %flood is incremented when text
arrieve with no nick or channel specification.


I also see the following flood protection on Scripts:
on @*:text:*:#: {
 if (%flood. [ + [ $nick ] ] == $null) {
   set -u8 %flood. $+ $nick 0
 }
 inc %flood. $+ $nick 
 if (%flood.[ $+ [ $nick ] ] >= 3) {
  kick $chan $nick Please don't flood... | unset %flood. $+ $chan $+ . $+ $nick
 }
}

This example is not 100% eficient, if CoolMaster input 2 lines on #script3rs and
Khaled 2 lines the format of variable are:
%flood.coolmaster 2
%flood.khaled 2
And I ask... And if CoolMaster inpu text on #ScriptsHelp ? the variable are:
%flood.coolmaster 3
%flood.khaled 2

And Coolmaster is kicked from #ScriptsHelp this is wrong because CoolMaster only
input 1 line to #ScriptsHelp ... You get my idea?! If not please test the codes of 
this doc. :]



[ Make a good and powerfull flood protection without errors and good triggering ]

on @*:text:*:#:{
;this event is only triggered if you're op on channel because '@'
if (%flood. [ $+ [ $chan ] $+ ] . [ $+ [ $nick ] ] == $null) {
set -u8 %flood. $+ $chan $+ . $+ $nick 0
;this part of code check if variable %flood.channel.nick exists if not then create
;one with value of 0 and unset automaticaly after 8 seconds (-u8)
}
inc %flood. $+ $chan $+ . $+ $nick 
;here the variable %flood.channel.nick is incremented one unity
if (%flood. [ $+ [ $chan ] $+ ] . [ $+ [ $nick ] ] >= 3) {
kick $chan $nick Please don't flood... | unset %flood. $+ $chan $+ . $+ $nick
;if variable %flood.channel.nick >= 3 kick nick from channel then unset variable %flood.channel.nick
}
}

Without comments is something like this:

on @*:text:*:#:{
 if (%flood. [ $+ [ $chan ] $+ ] . [ $+ [ $nick ] ] == $null) {
   set -u8 %flood. $+ $chan $+ . $+ $nick 0
 }
 inc %flood. $+ $chan $+ . $+ $nick 
 if (%flood. [ $+ [ $chan ] $+ ] . [ $+ [ $nick ] ] >= 3) {
  kick $chan $nick Please don't flood... | unset %flood. $+ $chan $+ . $+ $nick
 }
}

Simple isn't it?!
I explain who variables is seted...
For example we have nick CoolMaster and Khaled on #Script3rs and we have
Goju-Ryu on #your_way, Be-yourself, Watersun and CoolMaster on #raptors.

;If CoolMaster input some think to #Script3rs the variable will have this format:
%flood.#Script3rs.CoolMaster <lines>
;If Khaled input to #Script3rs we have another variable:
%flood.#Script3rs.Khaled <lines>
;If Goju-Ryu input to #your_way we have another variable:
%flood.#your_way.Goju-Ryu <lines>
;If Be-yourself input to #raptors we have another variable:
%flood.#raptors.Be-yourself <lines>
;If Watersun input to #raptors we have another variable:
%flood.#raptors.Watersun <lines>
;If CoolMaster input to #raptors we have another variable:
%flood.#raptors.CoolMaster <lines>

Without comments:
%flood.#Script3rs.CoolMaster <lines>
%flood.#Script3rs.Khaled <lines>
%flood.#your_way.Goju-Ryu <lines>
%flood.#raptors.Be-yourself <lines>
%flood.#raptors.Watersun <lines>
%flood.#raptors.CoolMaster <lines>


Now understand the power of Evaluation Brackets [ ] to a channel flood protection?!
To unset all variables you need to input something like this: /unset %flood.*
The "." are not needed, you can put "-", "_" 
or nothing: %flood#channelNick or whatever you want unless spaces. You can change
the order, you have so many possible ways.



[ Conclusion ]

Evaluation brackets are very usefull not only on flood protection but other 
scripting cases... In some program or Scripting languages variable arrays
are very, very important and used.

Well I want apollogies for my english :) I know it sucks.
Be cool :]


				CoolMaster <coolmaster@PTlink.net>
				http://coolmaster.org 
				You can find me on PTlink <GameOver.PTlink.net> then #Lesbicas or #PHP
				CoolMaster productions (28/03/01 03:04 am)
