Variables
 

Well we all know what a variable is *I hope* :
if not I will explain, a variable is like an alias its a shorter code representing something bigger.
e.g say in a lot of commands I used

if ($nick isop $chan) halt | if ($nick isowner $chan) halt

and I got sick of writing that. well what I could do is save myself a lot of time by setting a variable. the word variable means it can vary. most variables change (e.g pass codes) but some don’t have to, also it is a temporary storing place for data that is unset at the end of a command.

Anyway back to the problem, you could manually write a Variable (open "Remote" and 2 tabs along *after User List* you will see the tab Variables) now you can write this in:

%opownerhalt if ($nick isop $chan) halt | if ($nick isowner $chan) halt

What this is is everytime you use %opownerhalt it will acrtually be if ($nick isop $chan) halt | if ($nick isowner $chan) halt, time saver ... eh? its cool I know.

That’s basically what a variable is and how to use it.

with codes most scripts have something similar to this.....

raw prop:*ownerkey*: {
/set %pass $3-
}


This sets the Variable %pass with the room code, and every time it is changed %pass will know what it is.


SETTING AND UNSETTING VARIABLES :

ok simple as you have already seen

/set %variablename Data to be stored
/unset %variablename

cant be too hard to understand

Variables are very handy features in mIRC. some people might even want to replace %n and %r with $nick and $chan... ill talk you through a little bit more about variables and how they can be used.

on *:TEXT:.set*:#:/set %$2 $3-

if you have that and someone said:

.set Message The world has come to an end!

this will set a variable called %message representing "the world has come to an end"

*Note* if someone was to say .set Message again it would overwrite the previous variable called %Message

on *:TEXT:. retrieve *:#:/privmsg $chan %$2

if someone was to say .retrieve Message the script would say "the world has come to an end" i think you have got the picture of where i am going with this.

hehehe here is my MassKick stopper again :
 

on @!*:KICK:#: {
  if (%kic. [ $+ [ $nick ] $+ . $+ [ $chan ] ] == $null) {
    set -u8 %kic. [ $+ [ $nick ] $+ . $+ [ $chan ] ] 1
    return
  }
  else { inc %kic. [ $+ [ $nick ] $+ . $+ [ $chan ] ] }
  if (%kic. [ $+ [ $nick ] $+ . $+ [ $chan ] ] > 3 && %kic.check == $null) {
    acces # add deny $nick
    access # add deny $address
    kick # $nick Flood Detected
    set -u6 %kic.check 1
  }
}
 

Now before you read the rest please examine this code and try to make sense out of it.


It is referring to the variable %kic. and it checks if %kic. is $null (nothing in it) and if it is it sets a variable.
this variable will only set itself for 8 seconds, this is a timer. Please read my Timers tutorial for help on Timers and the -u Switch.

now a very popular thing besides making long commands shorter is to increment and decrement Variables. like you see here:

else { inc %kic. [ $+ [ $nick ] $+ . $+ [ $chan ] ] }

the inc %kic. means it is assigning it an added data value of one ( you can use inc 2 %kic. or whatever, it doesn’t have to be one, if you are assigning it one value just write inc %kic. )

Next it is checking if %kic. is greater than 3 :

if (%kic. [ $+ [ $nick ] $+ . $+ [ $chan ] ] > 3 && %kic.check == $null) {

then it checks to see if is null.......( remember it was only written to last 8 seconds ) so basically in English, it means
*
if there have been 3 kicks from the same person in 8 seconds, it executes these commands :

access # add deny $nick
access # add deny $address
kick # $nick Flood Detected
set -u6 %kic.check 1
*


I hope i have increased your knowledge on what variables are used for and the sort of things you can do with them

 

Hosted by www.Geocities.ws

1