PDA

View Full Version : Using SRL...



WT-Fakawi
07-04-2006, 09:02 PM
This tutorial is for all folks having trouble working with SRL. Please read on, it will only take five minutes of your time...


SRL := MultiPlayer.

SRL is designed to work with multiple Players, all lined-up, one-by-one, one-after-the-other. We need multiple Players because Jagex developed a number of unsolvable traps. Thus certain AntiRandoms will stop every script and thus limit profit.
So, in order for a good SRL-script to run properly you need to setup your Players. SRL uses a Player Record, a structure that holds the different Player properties, like its Name, its Password, its ScreenName, its Skilllevels etc.


The Player Record.


type
TUser = record
Name: String; // * User Name
Pass: String; // * User Pass
Nick: String; // * Screen Name for random detection
Active: Boolean; // * Set to True if Ok, False if Lost.
Loc: String; // * User Location
Rand: String; // * Stuck inside Random
Skill: String; // * User Action to Perform
Level: array[0..21] of word; // * Levels of all skills. SetIn GetPlayerLevels.
Worked: Integer; // * Time User has worked
Banked: Integer; // * Number of Banks User has done
Booleans: Array of Boolean; // * For reports, etc.
Integers: Array of Integer; // * For reports, etc.
Strings : Array of String; // * For reports, etc.
Extendeds : Array of Extended; // * For reports, etc.
end;



Players are arranged in arrays. I do hope you are familiair with those, if not familiarize yourself with the use of arrays!.


var
Players : array of TUser;


Suppose we have 4 Players. We will need to declare an array of 4 Players. SRL has a function that does just that:


procedure NumberOfPlayers(Number: integer);
begin
SetArrayLength(Players, Number);
end;

Just call
NumberOfPlayers(4); if you want to use 4 Players.


Adressing Players.

The first Player in our array is Player[0], the second Player[1], andsoforth, until we come to Player[3] which is our fourth Player. This is somewhat confusing, but it is the way arrays work. If you don't address Players wisely, you will get an out of range error.
So, the name of our first Player is Player[0].name, the password of our fourth Player is Player[3].Pass.
Besides Name and Pass there are two more properties you will need to know about: Players.Nick and Players.Active.

Players.Nick

Nick is your screen name.Your RuneScape Name appears in yellow on the mainscreen whenever a Talking Random addresses you. This is what we continiously scan for (using FindTalk), and it is the heart of SRL AntiRandoms routines. Imagine your Player Name is 'qwertyuiop', you would typically use three or four letters from this name as Nick. So Player[0].Nick:='wer' or 'tyu' or 'iop', but NOT 'qwe', since First Letters Are Always Capitalised in RuneScape. It is absolutely vital to understand this concept, otherwise randoms wont work, and you will die or be banned pretty soon.

Players.Active

Though not particularly evident, this is a very important hidden Player Property. Active determines whether a Player is well, standing at a known place and working for you. You will only need to set Active once, at script startup: Players[0].Active:=True. From that moment on, Active will be handled automatically. (Technically speaking: If not LoggedIn then Players[CurrentPlayer].Active:=False at NextPlayer(False) ) So, dont forget to set your Players Active at startup!


All other Player Properties are optional and are not required for proper script functioning. Most are arbitrary Properties that the programmer may use to his/her hearts content.


Players.[CurrentPlayer]

CurrentPlayer is a Global Variable representing the internal counter that keeps track of which Player is Playing. If not set the Script will use the initial value 0, thus starting with Players[0]. Players[CurrentPlayer] is the online Player. If you Set CurrentPlayer to 3 at script startup, your script will start with Player 4 in the Array. CurrentPlayer is switched inside the Function NextPlayer.


Procedure NextPlayer(Active: Boolean);

One more vital function in multiplayer SRL is NextPlayer. NextPlayer switches Players. It logs the CurrentPlayer out and Logs in next Player, making it CurrentPlayer. NextPlayer is ideally called whenever the Player has done its job and is ready to switch.You call NextPlayer(True), indicating our Player is fine and standing at a known place.
But under less ideal situations, in case our Player is in trouble, trapped or loggedout, NextPlayer(False) is called (If not loggedin then NextPlayer(False))at the last line of the script, safely switching Players and removing the unfortunate Player from the active queue, e.q. Players[CurrentPlayer].Active is set to False. This player will no longer log in, and it is to the rest of our army to continue its job.



Setting Up SRL.

Be sure to:{.include SRL/SRL.scar}
at the top of your script, and call: SetupSRL; at script startup.

Setting up your Players.


program SRLTest;
{.include SRL/SRL.scar}

Procedure DeclarePlayers;
begin
NumberOfPlayers(HowManyPlayers); // Sets the Players Array Length;
CurrentPlayer:=3;

Players[0].Name :='qwertyuiop';
Players[0].Pass :='';
Players[0].Nick :='iop';
Players[0].Active:=True;

Players[1].Name :='asdfghjkl';
Players[1].Pass :='';
Players[1].Nick :='fgh';
Players[1].Active:=True;

Players[2].Name :='zxcvbnm';
Players[2].Pass :='';
Players[2].Nick :='xcv';
Players[2].Active:=True;

Players[3].Name :='poiuytrewq';
Players[3].Pass :='';
Players[3].Nick :='oiu';
Players[3].Active:=True;
end;

Procedure StartScript;
begin
SetupSRL;
DeclarePlayers;
LoginPlayer;
end;


This is basically all you the setup you will need to do in order to succesfully work with SRL.
Over to the main loop.

MainLoop.


repeat

if Players[CurrentPlayer].loc='Dalafor' then
begin
WalkToMine;
end;

if Players[CurrentPlayer].Loc='Timmingron' then
begin
repeat
Mine;
if (not(Loggedin)) then break;
until(InventoryFull)

WalkToDalafor;
Bank;
ProgressReport;
end;

if ((LoggedIn) and (Players[CurrentPlayer].Banked mod Loads = 0)) then
begin
SetChat('off', 1);
repeat
Wait(1000);
FindRandoms;
until(not(LoggedIn));
NextPlayer(true);
end;

if (not(Loggedin)) then NextPlayer(false);
until(false);

This is a typical example of how you might want to setup a mainloop using SRL. The first two are simple: walk-mine-walk-bank. But notice the use of if (not(Loggedin)) then break; inside this loop:


repeat
Mine;
if (not(Loggedin)) then break;
until(InventoryFull)

This is essential!

You have to break out of every loop. Let me say that again, only louder this time:
YOU HAVE TO BREAK OUT OF EVERY LOOP. In SRL there are no endless loops.You wont find a single endless loop in the SRL Library. All functions or procedures break one way or the other. It is vital for proper SRL scripting. Do not use:


repeat
//Something here
until(false);

but break, make timed loops, create conditions to break from your loop! A nice break is:
if takes too long then logout;

and in the rest of your script:


if not loggedin then exit;
(exept in your mainloop ofcourse...)

Now, notice the last line: if (not(Loggedin)) then NextPlayer(false);This is the final instruction of the script. Something went wrong and we where logged out for some reason. The Player is False. We pass this to NextPlayer, thus setting Players.active to False. It is removed from the list and the next True Player is logged in.

This system continues until all Players are false, and thus our script ends.This is what I have made, and this is the true heart of SRL. If you keep close to these rules, you will be succesfull!


Enjoy!

Sjoe
07-04-2006, 09:06 PM
w00t first post on this great tutorial :d (which I'm gonna learn afterwards)

blackfire553
09-19-2006, 02:54 AM
This tutorial is for all folks having trouble working with SRL. Please read on, it will only take five minutes of your time...

cool, good tut.

bibi26
09-22-2006, 04:31 PM
Woah, thanks alot, useful for making my multi-login :)

Thanks :D

naterocks42
10-08-2006, 12:18 AM
errr... how do you use the srl...like the screen

Hey321
11-18-2006, 12:38 PM
Good tut, although i dont get this. You say there are NO endless loops. Yet in the script ending you showed us, it say

until(false)

Why?

IronTeapot
11-18-2006, 04:34 PM
Because that is not an endless loop


if (not(Loggedin)) then NextPlayer(false);
until(false);


that is what determines the condition. if no players can log in, and all are set to false, then untill(false) is now true and the loop will end.

Hey321
11-18-2006, 04:42 PM
Ahh... Ok i get it now thanks.

Boreas
11-18-2006, 06:15 PM
Actually false will always be false. The repeat loop won't end. What Iron means is that if there are no active players to login in, nothing will happen. The script will still be running, but nothing will be happening, so you have control of the mouse and wont get stuck, and you can easily click stop. until false doesn't mean endless loop nescessarily. Take these 2 examples.

If you have until (false), but somewhere in the loop it says, if blahblah then terminatescrip;, then it's not really an endless loop, because when blahblah is true, it will stop. Obviously blahblah could mean that it is lost or something.

The second example is without until(false), but still being endless loop.
repeat
someotherstuffhere
point[i].x:=x;
point[i].y:=y;
someotherstuff here
until i=100;
There is no i:=i+1; in there, so i will never be 100, and it will never end. I have forgotten to do this a couple times, sometimes it means the scrip does nothing, but if you have a mmouse in there, you'll have to end the process! No it's easy to see there is no i:=i+1 in there, but trust me, when it gets bigger (thats why I put someothertsuffhere) it's easy to miss.

Wiz4life2
11-25-2006, 09:49 PM
What do u do if your only using 1 player.. ?? Just delete the others? Wich player would u be using player 0????? or 1????

Bramble
11-26-2006, 05:43 AM
thanks alot for that bit of info

bell1313
01-12-2007, 09:38 PM
Hmmm, i dont get it, has someone got an example of like those two scripts combined. You dont even want to see my feeble attempts lol!

pwnaz0r
01-18-2007, 04:04 AM
gr8 thnx needed it =p

Mjordan
02-01-2007, 07:13 PM
thanks this helped me understand using multi players even more

WhoCares357
02-01-2007, 08:01 PM
Thanks WK. Helped me alot. +rep

Westside Rep
02-13-2007, 02:58 AM
A Question: Do you have to put The Whole player record In your script (Just like you did)? Or at least up to where it says String1, boolean2, etc. Someone answer this please.

Secet
03-02-2007, 09:12 PM
Never knew that I can't use nick Sec, but it should be ece! Thanks, that's why it doesn't findtalk, this guide really helped, good job! :)

obrian93
03-08-2007, 02:22 AM
I wandered over to this thread knowing absolutely nothing. Now I know very very little!

The difference, however, can hardly be expressed. Thanks for a wonderful, clear tut. You've cracked the shell of SRL for me. Now to dig in . . .

Thanksthanks!

bustinthejus
03-17-2007, 04:17 AM
Yea thanks. I never really understood what the player:active was for.

ranojit
03-27-2007, 03:43 AM
ok (this is kind of noobish) um i get the whole concept of the nickname and what you have to put to turn on srl but i still dont get how how the players thing works. like does the stuff get transferred or what happens because i dont understand.

Ramage
03-27-2007, 04:04 AM
I don't exactly get what you mean.. but yeah:

Each player gets a specific amount of time or something and once that factor is up, the player logs out and the script automatically logs into another one of your accounts.

drShadowz
04-23-2007, 09:05 PM
Awesome Tutorial.

Thanks for the info. I used the program last night forhte first time and set my nick to the first 3 letters of mycharacter name. Sandwich lady got me after an hour. now I know why!

Well Done!

evilwalrus
05-27-2007, 01:51 AM
omg i understand scar alot better now, thanks so much! the pictures also helped

skibby
05-27-2007, 02:50 AM
Thx alot man

gillian
05-29-2007, 09:29 AM
*smacks forehead* first lesson of anything .. read the instructions :D I have been commenting on scripts' failure to deal with randoms .. and, it seems, the failure is on my part cuz I didn't understand the darn nick :) TY!

randy marsh
06-12-2007, 02:30 AM
Hello im a noob , so say i get a woodcutting scirpt and copy the scirpt into the scar window, Do i have to set up the "Setting Up SRL." and the "Setting up your Players." and the "MainLoop" bits my self ot his this include in the script?

BobboHobbo
06-12-2007, 06:51 AM
Nice guide, nice detail and color in writing.

randy marsh
06-12-2007, 11:56 PM
help me please!

The devil
06-17-2007, 03:41 AM
Hey thanks fawaki for that.

abba00221
07-18-2007, 08:20 PM
my scar write this: Found compass-where i can find tutorial for this?

han941306
08-13-2007, 03:14 PM
A cool Tut..
Learned more about DeclarePlayers from here..
Thanks a lot.

Anty88
08-17-2007, 10:42 PM
Awesome tut, thank you :(h):

mihkel50
09-03-2007, 11:26 AM
Thanks for the guide, should get my scripts better with it.

Fuzion X
09-08-2007, 04:48 PM
its good...very nice!

skilld u
10-03-2007, 10:23 PM
thanks. helped alot.

davidwang95
10-10-2007, 07:33 PM
Wait, where do you put "declare players"?

Rikje
10-10-2007, 07:58 PM
DeclarePlayers;

but it on the begin of you script.
like:


//<the script>

{main loop}
begin
SetupSRl;
DeclarePlayers;
//<other stuff>
end.

mynameisjoe
10-13-2007, 02:57 AM
Thank you so much. This will surely help me send in a decent SRL script. Gotta love the player array. :D

M3talhe4d
10-20-2007, 03:50 PM
this was a really good read. It was really helpful for me, but I have a questiong regarding the mini-miner+banker.


repeat

if Players[CurrentPlayer].loc='Dalafor' then
begin
WalkToMine;
end;

if Players[CurrentPlayer].Loc='Timmingron' then
begin
repeat
Mine;
if (not(Loggedin)) then break;
until(InventoryFull)

WalkToDalafor;
Bank;
ProgressReport;
end;

