Storing/Retrieving Data:

There are multiple ways to store data to a text file...
Add data to file (New Line):
/write -1 myfile.txt data
Add data to file (Select Line):
/write -l5 myfile.txt data
would write the data to line 5

Retrieving Data From Text File:
$read(myfile.txt,5)
Would read line 5 of file (Reads random line if no line is specified)
Search Data:
$read(myfile.txt, w, *finddata*, 1)
Would search the text file for "finddata" anywhere in line... (1 @ end specifies line to start search at/Begining if unspecified)
"*" either side of finddata specifies anything at start/end remove for exact matches...
First you must create a table:
.hmake tablename
To add data to hash table:
hadd tablename dataname data
To increment a number:
hinc tablename dataname
To remove data:
hdel tablename dataname
To delete table:
hfree table
To save table:
hsave tablename table.dat
To load table from file (Table must have been created first):
hload tablename table.dat

Retrieving data from hashtable:
$hget(tablename,dataname)

To add data to an ini file:
/writeini file.ini section subsection data
To retreive data from ini file:
$readini(file.ini,section,subsection)
To count sections/Subsections in an ini
$ini(file.ini,0)
$ini(file.ini,section,0)
To read specified sections/subsections
change "0" to match number you wish to get

Modifying Data:

To replace data in specified string:
$replace(%data,replace.text,replaced.text)
Use $replacecs if you wish the replace to be case sensitive.
To tokenize data so you can use $1 $2 $3 and so on to specify token you wish to select
tokenize 32 data
32 is the chr value you wish to tokenize by 32 (Space)
46 would be "." & 124 would be "|"
To select specified token use:
$getttok(data,1,32)
change "1" to token you wish to select change
"32" to chr value you wish to break by 32 being space (46 is "." & 124 is "|")
To add a token to data use:
$addtok(data,data2add,32)
32 being specified token value to work with
To remove a token from data use: To add a token to data use:
$remtok(data,data2remove,32)
To sort tokens by Alpha/Numeric values use:
$sorttok(data,32)
To count number of tokens in data use:
$numtok(data,32)
Would count how many times space occurs in data




Varibles:

To set global varible (Set forever):
/set %varname data
To unset varible after specified time:
/set -u10 %varname data
would unset varible after 10 seconds.
To increment a number stored in varible (Unset works same as set):
inc %varname 3
would increment number by 3 (Increments by 1 if no number is specified)
To set a custom varible name with code:
/set -u10 %varname. [ $+ [ $mycustomid ] ] data
This must be used exactly as shown or it will not set correctly

Retrieving data from varible :
%varname
on its own recalls data from that var
For varible count (Matching vars)
$var($+(%,varname,*),0)
change "0" to number match you wish to select To read data from a varible
$var($+(%,varname,*),1).value
Change "1" to specified match you wish to select.

Local varibles are to use within containing script/alias.
First you must declare varibles before you use them
var %var1, %var2, %var3, %l
Always include one varible more than you wish to use (Else it dont work correctly)
To set data of local var use:
%var1 = data
just put varname to use specified var in code
you can also use inc to increment a number same as global vars.

On Events

Include "^" before first * to halt mIRC's default echos
* may also be a user level ie:ownerlist, admin
To do something when someone joins channel use:
on *:JOIN:*: {
.echo # $nick > $ial($nick).addr has joined #
}
To do something when someone parts channel use:
on *:PART:*: {
.echo # $nick > $ial($nick).addr has left #
}
To do something when someone talks use:
on *:TEXT:*:*: {
.echo # $nick just said $1-
}
To only activate on specified text use:
on *:TEXT:activating.text:*: {
.echo # $nick just said $1-
}
You can also include * before and after activating text for anything before or after match.
Change last * to # if you want to specify channel text or ? if you wish to specify query text.
Action works exactly the same as on text above. To activate a script when a user is kicked use:
on *:KICK:*: {
.echo # $nick just kicked $knick out of # for $1-
}

Sockets

Sockets are how you communicate with the internet.
Example given would be to get a webpage.
to open socket use:
/sockopen socketname webaddress.com 80
80 is standard http port webaddress.com is site dns name.
put -e before socketname and after sockopen to specify SSL encrypted socket (443 is default https port)
To send data on when socket opens:
on *:SOCKOPEN:socketname: {
/sockwrite -n $sockname GET / HTTP/1.1
/sockwrite -n $sockname HOST: webaddress.com
/sockwrite -n $sockname $str($crlf,2)
}
To read data recieved from socket use:
on *:SOCKREAD:socketname: {
var %read, %l
sockread %read
.echo -a %read
}
To activate script on socket close use:
on *:SOCKCLOSE:socketname: {
.echo -a $sockname has closed
}
Script will not trigger if user used "/sockclose socketname" for socket close
To listen for a connection on a specified port use:
/socklisten socketname 12345
would listen for connections to port 12345.
To accept connections when using socklisten command:
on *:SOCKLISTEN:socketname: {
sockaccept acceptedsockname
}
This will accept the connection giving it the socketname acceptedsockname.
You will have to specify a different accept name for each connection accepted.
You may only use a port once and a sockaccept name once