Aser
2009-03-01 18:44:24
Tutorial
Download SCAR
First you need to obtain a copy of SCAR. You can get it by going to
http://freddy1990.com/scar.php and downloading the newest one. It is the
picture of the orange bulldozer surrounded by green.
Select Save File. A window should come up, asking you where you would like to save the file. I usually save it to my Desktop for ease of installation. The file is 1.9MB as of v3.15b. This means it should be a quick download even on my 2KB download rate dial-up…all right I admit it took like 15 minutes.
Install SCAR
1. Find the place you downloaded SCAR to.
2. Double click the icon. It looks like a blue box with a blue disc beside it. A screen comes up telling you that this will install SCAR.
3. Click next
4. Select I agree, select next
5. Choose where you want SCAR put (if you are actually following these instructions the leave the install path default), select next
6. Choose what you want the Start Menu folder for SCAR to be named; select next;
7. Select if you want to have a desktop icon (shortcut straight from your desktop to SCAR), program group icon(anyone wana help me out with this one?), or a quick launch icon(the little bar by the Start Menu);select next;
8. Verify that it has the correct information referring to the install; Click Install;
9. Wait for approximately 5 seconds as SCAR is installed (you will see a blue bar);
10. Select if you want to launch SCAR or not (recommended to launch if continuing directly on with this tutorial; select finish
Note: Some of the steps may change due to updates but you should be able to figure it out.
Getting SRL
Obtaining a copy of the most recent SRL would be a good idea. It is not necessary to begin scripting, but it is nessisary to begin scripting good and to run scripts that don’t get your character in RuneScape banned.( I suppose you could write the includes yourself…but you would have to be a God at scripting (you wouldn’t be reading this tutorial) or stupid).
First, you might be wondering what is SRL. SRL is an acronym which stands for SCAR Resource Library. It is a compilation of files that make SCAR better.
The SRL Developer Team is proud to present the SCAR Runescape Library.
It is managed and maintained through a SVN server by the SRL-developers.
SRL came into existence as a response to the include wars (include writers bashing each other) to bring standardization and cooperation to the include world. SRL evolved around the idea of having only one include which could meet the needs of all scripters, from beginners to the ultra advanced. The first incarnation of RSL was a compilation of all the major includes at the time of it’s inception. Functions from library, library2, SI, RSCI SSI2 and Squig were used along with procedures and functions from well-known scripters. The final product is an elaborate tool that meets the need of the first time scripter as well as the advanced scripter.
Advantages of SRL
Standardization
A structure of standardized functions and procedures is a giant leap forward for the cheating community as it allows for continuous and consistent growth without having scripts become outdated.
Mature approach
The Developers are all well-known and respected members of the cheating community. They are well above petty include wars, and they are all in one way or another committed to the project.
State-Of-The-Art
Since SRL involves big names from the cheating community. You couldn’t wish for a better include, in fact, it is the only include left.
SSI2, SI, Squig, and RSCI are all dead.
Support
SRL offers the widest possible support from the cheating community.
Surveyable
The SRL-include is split up into small surveyable segments so at a glance you can quickly select what portions you will need.
Modular and expandable
The modular approach of SRL enables the developer and the scripter to easily maintain and adjust the include. It is therefore easily expandable.
Research & Development
SRL is not a finished product. Although some functions are hardly negotiable, others are open for change and improvement. Most functions
will be polled and discussed at the SRL forum, thus maintaining a high democratic level.
Tailored to the scripters needs
Scripters have the opportunity to help direct future direction by making suggestions or even submitting their favorite procedure or function which they themselves use all the time.
SRL consists of three Catagories
Core:
consists of routines necessary for almost all scripts.
Skill:
consist of skill-related routines. You will need to include them separately into your script.
Misc :
any routine not applicable to the above mentioned types will be misc
Include wars: petty battles between include writers claiming the other had stolen their <wait> command (or some other trivial procedure/function)
Basically SRL is what makes SCAR scripting work. You can do it without but it wouldn’t be very smart. It would be like trying to nail together a house, using your face as a hammer instead of using the actually hammer that is sitting right next to you.
Now that I have explained, or rather copied an explanation, of what SRL is, you might be wondering how you get it. There are many tutorials that tell you how to get your very own copy of SRL. I will link to some in case my tutorial fails you, or in case you just don’t like my extremely detailed hopefully idiot proof version.
There are two ways to get and install SRL that I know of. They are manual and subversion. For me the easiest way is manual. It may not be for you, so I will include both.
Manual Install
1. To get SRL Rev 29 & 30 (most up to date at time of writing) go to http://www.villavu.com/forum/showthread.php?t=39307 and download or click here
2. A screen will appear asking you if you want to download or open. Select Download.
3. Now select where you would like the file saved. It is easy to choose desktop. Select Save.
4. Wait while it downloads (1.23MB file).
5. When if finishes downloading, go to where you saved it and double click to open it. Note: If you get an error you may need to download/install WinRAR (more about that later)
6. Extract the file by clicking on the extract button on the top left second button over.
7. Now you need to find where you put your SCAR folder. The default is C:\Program Files\SCAR (version)
8. You can navigate to the correct folder by choosing the correct path just as you would normally except now instead of double clicking you can also hit the plus button beside the directory(folder).
9. Hit the plus beside the line that says WINDOWS (C:)
10. WINDOWS (C:) should now expand and have a minus(‘-‘) beside it. Now you can expand(open) the line that says Program Files.
11. Next expand the line that says SCAR (version number).
12. Now select(click) the line that reads Includes. This will cause the line to turn blue.
13. Select Ok from the menu. If you have the previous version of SRL it may ask you to replace some files. I select ‘Yes to All’. This causes it to replace the old SRL with the new SRL.
14. SRL should now be fully installed and should work fine.
Subversion installation
Subversion is a way to quickly(depending on internet speed) and easily update SRL through SCAR. This convenience makes it a commonly used method for updating SRL. This way takes a little more setup but in the end it makes your life a little easier.
1. Get the Subversion installer from here.
2. Download and install it to the default path(it doesn’t have to be the default, it is just easier). Note: If you haven’t figured out how to download and install things by now try re-reading the beginning or try a different tutorial.
3. The installation is basically the generic Yes, Yes, Next, Next install. Note: I like to have the Subversion folder inside of my SCAR folder just for organization purposes.
4. Now open up SCAR
5. Go to Tools>Options…(bottom one)
6. Select SRL Download from the side menu
7. Make sure that the Subversion Repository radial is selected (radials are the little round white circles that fill in with a black dot when clicked)
8. Select Checkout under Check Revision.
9. A DOS window (Black screen with white text) will appear. It will go through downloading the files. When it is finished you will have completed downloading SRL.
Other Installation Tutorials
Subversion
http://www.villavu.com/forum/showthread.php?t=18370
http://www.villavu.com/forum/showthread.php?t=21471
http://www.villavu.com/forum/showthread.php?t=17890?t=19584
Now that you have SCAR and SRL (restart if you don’t yet, try re-reading before asking for help. You might also try another tutorial) you are ready to begin scripting. There is another SCAR utility that you can get called S.M.A.R.T. It lets you macro while also doing something else on your computer. I will not get in on how to get/install SMART right now because I have only done it once and don’t want to lead you astray.
Starting out in SCAR

When you first open SCAR you will see a couple of screens telling you what SCAR is about. There is a checkbox at the bottom that allows you to open SCAR and not see these screens. This is helpful for later on, but for the first time why don’t you spend some time and read what it has to say.
Now that that is done…you should see a mostly white screen with a little bit of text.
program New;
begin
end.
and also
Loaded all chars. (NPCChars, TradeChars, SmallChars, StatChars, UpChars)
07/01/2009: SCAR Divi 3.20 Beta 9 is available in the R&D section of
the forums. (note that you need to register to view and download)
(Forums: http://freddy1990.com/forums)
(Wiki: http://freddy1990.com/wiki)
(IRC: irc.moparisthebest.com #freddy1990)
(Donate: http://freddy1990.com/donate.php)
Don’t worry if you don’t see exactly that as it is frequently updated but it should be close.
Before learning how to create your very own SCAR scripts you need to learn a little bit about the program first. I know that reading the instructions for something is a little boring at first, but it allows you to learn many times faster.
Main Screen
The main screen is what it sounds like the main screen(the one with
program New;
begin
end.
in it)
This is where all of the coding actually happens. You will notice that if you want to you can type in this box/screen. It is labeled on the side with numbers. These are the line numbers and are very helpful when looking through long scripts and getting help if you script doesn’t work. At the start only lines 1-3 are labeled but if you go in and hit enter to add another line it will become labeled.
Now look to the top of the Main Screen. You should see a small gray rectangle that says untitled. This is the name of the file that is currently shown. If you open up a file called SRL.scar then the gray box will say SRL.scar.
Most of the buttons are fairly standard. They are
New Script (like new file) –
Open Script (opens a SCAR script) –
Save Script (Saves the current script being worked on) –
Cut –
Paste –
Search –
Add Tab (adds another tab allowing you to have more than one SCAR script open at a time without a huge mess) –
Close Tab –
Run Script (Will start a script )—
Pause Script (stops a script but remembers the point is stopped so it can be resumed) –
Stop Script (Stops the script, the script will have to be fully restarted if you choose this) – Step Into –
Step Over (I have never used these so I don’t know what they do. I assume they let you test a specific area of code) –
Color Picker (See Color Picker Section) –
Clear Debug Log (clears all text from the very bottom left box) –
Toggle Report Box ( Turns the box at the bottom right on or off) –
Clear Report (Clears the bottom right box of text) –
Toggle Function List (Turns the list at the right on or off) –
Read SCAR News (gives you the starting Debug Log text) –
Crosshair (see Crosshair section)
These are the buttons along the top. You will also see a generic tool bar at the top. You may explore this at will.
Now if you look at the bottom you will see some numbers.
Coordinate Numbers in (xxxx,yyyy) format. (See Coordinate Numbers of more explination).
Place Numbers in (Line:Column) format (the line is how many lines from the top you are and the column is how many lines right from the left you are)
Further Explanations
Color Picker
This is a very important little tool built into SCAR. It allows you to convert colors into an integer (number) that SCAR can use. I should probably explain a little of how SCAR works now, to the best of my knowledge and ability. SCAR is a color picker. It works by finding colors and pictures. It uses those colors a pictures to allow it to automate tasks, just as a person would do. You can ask SCAR to click on a certain color. It will find that color and then click it. That is how it can help you cheat at Runescape or any other online game. Certain objects are certain colors. Ex. If you want SCAR to help you mine a copper rock…You would specify the color that the copper rock is. Then SCAR could find that color and click it. Then it could repeat doing that even while you are away. Allowing you to sleep or do other activities while you level up.
Anyway… to use the color picker you click the dropper symbol or pres Ctrl + P. A small off white cursor box will appear. You can move it around with your mouse. It will have a line that says Mouse: followed by some numbers, and a line that says Color: followed by some numbers. It also has two boxes with a highly zoomed in view of what is under the cursor/crosshairs. The window on the left will show the surrounding area of the center of the crosshair. The right window will show the color that is in the center of the crosshair.
When you click a message will appear in the Debug Log
Color Picked: 16777215 at (550, 164)
The first number represents the color in a number form. I picked a white background. 16777215 is the number that corresponds to white. The second numbers are the coordinates that the color was picked at. These are in (x,y) format. If you don’t understand this, look to the Coordinate Numbers section.
That is how the Color Picker is used. Later on we will learn how to put this tool to good use.
Crosshair
This tool is also a crucial part of using SCAR. It allows SCAR to recognize a window even if it has been moved slightly or is a different size. That way you could use SCAR on a window even if it isn’t maximized or if it was moved to one side of the screen. To use this tool, simply click and hold the left mouse button while your cursor is over it. Then drag it to the window that you wish target. Then release the mouse button. You will see a blackish box close in around the window. SCAR’s Debug Log will now have a new line reading
New client targeted
After the client is targeted you can press the play button (if you have a script open) and the script will run.
Coordinate Numbers
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Warning: Technical Math Stuff
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
This concept should not be too hard to learn. You should already know it if you have taken (Pre)-Algebra. Coordinate numbers are a way to express a point on a flat plane (a plane is like a surface). Luckily for us your computer screen is a flat plane. The numbers are called Ordered Pairs. An ordered pair consists of an x number and a y number. They are always organized in this format (x,y). The x number comes first and the y number comes second.
I will try to explain how this works now…Imagine a grid. Now the grid had a bold line running through the middle of it horizontally (sideways) and another vertically (up and down). These bold lines intersect perpendicularly (make 4 right angles). It should look like a big ‘+’ sign.
Each of these bold lines is called an axis. The horizontal (sideways) one is called the x-axis. The vertical (up and down) one is called the y-axis. At each of the respective axes (plural for axis, pronounced axeees) the value for that number would be 0. So along the horizontal or x-axis the value of x would be 0. The same applies to y and the y-axis. So at the point where the two axes intersect, the Origin, the values for x and for y are both = to 0. If you then plug this into the format of (x,y) you get (0,0). It is worth noting that SCAR removes the ‘()’.
If you are still with me, good job. Here it gets a little more complicated, still easy to understand but not as easy as 0,0.
Now lets begin with the y-axis and how numbers are calculated from if. You already know that the axes them self represent a value of 0, but if you go above or below the x-axis what happens? The values have to change. Imagine that you go one unit above the x-axis. This represents a value of 1. If you go up 2 units from the x-axis y is at a value of 2. If you go up 1.365, y is at a value of 1.365. Easy enough? Now if you go below the x-axis what happens? Say you go down one unit of measure from the horizontal y-axis. Y would now be at a value of –1 (negative one). It is simple however many units below the y-axis you are is represented by the number of units in negative form. Thus 4 units below is –4 and 7.4 units below is –7.4. Imagine that the y-axis is a ruler that measures how far the point is above the x-axis. The further up you go on the y-axis the bigger value y is going to have.
Now for the y-axis. If is slightly more complicated but not much. The only problem you should have is memorizing which side is negative. Instead of up being positive and down negative now right is positive and left is negative. That’s it.
Now we need to learn how to combine the two. Say that we are two units left and 2 units up from the Origin. Up two units gives y a value of 2 and left two units gives x a value of –2. Using the format of (x,y), we can convert this to (-2,2). I hope that you can at least kind of understand the idea behind the coordinate plane.
To translate the coordinate plane to SCAR you need to only change two things.
1. The units of measure are pixels.
2. The origin is in the top left corner of the screen.
If you move your mouse around while looking at the bottom left corner in SCAR you will see the numbers changing. If you were to go to 100,100 that would be up 100 and to the right 100. If you move the mouse to the right you will see the value of x increase. If you move it to the left it will decrease. If you move the mouse up the value of y will decrease and the value will increase as the mouse is moved down.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
End of the technical math stuff
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
This knowledge is not truly necessary to script is SCAR but it has helped me many times and is a good concept to learn anyway.
What is SCAR code?
Now that we have all of that behind us we can get to actually learning how to SCAR script. Scripting is telling the SCAR program how to run. It doesn’t just know what you want to do, you have to tell it, and to tell it how to do what you want it to, you have to learn its language because it sure isn’t going to learn yours. Some of the SCAR commands are fairly easy and make sense, they ask SCAR to do what the command sounds like it asks. That is it is easy to interpret what a certain command does. Some are not quite so easy, but there are fewer tough ones than easy ones.
SCAR code is almost a mix of English and computer language. It combines words and numbers to make commands that represent ideas that you are conveying to SCAR.
Ex.
Mouse(100,100,3,3,True);
We could use this, a standard command. This represents the idea of you telling SCAR “SCAR I want you to move the mouse to coordinate point (100,100) with + or – 3 pixels of randomness to each coordinate value and then to click the right mouse button.” See how much easier it is to code?
Learning to script with SCAR –Very Basics
Now that I have defined code to the best of my ability, let’s start to learn the language of SCAR.
Program New;
This tells SCAR and other people the name of the program. It should try to convey the idea of what the script does. Program is followed by a space and then a name that you choose. The name cannot have any spaces in it but it can have underscores. If it contains more than one word without underscores then the starting letters of each word should be capitalized.
Ex: WindowsTaskManager not Windowstaskmanager
As you should be able to see, this is much easier to read. You may need to use this technique often so you should make this habit.
begin
This tells SCAR that it needs to begin executing some code. Not to bad is it. You tell it to begin and it begins. It can’t get much more simple than that.
end. or end;
End. is different than end; How you ask? They have different end punctuation. Just as with the English language a semicolon( ; ) is not the end of a sentence it is merely a transition. A period ( . ) on the other hand is the end of a sentence. The same is true with SCAR. Sometimes you need to have more than one begin/end sequence. Only the final begin/end will follow with a period. The others will be followed by a semicolon.
Learning to script with SCAR – One step further
I would like to recommend at this point that you have SCAR running and that you attempt to follow along. Following along will help you memorize the SCAR/SRL commands, helping you to improve your scripting/learn to script much faster.
Let’s learn how to make our very first SCAR script now. Complete with our own personalized touch. Open a new SCAR script (Ctrl + N; File>New; or click the new script button). Place your cursor behind ‘begin’ and hit Enter. This will expand your workspace. You should now have a blank line between ‘begin’ and ‘end.’ With the space let’s learn a very useful and easy first SCAR command.
WriteLn(‘Text Here’);
Here is the breakup of what that does and what the different parts mean. [WriteLn] this is the basic command. It means Write Line. We then need to further define what to write because SCAR can’t read your mind, so we add a ‘(‘. These will be used on any command that needs further definition. The quotes indicate that words will be input. With quotes anything you type between them will be output. You need to close the quote so that SCAR knows that the text is through. Then you need to close the parenthesis to let SCAR know the extended definition is through. Finally, you need to add a semicolon to tell SCAR that this is the end of the command.
You should now have something that looks like this…
program New;
begin
WriteLn('Your Text Here');
end.
The line that is written appears in the Debug Log ( the bottom box). If you cleared the Debug Log and ran this script you would get the following.
Successfully compiled (46 ms)
Your Text Here
Successfully executed
Successfully compiled (46ms) – This is always a good thing. It means that SCAR can successfully interpret or compile the code that you wrote. That means you did something right. The 46ms is the time it took. Ms stands for milliseconds. A millisecond if you don’t know is 1/1000th of a second. That means that SCAR could read our code a full 21 times in one second. In case you didn’t notice SCAR is faster than you are.
Your Text Here - Notice that WriteLn(‘Your Text Here’); has been converted into Your Text Here? That is because anything entered in the quotes after a WriteLn will be written in the Debug Log. If you were to change your command to WriteLn(‘;alsjdfiawefknvn,xc’); you would get ;alsjdfiawefknvn,xc as output.
Successfully executed – Means that the script ran successfully until it ran out of code to read otherwise called the end. It is always good to see this at the bottom of your Debug Log after running a script.
Notes: You can also put writeln, but you can probably see how ugly that looks. It is one of my pet peeves when people don’t use capitalization. Just do it. It is a good habit to get into and makes the script look nicer.
Little more advanced: Variables + if then statements
To effectively script with SCAR you need to know how to use variables. This section will hopefully teach you all about variables, starting with what they are. A variable is a way of representing a number or string (words) in a dynamic (changeable) fashion. If you have taken math classes you should know the basic idea of a variable.
A variable is almost like a mask for a value. It is exactly the same as the value it represents except for its appearance. So if x = 2, then x is the same as 2, thus the =. I will try to explain with examples.
There are four types of variables that are available in SCAR. They are Integer, String, Boolean, Extended. These are used to make that variables organized and recognizable not to mention work. An integer is a whole number. It can be positive or negative, but it can only increase/decrease by units of 1 ex, -3,-2,-1,0,1,2,3.
A String is a variable that defines text. The value is always surrounded by single ‘quotes’ also called an apostrophe. If you can’t find it, it is the key to the right of the semicolon/colon button. Don’t use Shift or Caps Lock when pressing it.
A Boolean is either a True or a False value. Ex. NegativeOneIsNegative = True, NegativeOneIsPositive = False.
An Extended variable is like an integer but more specific. They are real numbers. These allow you to use decimals and fractions. Ex. 1.0000001, -3120.75968
Let’s look at an example of a script using a variable…
program New;
var
s : String;
begin
s:= ('Define String');
WriteLn(s);
end.
Program we should already know. Var is new. Var is short for variable. It defines an area for defining variables. The code between var and begin defines variables. They are defined like…
VariableName : VariableType;
So…
S : String;
Assigns the letter ‘s’ to a variable type of string, meaning that it will be text. Begin will begin the script. The next line is how you input the value of the variable. First you state the variable name. Followed by a colon and an =. There can not be a space between the colon and the = or you will get
Assignment expected in script.
Next you can do one of two things. You could put a parenthesis to use better organization, or you could skip it and go straight to the quote. It makes no difference in how SCAR runs. I like to use the parenthesis because it helps me read it and it looks nice. The choice is yours. Because this is a string we then defined our text by surrounding it with quotes. This allows SCAR to know it is a string. Remember you can’t have apostrophes here because it will end your string (try using a full quote).
Now SCAR knows that the value of s = Define String. You can now input ‘s’ into other commands and SCAR will convert it into the text. So if we input the variable like so
WriteLn(s);
Then it will input the value that we set as ‘s’. Notice that there are not quotes around s. If there were your output would only be s.
Now for some integer work. As stated above and integer is a whole number whether it is positive or negative, just no decimals. Integers work slightly different from strings because they are numbers and not text. With integers we can add, subtract, multiply, and divide. (Also many other mathematical functions) The variable is defined the same as a string.
i : Integer;
This defines i as an integer. To input the value of and integer variable we would state the variable add the colon and = and then input a value in number form.
i:=(10);
Again, you do not need the (), but they allow for easier organization. Then if we input i into our script we should get an output of 10 in the Debug Log…You don’t? Don’t worry you shouldn’t…until we fix it. The reason you get a
Type mismatch in scriptis because your variable that you want to output as a string is still in integer format. To convert integers to strings, we can use the
IntToStr(variable); command. IntToStr stands for integer to string, the exact thing that we need for this situation. If we try
Writeln(IntToStr(i)); we should get the desired output. This is a good place to note that you should always have the same number of “(“ in a line as “)” in a line. If you don’t you may get a
Close round expected in scripterror. Count your parentheses well; make sure they are balanced if you get this error.
Now that we have learned to output the value of an integer (hopefully) as a string, we can look at multiple variables in a script and some of the math functions. To input two variables of the same type we could do
a : Integer;
b : Integer;
c: Integer;
or we could do it the easy way like this
a,b,c : Integer;
When defining variables of the same type you should always put them in the same line separated by commas. There is a maximum number that you are supposed to have per line…(could someone help me out with that one?). You may also separate them if you need to for organization, but that is generally not needed/unsightly.
Now that we have a, b, and c defined as integers lets explore some of the possibilities that SCAR offers us in the mathematics world.
program New;
var
a,b,c : Integer;
begin
ClearDebug;
a:=1
b:=(a + 1);
c:=(a * b);
WriteLn(IntToStr(c));
end.
You should soon notice that there is a new command in there, ClearDebug; This handy little command will erase all of the information in the Debug Log. This allows us to read our output on the top line and it also reduces the clutter if you run a script a few times or are running multiple scripts.
Looking into the script you might find some things that confuse you (hopefully not, if you understand it all then great) You should know that the first line is defining a as 1, not to bad. The next line defines b as a +1. This means that whatever value that a has it will be added to by 1. In this case it would be like 1 + 1 (substitution of 1 for a). If you were to have b exported as a string (writeln it) you would get a value of 2. If you don’t understand that 1 + 1 = 2, I am terribly sorry but you need to go back to kindergarten.
The next line sets the value of c to be a * b. If you didn’t catch on this is a times/multiplied by b. So if a = 1 and b = 2 and c = a * b, We could say that c = 2 * 1 or 2. If you run the script you will see that it is so, or that SCAR and math lie to us all…one of the two.
Just for fun let’s try something a little more advanced as see if you can follow. It shouldn’t be a problem if you can’t, you’ll just get left behind in the tutorial and probably get frustrated.
program New;
var
a,b,c,d,e,f : Integer;
begin
ClearDebug;
a:=1;
b:=2;
c:=3;
d:=4;
e:=5;
f:=(a + b + c + d + e); //This should be = to 15
if (f = 15) then WriteLn('F is equal to 15')
else WriteLn('F is not equal to 15. It is equal to ' + IntToStr(f));
end.
You may now be thinking that I tried to up the learning curve to quickly. I hope not. You should be able to start understanding certain things on your own now. If not take it a little slower and read more carefully. Soon the slow learner crutch will be removed and you will be expected to walk and then run.
Fairly straight forward until you get to f. I thought this would be a good point to teach you about comments. Comments are little things that you add to your code that do not affect it in anyway but allow you to easily add notations, warnings, or other forms of communication to yourself or to future users of you script. Comments can be added like I did in the script above by adding // (two forward slashes (? Key with no shift)) This will make everything after it be a comment (it will also turn green) but it will only affect that line. The other way can be used to make comments on multiple lines quickly. This is done by adding {} (the keys to the right of ‘p’. If you add the { anything after will be a comment until you add a }. This allows you to easily make big comments or make a certain section of code inactive for testing purposes.
Next line…the wonderful world of if then. These are very important statements. They allow you to check for a certain condition and execute code (or stop code) if the condition is found. If then statements start with an if. Then you state the condition to be checked. In this case it checks if f = 15. It finds f to in fact be = to 15. The then tells it what to do if the condition is met. Since f = 15, the condition is met so the following code is executed
WriteLn('F is equal to 15')
If you run the script you will see that it does output F is equal to 15. You can do all sorts of things with if thens that will be explained later. Right now let’s keep working on this part. Notice that this line does not have a semicolon after it? That is because we still need to add another section. If you notice the else on the next line, you will see that it has a different command next to it. If we had added a semicolon then the script would not have recognized the line with else, giving us an error.
Else is like a ‘if the condition is not the one stated above’ command. If above condition is not met then do this. In this case it is saying the if f does not = 15 then it will execute its command.
else WriteLn('F is not equal to 15. It is equal to ' + IntToStr(f));
Obviously the else statement and the WriteLn. You should also understand up to the +IntToStr(f). This is to say output the string but also output the integer f in string form. It is worth noticing that I have put an extra space after to in the string. This is because the integer does not have any space in front of it. We need to add the space in string format because if we add it in next to the f nothing happens.
Try editing the one of the variables to a different value so that f does not = 15. You should get an output saying that f does not equal 15. Then you should get the value for f because of your IntToStr.
Before I forget we need to cover Booleans. Extendeds aren’t too important to cover as they are mostly the same as integers. The only noticeable difference is that you need to use FloatToStr to output it instead of IntToStr.
Booleans as stated before can only have to values, True and False.
program New;
var
a,b,c,d,e,f : integer;
Fifteen : Boolean;
begin
ClearDebug;
a:=1;
b:=2;
c:=3;
d:=4;
e:=5;
f:=(a + b + c + d + e); //This should be = to 15
if (f = 15) then
begin
Fifteen:= True
end;
if (Fifteen = True) then WriteLn('F = 15')
else WriteLn('F is not equal to 15. It is equal to ' + IntToStr(f));
end.
Notice that we defined fifteen as a Boolean. We didn’t use 15 because numbers cannot be variables. Imagine how confusing that would get. (Your variables can contain numbers, please don’t, but they cannot start with them.) Then we got to the if (f = 15) then part. An if then can be followed by a whole section of code. This is done by pressing enter and starting a begin/end section. We then define fifteen to be true. Then end that section of code. Notice the end has a semicolon after it because it isn’t the final end. We then ask SCAR to check for the condition of fifteen being true. It is in this case so F = 15 is written.
If you are ready to move on you should read this tutorial on scripting standards. They are kind of like grammar for SCAR. They may be annoying to follow, but it helps your script be readable and organized; thus, you can find errors and mistakes easier. It should also be noted that It is much more annoying to read a script with no standards than to make one with them.
Standards = important
http://www.villavu.com/forum/showthread.php?t=39653
Good job Cut em2 it. That tutorial was excellent. Also, I am totally serious. Read that tutorial now. If you do not know standards or have bad standards this will really help you. I know my standards are a little iffy but I do try and so should you. Make your script the very best you can. Even if you are really sucky/a complete noob at scripting, if you use standards you are better than a more advanced scripter that completely ignores them.
Starting out with SRL + procedures
Hopefully now we can move faster because the difficult starting stuff should be behind us. Let’s learn a little bit about SRL and the commands that it allows us to use. SRL can be included in a script by entering to following
{.includes srl/srl.scar}
to the line directly after your program line. Then you need to add
SetupSRL;
;into the first line of your main loop (right after begin for now);
With SRL included you now have access to many super awesome new commands and features. These features range from undetectable RS autoing functions to RS random solvers such as the Mysterious Old Man, Evil Bob, Leo, and many others. The SRL include allows you to have shorter scripts that are much more effective than many of the older longer scripts. The generic SRL include allows you to use most of the commands. It in its self has includes incorporated into it. Includes are included in the following way… Find your SCAR folder. Inside there should be a folder named Includes. This folder should contain at least a folder called SRL. The SRL folder contains the srl.scar file. You might notice that the include line we just entered was the folder path starting from the main SCAR directory (folder). So .include means that SCAR first opens the include folder. .include/srl now means that it will open the SRL folder. .include/srl/srl.scar means it will then open the srl.scar file within the SRL folder which is within the includes folder. If you wanted to open a file in the includes folder called the.scar, you would put .include/the.scar. include is the folder the.scar is the file. You just add more slashes and folder names until you get to the proper folder. One last example…you need to open a file called rainbow.scar that is in the green folder (imaginary) within the blue folder, within the yellow folder, within the SRL folder, within the includes folder. You would have code looking like
{.include/srl/yellow/blue/green/rainbow.scar}
Starting to use SRL and Procedures
A major part of SCAR autoing is based off mouse movement/clicking. The other majority is color finding. Mouse movements and clicking is a really easy task to learn. Look at this.
Mouse(x,y,randx,randy,lclick);
Once SRL is included you can use the Mouse command. It is in the format above. It will click at the coordinate point defined by x and y as an ordered pair. The point will have randx randomization. That is, the value of randx will be randomized and whatever that number is will be the change in x. The same applies to randy except that is the change in the y value. You should probably keep both the random values the same, unless you have reason not to. Lclick is the option to have SCAR click the left or right mouse button. Lclick is a Boolean so the only values that are acceptable are true and false. True = left click, False = right click.
Mouse(250,250,5,5,True);
This will move the mouse to the screen position at (250,250) and left click the mouse. It will also have randomness so that you could have anywhere from (250,250) to (255,255). It should be noticed that the mouse command only has randomness in the positive direction. According to the coordinate plane you would think that this would cause clicks to be up and to the right. Unfortunately, it causes the clicks to be down and to the right. For some reason 0,0 is in the top left corner of the screen. This causes y to increase as you go down.
Try this script out in paint. It might give you an idea of how the Mouse command works.
program New;
{.include srl/srl.scar}
var
x,a,b : Integer;
begin
SetupSRL;
Wait(2500);
if FindColor(a,b,65280,0,0,2000,2000) then
begin
Mouse(a,b,0,0,True);
Mouse(250,250,0,0,True);
end;
if FindColor(a,b,255,0,0,2000,2000) then Mouse(a,b,0,0,True);
repeat
Inc(x);
Wait(100);
Mouse(250,250,200,200,True);
Until(x > 20);
end.
Don’t worry about what the script means right now. We will get to that later. Just open paint, click play, select the paint window and watch. If you want to see it better select the brush tool.
The green dot is 250,250. The red dots are all of the places that SCAR will click with 200 randomness settings. Don’t worry you will probably never use 200 randomness setting. The most I’ve ever used was 10 randomness. — Those three lines are 15 pixels long together. That would be using 15 randomness and it wouldn’t always click that far. Mostly a randomness of around 3 or 5 is used. Note: the pixel length may differ depending on the resolution you use and text size differences.
Now we will look at procedures. Procedures allow you to place code that you write into a command, allowing you to use it in one line, making your scripts smaller and more readable/understandable. If you look at this…
program New;
{.include srl/srl.scar}
procedure Math;
var
a,b,c : Integer;
begin
a:= 25;
b:= (a * a);
c:= 10 * b;
WriteLn(IntToStr(c));
end;
procedure Other;
begin
WriteLn('This should demonstrate how procedures work.');
end;
begin
ClearDebug;
Math;
Wait(500);
Other;
end.
I think I have a little explaining to do…possibly? You may notice that I included SRL even though I didn’t need to… This is because I have SRL included in my default start screen
program New;
{.include srl/srl.scar}
begin
end.
Paste this into SCAR and File>Save as Default if you want to have SRL automatically included when you start a new SCAR file.
Next, procedure is seen. A procedure is almost the same as a regular script except instead of using program name, you use procedure name. Then you make sure to follow your final end with a semicolon.
The code included in the procedure doesn’t actually run when you play the script. When you put the name of the procedure into your main loop (begin/end. notice the period; the part of the script that isn’t in a procedure) it will execute the entire procedure just like it would a script.
If I decided to put another Math; under Other; It would run Math; twice, but I would have much less code, and it would take me a lot less time.
Wait(500);
This causes SCAR to wait. The number is the time that SCAR will wait in milliseconds. 1 second = 1000 milliseconds. So
Wait(500);
Would wait for one half of one second. 2500 would cause it to wait for 2 and one half seconds.
Basic Color Finding
FindColor(x,y,color,MSX1,MSY1,MSX2,MSY2);
This finds the color (gathered by the color picker) and inputs the coordinates of where it is found into x and y. MSX1,MSY1,MSX2,MSY2 are the coordinates of the box that it will look in for this color. MS stands for main screen. X1,Y1 form an ordered pair that give the top corner of the box. X2,Y2 are the points for the oposite corner of the box.
MS = main screen, searches the playing field of RuneScape
MM = mini map, searches the mini map
MI = inventory, searches the inventory (not 100% on this one, can’t really remember)
So…
FindColor(x,y,color,MMX1,MMY1,MMX2,MMY2);
Would find the color in the mini map…
To properly use this you would at least need…
program New;
{.include srl/srl.scar}
var
x,y,color : Integer;
begin
SetupSRL;
Color:=0;
FindColor(x,y,color,MSX1,MSY1,MSX2,MSY2);
Wait(500 + random(100));
Mouse(x,y,3,3,True);
end.
x, y, and color need to be defined as integers because SCAR converts colors into numbers. SetupSRL; is needed to make Mouse() work properly. Color: defines what color we will use. Color is the implemented into the color part of FindColor. You could also put a number there, but variables look nicer.
Randomness was implemented in Wait() this time. To include randomness just add a +/- then Random(#). Random generates a random number between 0 and #. If you had Wait(500 + random(500)); Scar would wait between 500 and 1000 ms. Wait(500 – random(500)); would wait between 500 – 0 ms.
Constants
Constants are very useful when you are doing color finding. The colors in RS are constantly changing to prevent autoing (didn’t work very effectively). Because the colors change it is nice to be able to easily change them without having to scroll to every line that contains a color. Constants are very easy to define. They are almost exactly like variables except you do not need to define them.
program ConstantExample;
const
IntConst = 0912; //you don't need to define it as an integer, it knows it is because of #'s
StrConst = 'string'; //for a string constant just make sure you use quotes
BooConst= True; //Boolean constant (True or False)
begin
ClearDebug;
WriteLn(IntToStr(IntConst));
WriteLn(StrConst);
If BooConst then
WriteLn('BooConst is true');
if not BooConst then
WriteLn('BooConst is false');
end.
Integer constants are good for allowing color changes. String constants can be used for auto responders or IsUpText (more about that later). Boolean constants are good for allowing a user to choose between two options.
Cases
A very important part of autoing is the use of anti ban. Anti ban is a way of incorporating randomness into a script so that is is more human like. This hopefully will cause players using the script to not be as obvious of an autoer. The less obvious you are the less chance of getting banned you have.
Antiban is usually performed through the use of cases. Cases are an easy way to express long if then statements into short understandable code. They are also very easy to use.
program CaseExample;
begin
case Random(10) of //will generate a random number between 0 and 10
0 {if the 'random(10)' is 0}: WriteLn('Random number generated was 0.');
1 {if the 'random(10)' is 1}: WriteLn('Random number generated was 1.');
2 {if the 'random(10)' is 2}: WriteLn('Random number generated was 2.');
//you get the idea...
end; // you have to end your case statement
end.
Case defines that you are starting a case. The value that follows (It can be a straight number, variable, or random) defines what the case will “if then”. Of then starts the different arguments of the case.
Cases can also be used in conjunction with constants and all types of variables.
program CaseExample2;
const
Print = False; //True for print positive results, False for negative
var
number : integer;
procedure Mathz;
var
l : integer;
begin
l:= 0;
l:= l+1+75+(6*6);
number:= l
end;
procedure Results;
begin
case Print of
True: WriteLn('The result is ' + IntToStr(number));
False: WriteLn('The result is -' + IntToStr(number));
end;
end;
begin
Mathz;
Results;
end.
As you can see if you change the constant value of print to false you will get the number outputted in a negative form. You could also write this script…
program CaseExample2;
const
Print = False; //True for print positive results, False for negative
var
number : integer;
procedure Mathz;
var
l : integer;
begin
l:= 0;
l:= l+1+75+(6*6);
number:= l
end;
procedure Results;
begin
if Print then //Note*
WriteLn('The result is ' + IntToStr(number));
if not Print then
WriteLn('The result is -' + IntToStr(number));
end;
begin
Mathz;
Results;
end.
It is possible to change a case into an if then, but it gets very tedious after a while and doesn’t look as nice. Many of the SRL Members frown upon the use of large if then statements when a case could be use. This could decrease your chances of being accepted, so don’t do it.
Note*- If a variable is a boolean you do not need an ‘=’. If it is true it is just
if Boolean then
Scar automatically recognizes that you are asking if it is true. So…
if not Boolean then
is asking if the boolean is false.
Anti Ban using Cases
This is an example of RS antiban from a script that I wrote
procedure AntiBan;
begin
if not LoggedIn then
Exit;
case (Random(100)) of
0 : RandomRClick;
5 : HoverSkill('Woodcutting', False);
10 : BoredHuman;
15 : PickupMouse;
20 : GameTab(Random(15));
25: AlmostLogOut;
30: SayCurrentLevels(‘woodcutting’); //Note*
35: Case random(5) of
4: WriteLn(‘Wc Lvls?’);
3: WriteLn(‘lol’);
end;
40: begin
HoverSkill(‘Woodcutting’, False);
Wait(100 + Random(100));
GameTab(4);
end;
end;
end;
It isn’t very indepth and should probably be improved but it serves its purpose as an example.
It will exit if it is not logged in. You should probably include this in most of you your procedures
It generates a random number 0 – 100.
RandomRClick; - Randomly clicks the right mouse button on the screen
HoverSkill(‘Skill’, Boolean); - hovers the ‘skill’ (string format) and will right click it if the boolean is set to true. Otherwise it will only hover the skill. This is useful because many people check their experience in a skill often. You should have the HoverSkill() be related to what the script will do. If it is a fighter you would want it to check combat. If it is a miner you would want it to check mining.
BoredHuman – Moves the screen around using the arrow keys and also examines things.
PickupMouse – Simulates the movement of the mouse when someone picks it up.
GameTab – Selects the tab in the game corrisponding to the tab number. 1 = combat tab, 2 = stats?, 4 = inventory… If you have random in it, it will click a random tab.
AlmostLogout – Clicks the ‘x’ and hovers over the logout button simulating the user thinking about loggin out.
SayCurrentLevels- retrives the level of skill in the skill you input and types the value into RS
Case – You can imbed a case within another case to create even more randomness.
Begin- You can put a section of code to be executed if the random number is chosen.
Note* - WriteLn will not work in RS. It was added as an example of what you can do with cases. To write in RS use TypeSent(‘text’); It is unwise to use talking in a case statement unless it is something very generic.
Other Antiban tutorials:
http://www.villavu.com/forum/showthread.php?t=12355?t=13725
http://www.villavu.com/forum/showthread.php?t=23178?t=25286
Finding Stuff
Colors review
Uptext
FindObj(Custom)
Bitmaps
DTMs
TPA links
Color Finding Review
As you should already know SCAR is based off color finding. Most items in RS have a fairly unique color. This allows us to find items with ease.
FindColor(x,y,color,x1,y1,x2,y2);
Fairly simple and already covered I believe. Inputs the coordinates in to x and y of where the color was found in the box created by the x and y 1’s and 2’s.
UpText
Uptext is a powerful defence against miss-clicking because some item has the same color as the one you want to click. Uptext is the text that is displayed in the upper left corner of the RS screen. It tells you what your mouse is hovering over.
IsUpText(‘uptext string’);
This is used like so…
program New;
{.include srl/srl.scar}
const
Color = 0; //Color to be clicked
procedure Finding;
var
x,y : Integer;
begin
if FindColor(x,y,Color,MSX1,MSY1,MSX2,MSY2) then
begin
MMouse(x,y,2,2); //moves mouse to x,y with 2 randomness without clicking
if IsUpText('ock') then //don't include the capitalized letters
begin
Mouse(x,y,2,2,True); //clicks x,y
end;
end;
end;
begin
SetupSRL;
Finding;
end.
IsUpText allows you to know exactly what you are clicking on. When things are the same color (like tree tops) you can use ISUpText to differintiate between the two.
FindObj(Custom)
FindObj and FindObjCustom are SRL functions that combine FindColorTolerance and IsUpText. This makes it easier to find objects because you don’t have to code as much and you can input multiple uptexts and colors.
If you look in your objects.scar you will find the finding object functions
FindObj(x,y,'object',Color,Tolerance);
If it finds the thing with the uptext of ‘object’ and the color of Color with a tolerance of Tolerance it will input to coordinates into x and y. The object sting should always have quotes and should not contain any capitals. Pro Tip: The object, color, and tolerance can be constants.
Be sure to use if thens when object finding.
FindObjCustom(x,y,[‘object’,’object’, ‘object…’],[Color,Color,Color…],Tolerance);
FindObjCustom allows you to find an object that could have multiple uptexts or colors. For example, if you wanted to find a pickaxe you could have
FindObjCustom(x,y,[‘ick’, ‘kaxe’],[PickColor1,PickColor2], 5);
You can add as many uptexts and colors as you want. And all of the options are ‘or’s’. It is like if the uptext is this or this or this with a color of this or this or this. FindObjCustom works nicely with arrays. Arrays will be covered more later.
Bitmap Finding
A bitmap is a format of picture. Scar can find these pictures through numbers and letters. Don’t ask me how this works because I don’t know. I can only explain how to do it. To make a bitmap readable by SCAR you first have to get the bitmap.
Obtaining the Bitmap
1. Open up RS and login
2. Get the item that you want to make a bitmap of in your inventory
3. press the Print Screen button (mine says Print Scrn| SysRq) It should be right of the F12 button and to the left of the Scroll Lock, above Insert and Delete.
4. Open up paint (or another image eiditing program) and select Edit>Paste or Ctrl + V
5. Crop the image so that it is as small as possible but still retains the most of the pictue (half should be enough)
6. Fill the extra space with white or black (help on the correct one here?)
7. Save the file where you can find it easily
Converting the bitmap for use
1. Open SCAR
2. Go to Tools>Picture to String… You should get a pop up
3. Select open and navigate to your picture.
4. Optional – Input the name of your bitmap
5. Select Ok.
You will get an output of what looks like a bunch of numbers and text. This is an image to SCAR.
Implementing the bitmap
1. Make a new procedure called LoadBitmap;
2. After a begin copy and pase the bitmap text into the script
3. You should have something that looks like this…
program New;
{.include srl/srl.scar}
procedure LoadBitmaps;
begin
procedure LoadBitmaps;
begin
chicken := BitmapFromString(17, 24, 'beNq9lF0rg3EYh78ADuUDo' +
'OUIpYjigMbW3mcmjBizNSNtDTMvebeQtfLWMpmllEZraUlygpRTX8' +
'dV/3p62suTnajr8L7+9/2772fTawYsKrAY6iXsNrOEzWqQsJh0gkL' +
'FoK1VqC+lCKR6b3XlPyjZq1BZSnR9Yrq6oizlMDzqr6mSK/LiQsUz' +
'oo6EHLnkioIi1cPsuHZmrG9vcThzufQXhceXvGbYDg6lL4KlFKl+0' +
'z8IAZch7LNCqS7yel5enbMJEUplkb/PVFisV8BdPh728xR5vejCbi' +
'F57HtOrTLYe3oX8hRRCawIYhtOIPjT9TK83K4JJEXEpJKRuMX8pC4' +
'e8VAPTAU0AjoKJeg2Sfy86hyWLs5BBB7/yh5/507R788Dj/EFkMeP' +
'hJsZ7zPT269tAzqmonNAhLMdl0hBNLkScDcI9D0twJKBkd7uNgilf' +
'Bd1ZyNwR1aROPAyP0PexNqLLlnQ2lQHxIGTrSkaJY7aQEGBjhaV09' +
'4NLJDIeb99hS+ZVYvLyhWjXqOgFP2HMf4CmBSm3g==');
end;
begin
end.
Now you need to define the Bitmap as a integer. This goes in as a global variable (variable not in a procedure). Now you should have something like this
program New;
{.include srl/srl.scar}
var
chicken : Integer;
procedure LoadBitmaps;
begin
chicken := BitmapFromString(17, 24, 'beNq9lF0rg3EYh78ADuUDo' +
'OUIpYjigMbW3mcmjBizNSNtDTMvebeQtfLWMpmllEZraUlygpRTX8' +
'dV/3p62suTnajr8L7+9/2772fTawYsKrAY6iXsNrOEzWqQsJh0gkL' +
'FoK1VqC+lCKR6b3XlPyjZq1BZSnR9Yrq6oizlMDzqr6mSK/LiQsUz' +
'oo6EHLnkioIi1cPsuHZmrG9vcThzufQXhceXvGbYDg6lL4KlFKl+0' +
'z8IAZch7LNCqS7yel5enbMJEUplkb/PVFisV8BdPh728xR5vejCbi' +
'F57HtOrTLYe3oX8hRRCawIYhtOIPjT9TK83K4JJEXEpJKRuMX8pC4' +
'e8VAPTAU0AjoKJeg2Sfy86hyWLs5BBB7/yh5/507R788Dj/EFkMeP' +
'hJsZ7zPT269tAzqmonNAhLMdl0hBNLkScDcI9D0twJKBkd7uNgilf' +
'Bd1ZyNwR1aROPAyP0PexNqLLlnQ2lQHxIGTrSkaJY7aQEGBjhaV09' +
'4NLJDIeb99hS+ZVYvLyhWjXqOgFP2HMf4CmBSm3g==');
end;
begin
LoadBitmaps;
end.
If you didn’t notice, I did mine of a chicken on the main screen. That was only because it was the only picture that I had handy. Usually you should use bitmaps for things that are not on the main screen (or something that is in your bank). Anyways…
Now you need to actually click/interact with the bitmap so you would add…
procedure ClickBitmap;
var
x,y : Integer;
begin
if FindBitmap(chicken,x,y) then
begin
Mouse(x,y,3,3,True);
end;
end;
FindBitmap will put the coordinates into x an y if it finds the bitmap, in this case chicken. Then you need to mouse to the coordinates to click it.
You need to make sure that you free your bitmaps so they don’t rape your memory any more than they already do.
FreeBitmap(Bitmap);
Just input the bitmap that you want to be freed. If you have more than one bitmap it is good to put them all in a procedure and just call the procedure when you need it.
Make sure that you free the bitmaps as soon as they are no longer needed. You should load them right before they need to be used.
LoadBitmaps;
ClickBitmaps;
FreeBitmaps;
If you forget to/don’t free your bitmaps your script will lag because you will eventually run out of memory to hold the bitmaps in.
DTM’s
DTM’s (deformed template meshes (this shows the effectiveness of the search button) are another way to find items. They are like bitmaps but much faster and accurate(ß I think). So why did we just learn about bitmaps? Hell if I know. I guess it was because bitmaps were in all of the tutorials that I read to learn. Maybe because you should learn as much as possible about using SCAR; it will help you to progress faster.
Making a DTM
1. Open SCAR
2. Open your screen shot of the item in your inventory
3. In SCAR go to Tools> DTM Editor…
4. You should get a popup that shows the window behind SCAR
5. Maximize this window if you don’t see the area where the item is located. You may have to move the background image around a bit before opening the DTM editor to get the right view.
6. Click in the middle of the item that you wish to make a DTM of. You should now have a blinking dot in the middle of it.
7. Move to the outside of the object/image. The zoomed in view in the top left should show you that the item is surrounded by a 1 pixel wide band of black. This is where you need to click.
8. You should see a line of red connecting two blinking dots. One in the middle and one in the black band.
9. Make a few more lines by clicking on the black band, trying to keep an even spread between the lines. (One straight up, one down, one left, one right…) try to get an even spread.
10. Set the tolerance on the right side from 10-15. The lower the tolerance the more chance it has of not being confused by a similar object. If the tolerance is to low then it willn’t find the correct object. If the tolerance is too high it will pick the wrong one. 10 ususally seems to be a good balance.
11. Select File>DTM to Text
12. You should get a print out in the debug box that looks similar to this…
DTM := DTMFromString('78DA63AC606060106240019B1819194480342' +
'310FF0702C61A208319554D2E0F3B986684F2195B800417AA9A5A' +
'46465435D540420655CD1E7435F940421855CDCF0F1F50D51460D' +
'A75AAB010450D007E480E3D');
That was a DTM of my call wave…but…that is how you create a DTM.
Incorporating a DTM into a script
program DTM Example;
{.include srl/srl.scar}
var
x,y,DTM : Integer;
procedure LoadDTMs;
begin
DTM := DTMFromString('78DA63AC606060106240019B1819194480342' +
'310FF0702C61A208319554D2E0F3B986684F2195B800417AA9A5A' +
'46465435D540420655CD1E7435F940421855CDCF0F1F50D51460D' +
'A75AAB010450D007E480E3D');
end;
procedure ClickDTM;
begin
If FindDTM(DTM,x,y,0,0,1000,1000) then
Mouse(x,y,0,0,True);
If not FindDTM(DTM,x,y,0,0,1000,1000) then
WriteLn('Didnt find DTM');
end;
begin
SetupSRL;
LoadDTMs;
ClickDTM;
FreeDTM(DTM);
end.
You need to declare your DTM as an integer. Then you need to make a loading procedure, just like a bitmap. The command for finding a DTM is
FindDTM(DTM name,x,y,coords…);
I put in 0,0,1000,1000 because I was looking for something on my desktop. You will most likely be looking for something in your inventory so you would use MIX1,MIY1…
Make sure that you free your DTM after you are finished using it. You don’t want a memory overflow error.
Note–Don’t use DTMs or Bitmaps for finding objects on the main screen. They can rotate when you turn the screen making it a very unreliable method.
TPA’s
TPA’s are the newest and bestest way to find things on the main screen. Since I do not fully understand the concept or use of TPS’s, here are some links that should help you out. If all else fails then you could use the search button or join the IRC channel
IRC- http://www.villavu.com/forum/showthread.php?t=28996?t=31532
Search - http://www.srl-forums.com/forum/search.php
TPA tutorials - http://www.villavu.com/forum/showthread.php?t=33111?t=35862
http://www.villavu.com/forum/showthread.php?t=38295
If you think that your TPA tutorial should be on this list then pm me or post here and I will slap it up. When I get my face around the concept I will post the super dumified version of how to use TPA’s.
AntiRandoms
Anti randoms should be included in every RS script. It is what checks if your character is in a random event and then attempts to solve it or runs/logs out to save you from a ban/death. Without random solving autoing would last about 5 mins before the character got stuck in a random and then just sat there. So include AntiRandoms.
procedure AntiRandoms;
if not LoggedIn then
Exit;
FindNormalRandoms;
if InFight then
RunAway('n', True, 1, 10000);
end;
You don’t want it to preform antirandoms while not logged in so you include the if not logged in then part like always. Then you have FindNormalRandoms; This will attempt to solve randoms if they are found.
InFight checks if your character is under attack. In this case if the character was under attack it would run away
RunAway(‘direction’,RunFar,Action,Wait time);
‘Direction’ is ‘n’ for north, ‘s’ for south and so on. RunFar True makes it run further away. False it doesn’t run as far. Action is in the form of 1, 2, or 3. Wait time is how long to wait before running back.
Action can be either 1, 2 or 3.
1: RunAway + Wait(WaitTime) + RunBack
2: RunAway + Wait(WaitTime)
3: RunBack
Obivously you would only use RunAway if you were making a script that did not include fighting (or if your health was low while fighting).
The AntiRandom procedure should be called whenever you could get a random. Try putting it in your main loop or in you procedure where you are actually doing something. Example–while you are waiting for your character to cut down a tree, or right after the character begins to cut.
Multiplayer
Multiplayer was developed a while ago. It was one of the major inovations is RS botting. It allows you to bot with more than one character without changing the script. This decreases randoms and banning. If you do get banned then you likely still have another bot that you were already working on. These groups of bots are known as armies. To add multiplayer to a script you must add this…
Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Integers[0] := 0;
Players[0].Active := True;
end;
Set current player to the one you want to run first. 0 would be the one that you enter after Player[0]. Enter the RS name uneder name and then the password under Pass. The nickname goes under Nick. Nicknames are 3 or 4 letters of your username that are contiguous (in a row). If your username was Runescape you would use something like esca or scap or unes. Make sure that you don’t use the starting letter of your name. The nickname is what checks to see if a random is after your player. It will say something like “Character come with me.” SCAR will see that the nickname is in there and it will know that the random is after you. Then it can do AntiRandoms. If you do not have a DeclarePlayers procedure then AntiRandoms will not work.
Set the player for active = true if you want that player to be run in the script. Set false if you don’t want that player slot to be run.
Procedure DeclarePlayers;
begin
HowManyPlayers := 3;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Integers[0] := 0;
Players[0].Active := True;
Players[1].Name := '';
Players[1].Pass := '';
Players[1].Nick := '';
Players[1].Integers[0] := 0;
Players[1].Active := True;
Players[2].Name := '';
Players[2].Pass := '';
Players[2].Nick := '';
Players[2].Integers[0] := 0;
Players[2].Active := True;
end;
More player slots can be added by copy and pasting the main section and then changing the number value +1 (0à1à2…). Make sure that you set the number of how many players to the correct amount.
LoginPlayer;
This logs in the current player. In the cases above it would be player0 or the first one. To implement this into a script you need to have some way to let SCAR know when to change players.
if (LoadsToCut <= LoadCounter) then
NextPlayer(True);
This is what I used in my power cutter. LoadsToCut is a constant asking how many full loads you want to cut per player. LoadCounter is a variable that gets increased everytime the inventory gets full and logs have to be dropped. NextPlayer tells SCAR to switch CurrentPlayer: = 0; to CurrentPlayer: = 1; If your argument is true then the player that just ran will remain active. If it is False then the player will not be active and will be skipped next time their turn comes up. True should be used if you just want players to swich. False should be used if you find that your player is no longer functioning as is should, if the character is found dead or stuck in a random.
Normally I would now explain how to put all of this together to make a script, but this tutorial has become quite lenghty without my noticing. I hope to write a tutorial soon that will be a follow-up to this one. Explaining how to add all of this together. It should still be a good referance for looking up things you may have forgotten.
If you notice any errors in this tutorial please post here or pm me so that I can fix them. I want this tutorial to be as accurate as possible. If you have a tutorial that you think it would be good for me to link to then also please pm a link. Suggestions are welcome.
Do not spam this post. I don’t want any posts that say something like “Good Job” or “I think it was dumb.” If you want to post a comment, explain why you (dis)liked it.