new scriptrs try reading this basics of scripting
Post new topic   Reply to topic Forum Index -> mIRC Tutorials
kerstt  -  Sat Mar 17, 2007 6:34 am Reply with quote
Basic tutorial:

As people will notice there are alot of topics in these forums with really basic questions, i want to get rid of those cause with some common sence the scripters most times can do it their self. so i made this tutorial.
So lets get started then will we?
So u got mirc? No? Then go to Here

So u seen loads of bots and want to make one urself? the beginnings iwill explain in this guide! first some basic irc commands u should know
This guide includes
- on TEXT
- Variables
- Alias
- Regex
- If's
- pop up's
- Dynamic variables
- $read .txt

Dont get scared by the names it isnt that hard Smile

/ME message
Tells the current channel or query about what you are doing.
in scripts its /describe #channel

/QUERY nickname message
Opens a query window to this user and sends them a private message.

/MSG nickname message
Sends a private message to this user without opening a query window.
/msg #channel can be used also to message a channel

/NOTICE nickname message
Sends a private message to this user without opening a query window. no other people can read this thats why it's many used in bots

/WHOIS nickname
Shows information about someone. like channels etc

/NICK nickname
Changes your nickname to a new nickname.

/QUIT [reason]
[reason] can be filled with anything as a away message

/INVITE nickname #channel
Invites another user/bot to a channel.

Some others things u need to know

$chan Stand for the channel the script is trigger(trigger is explained below)
$nick Is the person activating the trigger
$me is ur nickname
* is a wildcard who can stand for anything with unlimited charaters (example it can stand for: Hi but also for: fiorhanrur )
? is a wildcard who stand for 1 charater (example: H) So remember LOL in wildcards is or * or ???
if u add a wildcard u can return that information as $numberofword
example hello* and then $2 wil lreturn the word after hello
$2- will return everything from word 2 + behind it
U need to know about brackets! these are very important whenever u open 1 (like: { ) u need to close it again (like: } )
all scripts need to trigger on something u do that like this

Now lets start scripting will we?


Anything here can be(just a short list)
- Text (a text by anyone said)
- Notice (if someone does /notice u)
- Action (a /me command)
There are much more explained later on but these u need to know
So if u want to trigger when someone types hello in the channel #guide it becomes:


if u look good there is a opening bracket { this means u have to close it at the end of the script, with } .
Now we want it to respond messaging the channel, u remember? /msg #channel, thats what we are going to use, $chan stood for the channel where the trigger was activated, we want it to respond Hi, <person who said hello> (so person triggering the script, $nick)
Don't forget the closing bracket!

Lets add that u say ur nick too, remember? $me


If u look good u see i have $nick and then the , that is because if u add those together it wont work! now i show u a new charater: $+ this will delete the space in front and behind it.

Will return the same thing!

$nick will still work if u add a , on it with $+ so lets do that:d


Here i show u the result:
<04mIRC> hello
<04Kerst> Hi, mIRC, i'm Kerst

Now lets work with the wildcards, cause this script will only activate if someone only says "hello" if u add a wildcard at the end of it like this:

It will trigger if someone types Hello <and anything here>
If u put one in front of hello too, it triggers anywhere in a sentence


u can also respond with notice $nick which will make which makes sure only the user getting it will read it, and msg $nick then the person gets it in his pm! u can also add msg $chan and msg $nick under one trigger and also multiple times msg $nick
Example: (a commands script cause everyone needs one)

Now u want a response if someone slaps with the trout!
lets say u want to kick him!
also this will active in all channels cause i just do #
/describe to do /me in the channel ( add a channel too)


u dont need to add ur name cause the describe does that!
i added wildcard (*) between slaps and around cause their stands the name of the person slapping, and that one will always change, thats why we have a wildcard there!

Now to the variables!
As example an simple pest control script
variables contain information which will be saved
commands for variables are:

