Results 1 to 6 of 6

Thread: [TUT]Setting up your default script[Beginner]

  1. #1
    Join Date
    Jul 2008
    Posts
    907
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default [TUT]Setting up your default script[Beginner]

    I've not been around for a long time guys, so I thought I'd come back with a bang and give to the community as soon as I could Please note though, this is a really basic tutorial, I'm trying to teach and remember what I knew (plus adapt to Simba) all at the same time.

    Getting set up to script - Your base

    So, why do you need a default script?

    In my time scripting, I hated having to set up the same old boring stuff, (Players, antiban, randoms, breaks, etc) so I set up my default script. At the time it was much better, but that takes time, adaptations happen everytime you write a script, you'll get a new idea, utilise it, find a problem with it in the next script and improve it. This is ultimately a base, and a lot of it (if not all of it) you'll change.

    This should hopefully give you some insight into the following:
    • The ultimate basics
    • Setting up players
    • The use of constants and variables
    • Loops
    • AntiBan/Randoms
    • Breaking
    • Including reflection in a hybrid script (explained)

    Please remember that there is a glossary at the bottom of the post, please check up on any words you don't understand, and feel free to shoot me a PM .

    The Basics
    So first off, let's get up the script you'll see when you open up Simba for the very first time.
    Code:
    program new;
    begin
    end.
    I'm not going to go over this extensively, I assume that each line is fairly obvious in this particular example. You can replace "new" with whatever name you like, it doesn't make the slightest difference. The "begin" and "end." are the mainloop (explained below).

    The mainloop is the section of the script which is acted upon by Simba, you could have a hundred procedures in your script but, unless you "call them" in your mainloop, they'll do absolutely nothing.

    Tips: The "end" in the mainloop is the only one that is followed by a period. This signals that the script has come to an end, thereby stopping it.

    You must place a semicolon at the end of the majority of lines, there are some exceptions (for instance, lines that only consist of "begin").

    So, getting started

    Well the very first thing you'll want to do is get in your includes. Being your default script, it's always best to get them all in so that you can take out the ones you don't want. For instance, the beginning of my default script goes like this:
    Code:
    {$Def Reflection}
    program Base;
    {$DEFINE SMART}
    {$i srl/srl.scar}
    
    {$IfDef Reflection}
    {$i reflection\reflection.simba}
    {$EndIf}
    So, analysing each line:

    {$Def Reflection}
    This line is fairly simple to understand, and extremely useful for a lot of things. It basically means "Define Reflection". This means that whenever you call {$IfDef Reflection} (If Define Reflection) in your script, the code following it, is run. If you don't define reflection, the script skips that part of the code. As I'm sure you can see, this allows for a lot of simple script editing. Consider a user wishing to take out breaks. Rather than messing with constants (or even the mainloop!) they could simply delete the line that defines breaks. It won't cause any compiling errors, and the script will still work perfectly

    program Base;
    This is simply the program name, as described above.

    {$DEFINE SMART}
    This one is different to the define used above; this is specifically used for Smart, and actually adds the Smart include to the script for you.

    {$i srl/srl.scar}
    This line adds the SRL include to the script. There is another way to do this, but in keeping with the seeming order of the script, I prefer this one. If you truly wish to know, you could replace it with "{.include srl/srl.scar}".

    {$IfDef Reflection}
    {$i reflection\reflection.simba}
    {$EndIf}

    I'm taking these three together because they come as a cohesive unit. I've already talked about the first line, and I think it's safe to assume you can figure out what the second means. The final line is directly linked to the first, and is necessary for the script to compile. It ends the "if statement, so that if reflection ISN'T defined, everything after the IfDef line, but before the EndIf line, will not be run.

    Getting onto the Runescape stuff

    So, we have out includes, you know how the ultimate basic script works, I think It's about time to get started adding in something to do with Runescape. Before that though, I want you to add these lines under what you already have:
    Code:
    Const
    {---SMART Setup Constants---}
      WORLD = 121;// Set a world, if you'd like.
      MEMBERS = False;// Change accordingly.
      SIGNED = True; // True if running a single account, false otherwise.
    {---------------------------}
    These are your constants, throughout the entire script, these will not change, no matter how you use them. This makes them useful for things in the script that never change, such as, to give an example from an old script of mine that I recall: which ore you shall smelt into which bar. Of course, there are ways to change this per player, but I'm sure you get the idea

    These specific constants are used for setting up Smart in the mainloop.
    Tip: "//" and "{}" allow characters in the script to be skipped over, allowing you to use notes without causing compiling errors.

    So, once you have those in, let's sort out some players
    Code:
    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
    
      Players[0].Name := 'Username'; 
      Players[0].Pass := 'Password'; // Password
      Players[0].Nick := 'sern'; // 3-4 lowercase letters from username
      Players[0].Active := True; // Set to true if you want to use this player
      Players[0].Pin := '0000'; // Leave blank if the player doesn't have a bank pin
    end;
    Add this section of code under your constants. This allows the user to specify which accounts they want to use in the script. In this procedure you can add more than the single player shown here, allowing you to use multiplayer in your scripts. I believe this is fairly self-explanatory.

    So.. anyone want to prevent a ban?

    Next in the script comes the Anti-Ban, this you will always have to update, you should really make your own anti-ban functions, I'm just using some of the SRL ones as a demonstration.

    Code:
    procedure AntiBan;
    begin
      case Random(6) of
      0: HoverSkill('Random', False);
      1: begin
           RandomMovement;
           HoverSkill('Random', False);
         end;
      2: BoredHuman;
      3: BoredHuman;
      4: ExamineInv;
      5: begin
           RandomAngle(1);
           HoverSkill('Random', False);
           ExamineInv;
         end;
      end;
    end;
    So, past the procedure's name, we have a case of loop. I used the integer value of "Random(6)" so that, each time the procedure is run, it will use one of the 6 random anti-ban functions. Think about it, if it wasn't random, it wouldn't be very good anti ban now would it?

    Also important in this section is the AntiRandoms. The following procedure is possibly the most simple ever, as all it does is call the SRL AntiRandoms, along with the reflection one. It should be called as frequently as possible.

    Code:
    procedure AntiRandoms;
    begin
      {$IfDef Reflection}
      R_FindRandoms;
      {$EndIf}
      FindNormalRandoms;
    end;
    Note: The IfDef function returns

    Breaking

    Before we get the actual breaking procedure out of the way, I would like you to update your constants. Please replace them with the following.

    Code:
    const
    {-----Breaking Settings-----}
      TakeBreaks = True; // Take breaks?
      HowOften = 90; // How often to break in minutes
      HowOftenRandom = 30; // Added randomness to how often you break
      HowLong = 20; // How long to break for in minutes
      HowLongRandom = 8; // Added randomness in break length
    {---------------------------}
    {---SMART Setup Constants---}
      WORLD = 121;// Set a world, if you'd like.
      MEMBERS = False;// Change accordingly.
      SIGNED = True; // True if running a single account, false otherwise.
    {---------------------------}
    Along with that, I would like you to add some variables in under the constants. Variables can be changed freely during runtime.

    Code:
    Var
    BreakOften, BreakLength, BreakTimes: Integer;
    Now then, this section may be the first time you are introduced to using Math in Simba. It's fairly simple, just remember that, when using wait functions, everything is measured in milliseconds, so to wait one minute, you would have to call "Wait(60000);".

    Code:
    procedure BreakCheck;
    begin
      if not LoggedIn then // This is a simple failsafe, if the player isn't logged in at this point, it's safe to assume the script has messed up, and therefore the player should be set inactive, and the function exited.
      begin
        Players[CurrentPlayer].Active := False;
        Exit;
      end;
      BreakOften := ((HowOften*60000)-(HowOftenRandom*60000)+Random(HowOftenRandom*120000)); // This used the constants to work out when to break, with a certain degree of randomness.
      if GetTimeRunning >= BreakOften*BreakTimes then // This checks whether or not the time the script has been running is over the amount of time that should pass between breaks * the number of breaks (see if you can figure out why ;))
      begin
        BreakLength := ((HowLong*60000)-(HowLongRandom*60000)+Random(HowLongRandom*120000)); // This is similar to the formula above.
        Logout;
        Wait(BreakLength);
        LoginPlayer; // This, along with the two above, should be self-explanatory.
      end;
    end;
    So, we're coming close to the end..

    I think the last procedure we really need to add, is a simple, easily edited progress report. For this, we're going to have to update our constants again. Please replace them with this:
    Code:
    const
    {-----Breaking Settings-----}
      TakeBreaks = True; // Take breaks?
      HowOften = 90; // How often to break in minutes
      HowOftenRandom = 30; // Added randomness to how often you break
      HowLong = 20; // How long to break for
      HowLongRandom = 8; // Added randomness in break length
    {---------------------------}
    {---SMART Setup Constants---}
      WORLD = 121;// Set a world, if you'd like.
      MEMBERS = False;// Change accordingly.
      SIGNED = True; // True if running a single account, false otherwise.
    {---------------------------}
    {--------Script Info--------}
      Author = 'Username';
      Name = 'Base';
      Version = '1.00';
    {---------------------------}
    So that's the basic script information in, which allows you to easily update things such as the version number, without screwing up the perfect alignment of your proggy. As for that:
    Code:
    procedure ProgressReport;
    begin
      WriteLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
      WriteLn(Name + ' by' + Author + ' V' + Version);
      WriteLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
    end;
    When ran, this will currently only output
    "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Base by Username V1.00
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"

    You can add other things however, such as a time running, or you could have a variable for something like the amount of logs cut, which is incorporated, I'm sure you get the idea.

    The Mainloop

    This is it, the most integral part of your script. Without this, when you press run, nothing will happen, and your user will be left with a feeling of betrayal and dissapointment. Is that what you want? -.-

    Code:
    begin
      Smart_Server := WORLD;
      Smart_Members := MEMBERS;
      Smart_Signed := SIGNED;
      Smart_SuperDetail := False; // These four lines, setup and run Smart, using the constants you made earlier.
      SetupSRL; // This is used to setup SRL's base features, and is almost always necessary.
    
      {$IfDef Reflection}
      SetupReflection;
      {$EndIf} // Hello again IfDef. If you haven't noticed, EVERYTHING to do with reflection is surrounded by this, so it is very easily removed.
    
      DeclarePlayers; // This runs your DeclarePlayers procedure, setting them up to run
      LoginPlayer; // This logs in your first player.
      repeat // This is the start of a loop, it will repeat until the conditions set after the until below are met.
        BreakCheck; // Runs the breaks
    
      until AllPlayersInactive; // This means that, once all characters have failed, the script will stop.
    end.
    It's all annotated for you Should be easy enough to understand. So, if you followed that perfectly, you should have a script that looks something like this:
    Code:
    {$Def Reflection}// Delete this line if you don't wish to use reflection (script will likely work much less efficiently)
    program Base;
    {$DEFINE SMART}
    {$i srl/srl.scar}
    
    {$IfDef Reflection}
    {$i reflection\reflection.simba}
    {$EndIf}
    
    const
    {-----Breaking Settings-----}
      TakeBreaks = True; // Take breaks?
      HowOften = 90; // How often to break in minutes
      HowOftenRandom = 30; // Added randomness to how often you break
      HowLong = 20; // How long to break for
      HowLongRandom = 8; // Added randomness in break length
    {---------------------------}
    {---SMART Setup Constants---}
      WORLD = 121;// Set a world, if you'd like.
      MEMBERS = False;// Change accordingly.
      SIGNED = True; // True if running a single account, false otherwise.
    {---------------------------}
    {--------Script Info--------}
      Author = 'Username';
      Name = 'Base';
      Version = '1.00';
    {---------------------------}
    
    Var
    BreakOften, BreakLength, BreakTimes: Integer;
    
    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
    
      Players[0].Name := ''; // Username
      Players[0].Pass := ''; // Password
      Players[0].Nick := ''; // 3-4 lowercase letters from username
      Players[0].Active := True; // Set to true if you want to use this player
      Players[0].Pin := '0000'; // Leave blank if the player doesn't have a bank pin
    end;
    
    procedure AntiBan;
    begin
      case Random(6) of
      0: HoverSkill('Random', False);
      1: begin
           RandomMovement;
           HoverSkill('Random', False);
         end;
      2: BoredHuman;
      3: BoredHuman;
      4: ExamineInv;
      5: begin
           RandomAngle(1);
           HoverSkill('Random', False);
           ExamineInv;
         end;
      end;
    end;
    
    procedure AntiRandoms;
    begin
      {$IfDef Reflection}
      R_FindRandoms;
      {$EndIf}
      FindNormalRandoms;
    end;
    
    procedure BreakCheck;
    begin
      if not LoggedIn then
      begin
        Players[CurrentPlayer].Active := False;
        Exit;
      end;
      BreakOften := ((HowOften*60000)-(HowOftenRandom*60000)+Random(HowOftenRandom*120000));
      if GetTimeRunning >= BreakOften*BreakTimes then
      begin
        BreakLength := ((HowLong*60000)-(HowLongRandom*60000)+Random(HowLongRandom*120000));
        Logout;
        Wait(BreakLength);
        LoginPlayer;
      end;
    end;
    
    procedure ProgressReport;
    begin
      WriteLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
      WriteLn(Name + 'by' + Author + 'V' + Version);
      WriteLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
    end;
    
    begin
      Smart_Server := WORLD;
      Smart_Members := MEMBERS;
      Smart_Signed := SIGNED;
      Smart_SuperDetail := False; // These four lines, setup and run Smart, using the constants you made earlier.
      SetupSRL; // This is used to setup SRL's base features, and is almost always necessary.
    
      {$IfDef Reflection}
      SetupReflection;
      {$EndIf} // Hello again IfDef. If you haven't noticed, EVERYTHING to do with reflection is surrounded by this, so it is very easily removed.
    
      DeclarePlayers; // This runs your DeclarePlayers procedure, setting them up to run
      LoginPlayer; // This logs in your first player.
      repeat // This is the start of a loop, it will repeat until the conditions set after the until below are met.
        BreakCheck; // Runs the breaks
    
      until AllPlayersInactive; // This means that, once all characters have failed, the script will stop.
    end.
    Now, press Script>Compile on the toolbar, everything should run fine

    A simple adjustment you can make

    So, you have your template, but perhaps you want to add multiplayer? Update both your DeclarePlayers, and mainloop.
    Code:
    procedure DeclarePlayers;
    begin
      HowManyPlayers := 2; // note this
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
    
      Players[0].Name := ''; // Username
      Players[0].Pass := ''; // Password
      Players[0].Nick := ''; // 3-4 lowercase letters from username
      Players[0].Active := True; // Set to true if you want to use this player
      Players[0].Pin := '0000'; // Leave blank if the player doesn't have a bank pin
    
      Players[1].Name := ''; // Username
      Players[1].Pass := ''; // Password
      Players[1].Nick := ''; // 3-4 lowercase letters from username
      Players[1].Active := True; // Set to true if you want to use this player
      Players[1].Pin := '0000'; // Leave blank if the player doesn't have a bank pin
    end;
    Code:
    begin
      Smart_Server := WORLD;
      Smart_Members := MEMBERS;
      Smart_Signed := SIGNED;
      Smart_SuperDetail := False; // These four lines, setup and run Smart, using the constants you made earlier.
      SetupSRL; // This is used to setup SRL's base features, and is almost always necessary.
    
      {$IfDef Reflection}
      SetupReflection;
      {$EndIf} // Hello again IfDef. If you haven't noticed, EVERYTHING to do with reflection is surrounded by this, so it is very easily removed.
    
      DeclarePlayers; // This runs your DeclarePlayers procedure, setting them up to run
      LoginPlayer; // This logs in your first player.
      repeat // This is the start of a loop, it will repeat until the conditions set after the until below are met.
        BreakCheck; // Runs the breaks
        if not LoggedIn then
          NextPlayer(false); // goes to the next player, setting the previous one as inactive.
      until AllPlayersInactive; // This means that, once all characters have failed, the script will stop.
    end.
    Glossary

    Anti-Ban - Random/seemingly unconscious movements to prevent repeated motions, and lower ban rates.
    Anti-Randoms - Solves Anti-Randoms in the game.
    Breaking - Logs the character out for a given amount of time. Helps prevent bans + randoms.
    Constants - Settings in the script that never change.
    Functions - A group of actions wrote out in their entirety once in the script, then one line each time after. May return anything from booleans (true/false) to any range of numbers.
    Includes - A group of procedures/functions that can be "included" in the script without them actually being within it.
    Procedures - A group of actions wrote out in their entirety once in a script, then one line each time after. Returns nothing.
    Reflection - An include, reads information from the client and allows very simple and accurate botting.
    Smart - A client for runescape which allows Simba to use Reflection.
    SRL - The include that is the base of Simba/SRL, it hosts a large number of runescape based, and other general procedures.
    Variables - Settings that are changeable in runtime.
    Last edited by Magiic; 05-14-2011 at 08:56 AM.


  2. #2
    Join Date
    Dec 2009
    Location
    R_GetPlayerLoc;
    Posts
    2,235
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Good Tut and first post
    "Logic never changes, just the syntax" - Kyle Undefined?

    Remember, The Edit Button Is There For A Reason!!!

  3. #3
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    good tut, i can't see the green text though =/

  4. #4
    Join Date
    Jun 2009
    Location
    Hiding
    Posts
    160
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Very nice.
    ~Austin~

  5. #5
    Join Date
    Jul 2008
    Posts
    907
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks guys, and I'll change that now Football (:


  6. #6
    Join Date
    Nov 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks I scripted for RSBuddy/PowerBot, but now I plan on scripting for Simba also

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •