kaitnieks.com  
Online Cheating Cheating in RS and other stuff
SCAR > Scripting tutorial

Contents
Main Page
News
SCAR
  This section
  Scripts
  Scripting standards
  Scripting tutorial
  Examples
AutoRune
SleepWalker
RS cheats
Testējam
Awaa1
Awaa2

Search

 
Scripting tutorial (0)

SCAR scripting tutorial by Khain
This section is for people who are willing to write SCAR scripts themselves. It's written by Khain. I got to say I found it in web accidentally.
 
|How to become a (basic) SCAR scripter by Khain v1.0 - put in html format by Random Hero aka Ghostmagem :)|
===============================================
~~~~~~~~~~~~~~~~~~Index~~~~~~~~~~~~~~~~~~~~
===============================================
1.0 Starting out
~~1.1.0 So you want to learn scripting?
~~1.2.0 The Basics
~~~1.2.1 Comments
~~~1.2.2 Program name
~~~1.2.3 Variables
~~~1.2.4 Constants
~~~1.2.5 Procedures (The Basics) Part 1
~~~1.2.5 Begin and end
~~~1.2.6 Repeat and until
~~~1.2.7 Procedure (The Basics) Part 2
~~1.3.0 1+1=Script; Putting one and one together

2.0 Procedures
~~2.2.0 RS2 universal procedures
~~2.3.0 Bitmaps! OMFG!!!one!!!!

3.0 Functions
~~3.1.0 RS2 most used functions



================================

*1.0 Starting out
================================

Welcome to the ultimate scripting guide. While going through this tutorial you will discover that not only are you learning the basics of SCAR scripting. But you're also learning how to shape your image, make yourself more professional looking, get familiar with different terms and evolve your own scripting style!
Don't complain to me saying pascal is hard, O please teach me this and that. HELP! Pascal is easy! Here is a conversation I had with a dude named Tezza at my scripting help channel #ScriptHelp

(18:29:45) (@Khain) you should start out as i did
(18:29:52) (@Khain) look at other peoples scripts
(18:29:53) (@Khain) easy
(18:30:05) (@Khain) pascal is like picking ur nose
(18:30:14) (@Khain) first your like all noob and you bleed and shit
(18:30:18) (Tezza) wot will that do
(18:30:20) (Tezza) lol
(18:30:20) (@Khain) but after a while you get better
(18:30:23) (Tezza) lmfao
(18:30:26) (@Khain) and don't bleed
(18:30:34) (@Khain) and you learn how to flick the boogers
(18:30:40) (@Khain) at great distances
(18:30:42) (Tezza) roflmao
(18:30:43) (@Khain) :D

I recommend going through the SCAR help file before reading this tutorial as that is the only place where you can learn the basic SCAR only functions. HIT F1 While in SCAR to bring up the help file

Enough talking! Let's get started.



================================

1.1.0 So you want to learn scripting?

================================

Bloody hell, how to start? Well you might want to start with grammar. Grammar is quite important in being taken seriously. 1337 talk and name calling is another thing, "liek wh47 uP? h0m0 g4y 4ssz0rz" <- a good example of what not to do
while creating an image for yourself. So I would spend some time working up your writing/social skills.

Think of grammar as a first impression based upon what clothes ur wearing. If you can't write properly, people will at once see your post and most probably will think you are no older than 11 or from some third world country with a poor education.

If you suck at English then it's about time to get better. No excuses, I'm half Brazilian, half Norwegian and was born in Thailand. I have never lived in any English speaking countries, yet that hasn't stopped me! English is spreading fast and is the most used international language, trust me, if you learn it your parents will be proud of you. Ok so now your thinking "Hell yeah, time to pull open up an online dictionary and script!". Whoa, calm down there buddy. Before you continue I've written a list of things you might want to do, and a list of things you might want to avoid.

What you want to do/have:
- Have some mannerism, nothing beats a polite person. This will make you special, since there is a handful of these in this

community
- Good English skills, you could keep an online dictionary open when writing posts or other...
- Try to be objective, Se things from a point of view where your thoughts on the manner is not affecting your decision
- When criticizing make it constructive not destructive or negative
- Help people, help the community. I promise you, sooner or later it will pay off. You'll make lots of friends and your popularity will grow.

What you most probably don't want to do:
- Spam and flame
- Negatively Criticize other people or their work
- Don't Judge people too quick, this can easily back fire on you! And it won't look good.

Ok so now you know what is needed to make an "alright" image. Next step, are you ready for it?

Are you ready for it? Will you be willing to:
- Dedicate endless hours scripting editing testing failing and failing again?
- Contribute to the community? How can you not right? After all this community created you, and you are not going to share?

How dare you call yourself a scripter if you don't share your work? If you do so your title should be changed from scripter

to script-leacher
- Read and read and do some more reading?
- Learn, learn and some more learning?

If not I advise you to go no further. Stop right here and leave.....
.....
......
.......
..........
.............
Oy!? So you still want to learn scripting eh? Ok let's move on then :)



================================

1.2.0 The Basics
================================

You think: "Finally Khain shuts the fuck up and starts teaching me scripting!", Yeah ok. But don't forget what I've said, it will come in handy. Basics? how about starting with terms and commands? I think we'll do that.

To keep on track, lets make a list of what we are going to be viewing:
- Comments
- Program name
- Variables
- Constants
- Procedures (The Basics) Part 1
- Begin and end
- Repeat and until
- Procedure (The Basics) Part 2

Take it from the top, shall we?


================================

1.2.1 Comments
================================

We use comments in scripts to explain things, make a introduction and it's a good way of keeping track of things in a script.

There are two ways of defining comments in SCAR. The first one on the list is // When writing // before a sentence in a script everything on that line will become a comment. SCAR will then automatically make the line italic, in a way conforming that this line is indeed a comment.

Second comment command is {}
{ tells SCAR to commence a comment command. } Tells SCAR execute a comment command. Example of usage: {This script is made by UberNewbie ^_^}

Easy, no? Onwards


================================

1.2.2 Program name

================================

A program name isn't needed, you can decide if you want to use it or not. It should be one of the first things in your script. The only thing that can be written before program name are comments, this is of course only valid if you use a program name at all.

To use program name all you have to do is write:

Program NameOfYourScript;

And yes the semicolon is needed. Without it you will get an error. Spell the name of your script in one word no spaces no commas/dots only letters and numbers.


================================

1.2.3 Variables
================================

Oy! don't have a heart attack now. A Variable is like a bank, it can store numbers/values/figures as Integers and it can store characters, sentences as strings for later usage. Easy enough, "How can I get to using them then?" You say. Well before you use any variables you have to tell SCAR "Oy! by crikey I'ma use these variables in this script! you hear, you vagina?".

Well SCAR won't recognize that sentence so we have to simplify it :P


{Comments blah blah!}

program PlsDaddyPls;

Var                   // Let me use some variables please
x,y: Integer;        //  I would like to use variables x and y as integers please
ShoutOut: String;   //   I would like to use ShoutOut as a string pretty please


There we go, as easy as giving away your anal virginity to a drunken pedophile.
As a general rule the variables x and y will are set aside for the horizontal and vertical co-ordinates (coords) of the mouse. x=horizontal y=vertical.


================================

1.2.4 Constants
================================

A Constant is a variable that never changes, It stays constant throughout the whole script, all you have to do is set it's values. And this is how you do it:

CODE

{Comments blah blah!}
program PlsDaddyPls;

Const                    // Let me use some constants please
Times = 10;             //  I want the variable Times to always equal/be 10

Var                   // Let me use some variables please
x,y: Integer;        //  I would like to use variables x and y as integers please
ShoutOut: String;   //   I would like to use ShoutOut as a string pretty please


The understanding of variables is crucial in learning how to script. So study this well and move on when you are confident on your knowledge.


================================

1.2.5 Procedures (The Basics) Part 1

================================

Procedures are what scripts are build up of. A procedure is a set of "instructions" that performs a specific task that can be called upon, that and makes your script neat and tidy :D A procedure is a mixture of functions. To write a procedure. We start out with the procedure name. This is used just like "program name".

CODE

procedure HereIsWhereIPutMyProcedureName;


Spell the name of your script in one word no spaces no commas/punctuations only letters and numbers.

================================

1.2.5 Begin and end

================================

