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!
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!