Set %variablename <what to set to> (this makes a variable)
unset %variablename (this destroyers the variable)
inc %variablename <amount to add> (this counts in numbers as inc %variablename <Amount added> so if u do inc %variablename 5 and then another time inc %variablename 10 then %variablename will be 15 u put %variablename in a script it says 15 now if u just do inc %variablename and no number after it it does +1)
u should know this except the variables if not read again the guide


Now u count how many times !world has been said, and what the world is
Note:Many people try getting the counter up by typing the trigger alot, simply hit in mIRC alt+r go to variables search the variablename and change the number behind it Wink
if u add behind %pccounter a number it will count that number all the time Smile

If u want to learn dynamic variables scroll further.
If u didnt understand any of this, re-read then start with this!

Now we're going further with the set commands with some evaluation brackets
If you want greater control over the order of evaluation of identifiers, you can use the [ ] brackets. Identifiers within these brackets will be evaluated first, from left to right. You can nest brackets.
Example lets make the PCW script multi channel



This will make the variable be created as %pestcontrol#channelname
so u get more variables with all different worlds per channel

So the hello example again:
he [ $+ [ llo ] ] will be hello

ok, aliases, they are EASY if u understanded explained above i'm sure u can do this. u can go remotes and alias section and do like this
/name /what it has to do
u can use $1 $2 $3 thingys in this!
trigger wont count as a word so first word will be $1

This will return message the active chan ur in Yo, words added

Aliases in remotes: (so put this in remotes)
They are commenly used to check things from outside the script, i will explain some simple stuff

Will sound stupid but it goes like that