After the procedure name, you MUST tell SCAR where the action begins. To set a limit for each actions you use begin and end;
Begin is used when you want the action to begin, and end; when you want the action to end

CODE

procedure DoSomething;
begin
//Here is where all the code that you want to performed should be entered
end;


Heh, you should pat yourself on the back! You are getting close to being able to write your very own first script! wow! Now get your butt off that chair. Go to the chicken, feed your mind, give it some milk and cookies, or some sugar if you have to, but make sure you are refreshed when you return. You don't want to stress yourself. Now one thing you need to know. If there is a beginning, there must be an end. If there is an end, there must be a beginning. You don't want to screw that up! Also, another thing is, in the main part of the script, there will be a "main begin" and a "main end" these don't differ from the regular begins and ends other than that the end, instead of containing a semicolon it will have to contain a punctuation! So instead of end; it will be end. This usage will be explained in greater detail in "Procedures part 2" so just relax take a breather, take it easy. :)

================================

1.2.6 Repeat and until
================================

You've probably asked yourself. What are the basics of autoing? Well, quite simply, it's just actions/tasks, being repeat over and over again! So eventually you will have to learn how to make a script loop. And that time is now my friend! Come, come.

Look here. It's really quite simple.
CODE

repeat
//Here is where all the code that you want to performed should be entered
until(false)  // you can set a limit for the repeats. how many repeats, when to stop repeating etc.


Until(false) will repeat in a never ending loop.

Now how can I set a different limit for my repeat? I don't want it to repeat forever! :'(
Well that is easy. If you want a script to stop after a certain amount of time. all you have to do is use a variable, that will do a simple math procedure just adding itself for every repeat, making the variable higher for every time. This way you can keep track of how many repeats you want it to perform

Here is a whole program, it doesn't do anything but that's ok. It's just so you get an idea of what to do, and you'll get to repeat some of our old topics... Things we have already been through.

CODE

program TheRepeater;
var
c: integer;

//This is where the main part of the script starts
begin
c:=0;        // this sets the value of the integer c to 0
repeat       // begin a repeat
//Here is where all the code that you want to performed should be entered
c:=c+1;     // This is the crucial part. It simply just does an addition. "Whatever c equals, add +1 to it
until(c>5)  // The script will now repeat your code, until the variable c is higher than 5.
end.        // As we discussed, the end in the main part of the script must have a punctuation mark at the end.


As you may have probably already noticed. Here the until function is slightly different. Don't get confused, that's a good thing, because now he have a limit for our repeat. It will only repeat until c is higher than 5. Which basically means it will repeat 6 times.

Now that that has been explained, onwards. Next thing we want to do is, make a script repeat until a function has been performed. Which is so simple, You'll be surprised! First things first. If you haven't checked out the SCAR functions, you
should. Hit F1 in SCAR and go through the help file. Read it well, and try to understand some of the functions.

When your done look at this code below

CODE

begin
repeat      
//Here is where all the code that you want to performed should be entered
until(findbitmap(mybitmap,x,y))  
end.      


This should be getting easy for you now. The script will now repeat until it finds the bitmap "mybitmap" and will store the coords once found in the x and y variables.

Heh, good job might I say. You have stuck with me so far. What's that? easy? Yeah it's easy as hell, but this is just basic stuff.


================================

1.2.7 Procedure (The Basics) Part 2
================================

Seriously... I'm getting bored of all this talking. And I'm sure you are too, so let's just get straight to the point, straight to the code.

How to create the main part of a script

CODE

begin // main begin
// one normally sets all of ones variables at the beginning, examples are below
x:=20; // set x to 20
y:=40; // yeah ^
ShoutOut:='Hi2u I am a flaming poopy head' // The string shoutout will now contain the text that we entered in between the ''
Loadingbitmaps; // If you use bitmaps in your scripts you have to remember to load them or you will get an error;)
// now that you have set out your vars some code can start
Login;     // This is a procedure that you leave out of the repeat, because you don't want it to repeat all the time.
repeat  // Of course we repeat!
// Here I call upon my main procedures
Talk;
LoginCheck;
until(false)  // Repeats constantly and never ending, thus our macro comes to life
end. // main end


You see this?
Login;
Talk;
LoginCheck;

All these are procedures being called upon (they are called upon in order, from top to bottom). First it calls upon the procedure Login, which would look something like this:

CODE

procedure Login;
begin
click(here)
wait(110)
click(there)
wait(150)
repeat
wait(1000)
until(getcolor(123,423)=234194) // get color number 234194 at coordinates 123(x) and 423(y)
end;


This is not actual code just an example. After the Login; procedure has been completed it goes on to the next procedure on the list which is Talk; , Talk; would look something like this:

CODE

procedure Talk;
begin
SendKeysSilent('I take it in the bum for geepeez'+chr(13)) // '' is the text, + = also, send character 13 (enter)
wait(1000)
end;


Now you have yourself a auto whore talking script :D but, if you want to advertise your services all day, you might logout, so this is the part where you have a script that checks if your logged in, and it should look something like:

CODE

procedure LoginCheck;
begin
 If(getcolor(312,125)=32322) and (getcolor(300,190)=36772) then // IF I get color and get another color at the coords THEN!
   Login;  
end;


This will check for certain colors that only are in the login screen, and if they find it, the procedure Login; is called upon, if not, it won't be called upon. IT WILL SEEMS STRANGE HAVE TO DIFFERENT LOGIN PROCEDURES FOR MORE ADVANCED SCRIPTERS BUT AS I'VE STATED, THIS IS ONLY FOR EXAMPLE PURPOSES AND IS A EASY WAY TO INTRODUCE THE IF FUNCTION AS WELL AS CALLING UPON OTHER PROCEDURES WHEN ALREADY IN A PROCEDURE.

One thing you have to always keep in mind is that a procedure can only be called upon if it is above the line from which the procedure is called upon. So here the script would have to look something like this:

CODE

program horetalker;

procedure Login;
begin
click(here)
wait(110)
click(there)
wait(150)
repeat
wait(1000)
until(getcolor(123,423)=234194) // get color number 234194 at coordinates 123(x) and 423(y)
end;

procedure LoginCheck;
begin
 If(getcolor(312,125)=32322) and (getcolor(300,190)=36772) then // IF I get color and get another color at the coords THEN!
   Login;  
end;

.....etc


YOU WILL RECIEVE AN ERROR IF YOU TRY CALLING UPON A PROCEDURE THAT IS BELOW THE LINE YOU FROM WHICH THE PROCEDURE IS CALLED UPON. It can be called ANYWHERE as long as it's above the line calling the procedure.

This will give you and error:

CODE

program horetalker;

procedure LoginCheck;
begin
 If(getcolor(312,125)=32322) and (getcolor(300,190)=36772) then // IF i get color and get another color at the coords THEN!
   Login;  
end;

procedure Login;
begin
// blah blah blah
end;


So remember what I've said, never call a procedure that is not above from where it is being called.



================================

1+1=Script; Putting one and one together
================================

This is a short chapter and we will just cover how a working "example" script is put together. We will be introduced to some new functions and reviewing code from previous lessons as a full and working script, where each procedure works together creating a macro.

CODE

program horetalker;
var
x,y: integer;
InTheBum: String;

procedure Login;
begin
click(here)
wait(110)
click(there)
wait(150)
repeat
wait(1000)
until(getcolor(123,423)=234194) // get color number 234194 at coordinates 123(x) and 423(y)
end;

procedure LoginCheck;
begin
 If(getcolor(312,125)=32322) and (getcolor(300,190)=36772) then // IF i get color and get another color at the coords THEN!
   Login;  
end;

procedure Talk;
begin
SendKeysSilent(InTheBum+chr(13)) // The string inthebum then hit enter
wait(1000)
end;

procedure walkaround;
begin
x:=447+random(100)  // variable x = 447 plus a random number of 1 to 100
Y:=235-random(50)   // variable y = 235 plus a random number of 1 to 50
movemouse(x,y)      // move mouse to the coordinates x and y which are random
wait(100)
clickmouse(x,y)     // click mouse on the random x and y coordinates
end;

begin
InTheBum:='I take it in the bum for geepeez'
Login;
repeat
Talk;
LoginCheck;
walkaround;
LoginCheck;      // Alternating the login check so it checks after every action
until(false)
end.


That's that, your first look into compiling a script. Keep in mind that this is just an example script and it won't actually do anything or compile for that matter if you put it in SCAR. Look well through the script, learn the new function and get the whole feeling of how a script is built up. When you think you are ready, proceed to the next chapter.



================================

*2.0 Procedures
================================

2.2.0 RS2 universal procedures
================================

Straight forward code for procedures you can use in your own scripts. Remeber to give credit to the creator.

CODE

Complete Banking script, just copy and paste it into any script you have that needs banking. remember to edit it to fit your needs

http://www.rscheatnet.com/forums/index.php?act=ST&f=37&t=25551


CODE

procedure Flagwait;
begin
  repeat
   wait(500+random(100));
  until(not (FindBitmapIn(flag,x,y,562,9,751,179)));
   wait(100+random(100));
 end;

The bitmap:

  flag := BitmapFromString(8, 15,
      '000000000000000000000000000000000000FF00005D3311000000' +
      '000000000000000000000000FF0000FF00005D3311000000000000' +
      '000000000000FF0000FF0000FF00005D3311000000000000000000' +
      'FF0000FF0000FF0000FF00005D3311000000000000FF0000FF0000' +
      'FF0000FF0000FF00005D3311000000FF0000FF0000FF0000FF0000' +
      'FF0000FF00005D3311FF0000FF0000FF0000FF0000FF0000FF0000' +
      'FF00005D3311000000000000000000000000000000000000C65604' +
      '5D3311000000000000000000000000000000000000C656045D3311' +
      '000000000000000000000000000000000000C656045D3311000000' +
      '000000000000000000000000000000C656045D3311000000000000' +
      '000000000000000000000000C656045D3311000000000000000000' +
      '000000000000000000C656045D3311000000000000000000000000' +
      '000000000000C656045D3311000000000000000000000000000000' +
      '000000C656045D3311');


CODE

Look in the previous chapter for two self made functions. Random wait and Mouse.


CODE

procedure FindTextSpiral(txt: String; dx,dy: Integer; SpiralSize: Integer; step, SpiralWait: Integer);  // By OhDearUrDead,

Edited By Khain
var px, py, qx, qy: Integer;
   FoundText: Boolean;
begin
 FoundText:= false;
 px:= dx; py:= dy; qx:= dx; qy:= dy;
 x:= dx;
 y:= dy;
 MoveMouseSmooth(x,y);
 repeat
 Spiralwait:= Spiralwait+random(50);
   MoveMouse(x,y)
   px:= px + 20; py:= py + 20;
   qx:= qx - 20; qy:= qy - 20;
   repeat
     getmousepos(x,y)
     x:= x + step;
     MoveMouseSmooth(x,y);
     Wait(SpiralWait);
     if(IsTextAt2(9,9,txt,100))then FoundText:= true;
   Until(x >= px)or(FoundText);
   if(FoundText)then Break;
   repeat
     getmousepos(x,y)
     y:= y + step;
     MoveMouseSmooth(x,y);
     Wait(SpiralWait);
     if(IsTextAt2(9,9,txt,100))then FoundText:= true;
   Until(y >= py)or(FoundText);
   if(FoundText)then Break;
   repeat
     getmousepos(x,y)
     x:= x - step;
     MoveMouseSmooth(x,y);
     Wait(SpiralWait);
     if(IsTextAt2(9,9,txt,100))then FoundText:= true;
   Until(qx >= x)or(FoundText);
   if(FoundText)then Break;
   repeat
     getmousepos(x,y)
     y:= y - step;
     MoveMouseSmooth(x,y);
     Wait(SpiralWait);
     if(IsTextAt2(9,9,txt,100))then FoundText:= true;
   Until(qy >= y)or(FoundText);
 Until(px > dx + SpiralSize)or(FoundText);
end;


CODE

This procedure uses the rwait function!

procedure logout;
begin
  writeln('LOGGING OUT');
  rwait('short');
  //x:=x+645+random(10)
  //y:=y+470+random(20)
  Mouse(645,470,'left',10,20);
  rwait('long');
  x:=584+random(123)
  y:=364+random(23)
  MoveMousesmooth(x,y);
  repeat
  rwait('short');
  ClickMouse(x,y,true);
  rwait('long');
   until(GetColor(387,243)=65535)
end;


CODE

Can't remeber who made it, but it's edited by me. So you can just not put any credits if you'd like.

Text between §§ needs you to enter you're own text

Add ST:LongInt; and banked: integer; to your vars, Add banked:= banked + 1; to your banking procedure for keeping count of times banked.

Procedure PrintProgressReport;
var
RHours,Minutes,Seconds,RMinutes,RSeconds,avtime:LongInt;
Time:String;

Begin
  Seconds:=(GetSystemTime-ST) div 1000;
  Minutes:=Seconds div 60;
  RHours:=Minutes div 60;
  Time:=inttostr(Seconds)+'seconds';
  avtime:=Seconds/banked;
  if Minutes<>0 then
     begin
       RSeconds:=Seconds Mod (Minutes*60);
       Time:=inttostr(Minutes)+' minute(s) '+inttostr(RSeconds)+' seconds ';
     end;
  if RHours<>0 then
     begin
       RMinutes:=Minutes Mod (RHours*60);
       RSeconds:=Seconds Mod (Minutes*60);
       Time:=inttostr(RHours)+' hour(s) '+inttostr(RMinutes)+' minute(s) '+inttostr(RSeconds)+' seconds';
     end;
  writeln('|==============Script Name================|');
  writeln('|PROGRESS REPORT:');
  writeln('|Worked for '+Time+'');
  writeln('|§mined/cut/thieved etc§ and banked '+inttostr(banked)+' time(s) '+inttostr(banked*§amount if items that are banked each time§)+' '§Item at hand§');
  writeln('|Currently Averaging '+inttostr(3600/avtime*§amount if items that are banked each time§)+' '§Item at hand§' per hour');
  writeln('|=========================================|');
End;


If you have any procedures or functions you'd like to add contact me and we'll hook it up.

NOT YET COMPLETED



================================

2.3.0 Bitmaps! OMFG!!!one!!!!
================================

Because I don't feel like it. I won't be explaining how to use regular bitmaps in scripts. For starters, to get things clear bmp = bitmap. to make a bmp of an image, find that image on rs and take a screenshot. Do this by hitting the Print screen button(above insert to the left of scroll lock, to the right of F12, may vary). After that open up your paint program and paste in, you can just do Ctrl + v. Crop down the image. And by that I mean make the image smaller. You don't have to use the entire object of what you need a bit map of. A helpful tool for trimming down the image, if you are using paint (Microsoft [ms for short] Paint) Is the Zoom feature, with it you can zoom in and do minor adjustments to the image. For example. If I'm using the image of a/some word(s). I usually use 2-3 maybe even 4 letters that are specific to that/those word(s). And I'll use the top pieces of those letters. Not the whole letters. Yet still, it should be unique.

See below for some example images.


http://www.mof0.org/Khain/Scripts/Incomple...cmQuickBank.bmp

http://www.mof0.org/Khain/Scripts/Incomple...mQuickBankY.bmp


Notice also that to make an area transparent. Meaning, to make SCAR ignore a area of the bitmap, color it black (hex code 0). So in my example of the letters. I would use black as a background color, thus telling SCAR that I don't matter what the background color is. As long as the letters are correct!

Save your image to any directory. Now open up SCAR. and Look at the toolbar. See the Script menu. Click it, the drop down menu will appear, look at it and notice the "Picture to string" feature. That's what we want to use. Click it, find the directory you save your bmp in and open it. SCAR will automatically create the image in string form (The hex code of the image) in the debug window.

So now you're thinking, "What shall I do with this shit?" well first we declare an integer. What name did you save your bmp as? Because, notice that in the debug window the code starts as NameYouGaveToYourBitmap:= Basically it means that the name of your bitmap is an integer, and it equals the picture in string/hex code. So we need to create that variable.

So...

CODE

var
NameYouGaveYourBitmap: integer;


or for example, I named my bmp quickbank.

CODE

var
quickbank: integer;


With that done copy the code to wherever you need it. If you have a Loadbitmaps Procedure or something similar you just paste it into there. Like in the example below:

Procedure
begin
quickbank:= BitmapFromString(1, 2, '5C3A20857622');
end;

Most times though. The string code will be much larger than above. Don't worry though, as long as you straight forward copy and paste the code it should go well. And don't worry about the hex code, you don't need to know anything about what it stands for or anything.

That's it. Now you can use your bitmap in for example the findbitmap function!



================================

*3.0 Functions
================================

In SCAR, there are a lot of neat little coded functions. You can of course also make your own. And in this guide we'll be covering both aspects of the functions. But first... What is a function? And how can I make it work for me? I advise you iff you already haven't, to read the entire help file for SCAR before going any further. Just open SCAR and hit F1.

Well, a function performs a specific task and returns a value. Some functions do both things at the same time, meaning it's task is to return a specific pre decided value. like the writeln(). It returns to the debug window whatever is written (or any variables) between ('HERE').

Most pre coded functions in SCAR will return one of these three options:

- A string
example:
readln('Enter username');
Will create a box with the text enter name and a text box. That which is written within the box is stored.

- An integer
example:
findbitmap(door,x,y);
will return the bitmaps coordinates to x and y

- A boolean value (Either true of false)
example:
istextat(10,16,'Khain')
if the text Khain is found at the coordinates 10,16 the returned value is true otherwise it's false.



================================
3.1.0 Creating Functions
================================

Let's take this function for an example.

CODE

procedure RWait (ranlength: string); // By Khain
begin
 if(ranlength = 'xxshort') then begin wait(15+random(15)+random(15)) end;
 if(ranlength = 'xshort')  then begin wait(50+random(25)+random(25)) end;
 if(ranlength = 'short')   then begin wait(100+random(50)+random(50)) end;
 if(ranlength = 'medium')  then begin wait(200+random(100)+random(100)) end;
 if(ranlength = 'long')    then begin wait(500+random(250)+random(250)) end;
 if(ranlength = 'xlong')   then begin wait(1000+random(500)+random(500)) end;
 if(ranlength = 'xxlong')  then begin wait(1000+random(500)+random(500)+random(500)+random(500)) end;
end;


This is a pretty easy straight forward function. It serves well for creating random wait times depending on what you want. Easier than writing in every single time wait(100+random(250)) to create a random number. Instead, just write on the line you want your random wait:

- rwait('short') this will make the script wait for approx 100-200 milisecs. You can chose the amount to randomly wait by changing whatever the text within the brackets '' to whatever size you want (look at the function and you'll see the supported sizes). Example : xxshort (extra extra short) long, medium etc...

Another function, a little more complex.

CODE

procedure Mouse(mx, my: Integer; Mbtn: string; ran, ran2: Integer); //By OhDearUrDead
begin
 Wait(20+random(50));
 mx:=mx+random(ran)
 my:=my+random(ran2)
 movemousesmoothex(mx,my,1,3,20,20,10);
 Wait(200+random(200));
 if(Mbtn = 'left')then ClickMouse(mx,my,true);
 if(Mbtn = 'right')then ClickMouse(mx,my,false);
 Wait(80+random(100));
end;


Usage:

- Mouse(x coord, y coord, left or right click, randomness for x coord, randomness for y coord)
This is basically a faster (coding faster :P) and simplified mouse function. It will wait for random milliseconds and also add a randomness to where it moves and clicks depending on the value of the amount entered in the randomness for each coord.

Study these functions and you'll have a pretty good idea of how to make basic functions. I won't take you there step by step because it is now that your knowledge and the things you have learnt will come into hand and you'll figure things out.



================================

3.1.0 RS2 most used functions

================================

NOT YET COMPLETED



================================
Ending comments etc
================================

As this is the first version I perceive there will be some updates in the future, nothing is certain though as I don't even script anymore :P

I'd like to thank Kaitnieks for creating "Shit Compared to AutoRune" don't be so modest, you did a great job :D

Also Alibvandestraat, piv, kurdt, antiyou, Sbm007 and all the other people that helped keep scripthelp alive back when it was alive :P

Any comments pm me. For questions ask in the scripting section of the forum. I might not answer but you can always try, there are several other also willing to help.

"We are all hypocrites"

-Khain


--------------------
 


Copyright © 2004 Kaitnieks
Page design from OSWD