if ((LoggedIn) and (Players[CurrentPlayer].Banked mod Loads = 0)) then
begin
SetChat('off', 1);
repeat
Wait(1000);
FindRandoms;
until(not(LoggedIn));
NextPlayer(true);
end;

if (not(Loggedin)) then NextPlayer(false);
until(false);

I'm just curious as to why your banking in "Dalafor" (as a opposed to Falador) and mining in "Tummingron" (as a opposed to Rummington)?
An explanation would be helpful, thanks.

synesthetics
11-01-2007, 07:09 PM
well, 1 thing is not clear to me. you said it is important to set the numbers of players..

NumberOfPlayers(4);


u can see you set a 4 between the hooks. (4).

but then you post an example like this:


Procedure DeclarePlayers;
begin
NumberOfPlayers(HowManyPlayers); // Sets the Players Array Length;
CurrentPlayer:=3;



you havent set the numbers of players between the hoops. like this

NumberOfPlayers(HowManyPlayers); // Sets the Players Array Length;
NumberOfPlayers(4); // Sets the Players Array Length;



what is the good one?


Edit: after some looking i saw someone say that i need to leave it unchanged.. is that so?

Tri
11-02-2007, 01:07 PM
ahh thanks I think I get what SRL is for now

lnknprkn
11-05-2007, 12:39 AM
thank you for this, it was easy to follow :)

xtatic10
11-07-2007, 07:53 PM
how do i set up a script

tico2
11-14-2007, 04:13 PM
thanks for the information

Dracody
12-18-2007, 05:38 AM
i understood it better thanks for the tut , very nicely done..

i c y k 1 d
12-20-2007, 12:06 AM
That helped me with alot, Thank you

upalot
02-09-2008, 12:52 AM
Great job lots of information

ranojit
02-24-2008, 10:06 PM
wow great tut it helped me understand SRL a lot

Adolis
02-27-2008, 04:47 AM
Very good tutorial. Helpful in understanding it. I'll have to come back and check it out when I have more time.

Adolis
03-01-2008, 09:25 PM
After looking through it, I became very confused. Since this is the tutorial island section, I think it's appropriate for me to ask how the arrays work and how I set the values for:
Rand: String; // * Stuck inside Random
Skill:'Mining' String; // * User Action to Perform
Level:'31' array[0..21] of word; // * Levels of all skills. SetIn GetPlayerLevels.
Worked: Integer; // * Time User has worked
Banked: Integer; // * Number of Banks User has done
Booleans: Array of Boolean; // * For reports, etc.
Integers: Array of Integer; // * For reports, etc.
Strings : Array of String; // * For reports, etc.
Extendeds : Array of Extended; // * For reports, etc.

After I set these values, I have my player record set right? Could you provide me with a complete example? I think I could learn it better if I compared what I'm making to an official player record. Thanks.

*Is it allowable for me to request an example?

stampede10343
03-01-2008, 11:13 PM
After looking through it, I became very confused. Since this is the tutorial island section, I think it's appropriate for me to ask how the arrays work and how I set the values for:
Rand: String; // * Stuck inside Random
Skill:'Mining' String; // * User Action to Perform
Level:'31' array[0..21] of word; // * Levels of all skills. SetIn GetPlayerLevels.
Worked: Integer; // * Time User has worked
Banked: Integer; // * Number of Banks User has done
Booleans: Array of Boolean; // * For reports, etc.
Integers: Array of Integer; // * For reports, etc.
Strings : Array of String; // * For reports, etc.
Extendeds : Array of Extended; // * For reports, etc.

After I set these values, I have my player record set right? Could you provide me with a complete example? I think I could learn it better if I compared what I'm making to an official player record. Thanks.

*Is it allowable for me to request an example?

im pretty sure you can ask for examples of these, i think i know what your trying to ask so here goes Players[0].Name :='qwertyuiop';
Players[0].Pass :='';
Players[0].Nick :='iop';
Players[0].Worked := 0;// You can keep this at zero and add time to it during a progress report
Players[0].Active:=True;
Players[0].Booleans[0] := false;//Lets say this is a mining script this could ask if pick was in inventory
Players[0].Integers[0] := 2;//Can be used to see how many loads to do
Players[0].Skill := 'mining';//This is used for genies to select which skill to use


Anything else just ask, and use [SCAR*] tags [/SCAR*] without the *'s ;)

laurenssie1
03-02-2008, 01:08 PM
That randoms are actually nice. I've won uncut diamond last night with the box :D

spykids007
03-02-2008, 07:30 PM
good tut but i still dont havesome questions answered but thanks i learned about the nickname thing!

rudehead
10-13-2008, 07:20 AM
Wow this would have saved me a lot of time if I'd read it before I started my first script.