Now u can do in any of ur scripts /dc and ur scripts will recognize it as disconnect (not very useful but it's an example)

these are used to check things as example i will take a global message
U get another opening bracket then so remember to close it

This will check if the user triggering the command is kerst guide, so no one else can use it, /amsg messages all channels u are in
u have multiple things to check
== equal to
=== equal to (case-sensitive)
!= not equal to
< less than
> larger than
>= larger than or equal to

<= smaller than or equal to
// v2 is a multiple of v1
\\ v2 is not a multiple of v1
& bitwise comparison

isin string v1 is in string v2
isincs string v1 is in string v2 (case sensitive)
iswm wildcard string v1 matches string v2
iswmcs wildcard string v1 matches string v2 (case sensitive)
isnum number v1 is a number in the range v2 which is in the form n1-n2 (v2 optional)
isletter letter v1 is a letter in the list of letters in v2 (v2 optional)

isalnum text contains only letters and numbers
isalpha text contains only letters
islower text contains only lower case letters
isupper text contains only upper case letters

ison nickname v1 is on channel v2
isop nickname v1 is an op on channel v2
ishop nickname v1 is a halfop on channel v2
isvoice nickname v1 has a voice on channel v2
isreg nickname v1 is a normal nick on channel v2
ischan if v1 is a channel which you are on.
isban if v1 is a banned address in internal ban list on channel v2

isaop if v1 is a user in your auto-op list for channel v2 (v2 optional)
isavoice if v1 is a user in your auto-voice list for channel v2 (v2 optional)
isignore if v1 is a user in your ignore list with the ignore switch v2 (v2 optional)
isprotect if v1 is a user in your protect list for channel v2 (v2 optional)
isnotify if v1 is a user in your notify list.

So u do if (<something> <something from above> <something>) {
that sounds maybe a bit messy so
if (3 isnum 2-4) {
that checks if its the number 2,3 or 4 which it of course is then it contineus else it wont activate. u can add also a message to respond with else {
We will take the global script again:


with the else { u open yet another bracket so close that again too!

$regex i will keep this easy, want to have more information about $regex read urza's perfect guide
i'm going to show u $regex for triggers so u dont have to add the script all the time with other triggers i wont explain Why it is like that just to keep it simple Smile
u need to add a $ before * in on so
on $*:text: then u need to add a /^
so on $*:text:/^
Then u can add triggers
u can choose between commands with [ ]
so [!@] will trigger on or ! or @ not !@
u can add trigger with ( and | )
with those u can let it trigger on multiple things
if u have something in the trigger like lal(a|b)
it will trigger on lala lalb BUT NOT ON LAL remember that
then u need to close with /si and close all ( with a same amount of )'s
ON $*:TEXT:/^[!@.](pcw|pc|world)/Si:#:{
will trigger on .pcw .pc .world !pcw !pc !world @pcw @pc @world
^ i know i didnt explain loads just triggers

Simple menu's

Some menu's not real dialogs!

u start with (opening bracket!)


^ is the name
now we add a button.

Very easy and u can try to build now everything together in one script

Dynamic variables:
ok, lets get started with a multi pcw script
To do this with variables u need to safe the variables with the channel and read that.
u do that with dynamic variables and evaluation brackets.
example: %var [ $+ [ "something here" ] ]
With the evaluation brackets i putted with $+ the something here part against the variable without destroying it.
if u change the something here for example $chan it will safe with at the end the channel name.
the beginning will be the same so with a pest control script u can safe it with that name using $chan when typing !world the channel is the same so u do %var[ $+ [ $chan ] ] again
Example script:

u can also use things like $nick and $2
so now we safe the user who setted it:

in variables with multi channels u have variables as:

Thats how u make multi channel pcw.
u can also use the $2 with dynamic variables
Example a counter:

The inc will only count for $2- so the variables will be <%slap the text he added after !slap.>
so u get counters for just 1 person.
of course u can also add normal variables with it, so lets add total slaps.


If u look good u see i used variable %slap again, it wont overwrite cause all other slaps have something behind it, EXCEPT when someone just types !slap. thats why its smarter to still use different names:

make sure u dont change it too something like %slapped or %slap. cause when someone types !slapped or !slap. it will destroy the var Cool
This concludes
->Dynamic Variables<-

$read .txt:
I will not go explain how to read random files in your PC, but i will for some simple .txt in your mirc directory.
lets start with .txt

Basic Commands:
/write writes in a file
$read reads the file
/write -ds Deletes text in a file
$read(.txt,w,$+(*,what to search for,*))

/write .txt Text here
^ that will write in a file and safes it
we will make a 8ball script..thats a script which brings a random answer to a qeustion. first we write the file (in status but also possible to write in scripts)
/write 8ball.txt No
/write 8ball.txt Yes
/write 8ball.txt Maybe
/write 8ball.txt *dies*
nah the dies isnt good so u can do like this:
/write -ds 8ball.txt *dies* now the dies is gone

^thats the script but we will go trough the $read ways
we will use //echo so u it returns in ur status
/echo $read(8ball.txt)

Reads a random line from the file 8ball.txt.

//echo $read(8ball.txt, 24)

Reads line 24 from the file 8ball.txt.

//echo $read(8ball.txt)

reads a random line from 8ball .txt

//echo $read(8ball.txt, s, mirc)

Checks the 8ball file for mirc and retuns that if it's in the file

//echo $read(8ball.txt, w, *yes*)
Searches for yes with wildcards so lalayeslala will trigger too

u can ofcourse also use variables or $2 in search
$read(8ball.txt, w, * %pcworld $+ $chan *)
U can make pcw scripts with .txt too
Little challenge:
Make a Greet Script using .txt and an on/off option with dynamic variables it has to have !setgreet !delgreet !greet on !greet off, post it here if u did it

Final notes:
Dont beg for scripts
Dont leech scripts (copy them for your bot)
Dont post ripped scripts (someone else his script)
Please make all ur scripts urself, it takes long to make a bot, but it feels much better if u do it urself Very Happy
Remember help files are ur friends typ in mIRC /help variables for more explaining on variables

Please comment with any ideas/tips Smile Smile[/i]
BrainBryce  -  Sat May 05, 2007 4:12 am Reply with quote
Wow very nice
Newkronic  -  Mon May 14, 2007 7:20 am Reply with quote
This is great, it should be stickyd
kerstt  -  Mon May 14, 2007 7:36 am Reply with quote
thank you all Smile
kuddus  -  Thu May 17, 2007 11:30 pm Reply with quote
very nice! was very helpful. but i still need a long way to go. and ur this tutorial will definitely help me along the way. thanx again. and do u have anything to suggest me? i am a total newbie and dont know nothing but some kids stuff :s
crazyguy  -  Thu Jun 07, 2007 1:51 pm Reply with quote
This guide helped clear up my problems with variables. Thanks a lot for writing it kerstt. One thing i still don't undetstand though. Where is my mirc directory? I have looked all over to find it, but with no luck. If i search for mirc on my computer do i put it in that area?
ZabuzaMomochi  -  Thu Jun 07, 2007 2:02 pm Reply with quote
crazyguy: in your mIRC client, type //run $mircdir THATS your mirc directory
crazyguy  -  Thu Jun 07, 2007 4:37 pm Reply with quote
Thanks a ton Zabuza Very Happy
ZabuzaMomochi  -  Thu Jun 07, 2007 10:33 pm Reply with quote
no problem Wink
kerstt  -  Fri Jun 08, 2007 12:23 am Reply with quote
thanks alot guys Wink i should update it soon again..
F R E E Z E  -  Sat Jul 21, 2007 10:43 pm Reply with quote
gj Kerst! I saw this on SwiftIRC forums aswell Razz
napa182  -  Wed Jul 25, 2007 8:51 pm Reply with quote
WOW very nice Cool Yeah i vote sticky Exclamation
mr candy  -  Tue Nov 13, 2007 11:12 am Reply with quote
its not fineshed but ive only been programming scripts 3 days and this tutorial has helped an amazing amount and i love you for that

so here it is


its got added var and a text file obviously

idk how to make it not messege the channel if the member hasent set a greeting messege. also it will repeat your nickname because idk how to make it work any other way.

if you could help me touch it up would be rgeatly apreciated:)
guest598594  -  Tue Nov 13, 2007 1:04 pm Reply with quote
i suggest using an ini

when u do !del, ur deleting $2 when it should be $nick, and i organized it betta, but using an ini file, hope it works

Last edited by guest598594 on Fri Dec 14, 2007 3:34 pm; edited 3 times in total
mr candy  -  Tue Nov 13, 2007 1:09 pm Reply with quote
wow thnx man Smile i owe you also these has tuaght me to use if's instead of a hole new command saves space and =less messy:)

Last edited by mr candy on Tue Nov 13, 2007 1:15 pm; edited 1 time in total
mr candy  -  Tue Nov 13, 2007 1:11 pm Reply with quote
double post sorry.
guest598594  -  Tue Nov 13, 2007 1:19 pm Reply with quote
wow that was a quick reply Razz

just click the x to delete ur second post

also, i screwed up, look at the new code
mr candy  -  Tue Nov 13, 2007 1:26 pm Reply with quote
i was eager to see what people though of my first script:P

also the script doesnt work it isnt messeging the channel the greeting messege that was saved and the greeting var is set to on =/a nd ive saved a greeting mesege=/
mr candy  -  Tue Nov 13, 2007 1:30 pm Reply with quote
checked ur fixed one it works fine well the same as before it just dont messege the channel the greeting messege:(
Mudkipz  -  Mon Mar 10, 2008 1:22 pm Reply with quote
You might want add like what the codes would be for certain things like Channel or Time, Or date ect.


Also, Things like time would be $time date would be $date, ect.
kerstt  -  Tue Apr 08, 2008 12:39 pm Reply with quote
there is a updated version around but it still has way too many grammer errors :p
i wrote this when i was half noob myself.
Display posts from previous:   
Post new topic   Reply to topic Forum Index -> mIRC Tutorials All times are GMT - 7 Hours
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.