Results 1 to 4 of 4

Thread: First Script attempt, help needed

  1. #1
    Join Date
    Dec 2006
    Location
    Australia
    Posts
    698
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default First Script attempt, help needed

    Below is my first attempt at a script can people look over it, and advise if im going about it the right way?

    At the moment its
    autocoloured
    form to fill in character details which it saves to a file
    Axe finding and repair
    Ent avoiding


    - Dont worry about anti-ban sorting that out tomorow.
    - It only will cut an invent and log out, it will become a draynor or edge willow cutter, with the choice of powercutting or banking.
    - What do you want in a script?
    - How could this one be improved?

    A problem i need help with is making the multiplayer working correctly.

    SCAR Code:
    {.include srl/srl.scar}
    {.include SRL/SRL/Skill/WoodCutting.scar}

    {thanks srl and starblaster!}

    var
          cUser, willows, i, StartXP, EndXP, TotalXP, LoadNumber:integer;
          StartScript: Boolean;
          frmDesign : TForm;
          CPlayer , PPlayer , BeginScript , Cancel , NPlayer, DPlayer : TButton;
          GroupBox1 : TGroupBox;
          Label1 , Label2 , Label3 , Label4 , Label5 : TLabel;
          UName , Pword , Loads : TEdit;
          Activity : TComboBox;
          EdgeWillowCutterFileName: String;

    {__________________________________________
    |                 Loading                  |
    |__________________________________________|}


    Procedure SavePlayersInForm(No: Integer);
    Begin
      Players[no].Name := UName.Text;
      Players[no].Pass := Pword.Text;
      Players[no].Active := StrToBool(Activity.Text);
      Players[no].Integer1 := StrToIntDef(Loads.Text, 0);
    end;

    Procedure LoadPlayersInForm(no: Integer);
    Begin
      try
        UName.Text := Players[no].Name;
        Pword.Text := Players[no].Pass;
        Activity.Text := BoolToStr(Players[no].Active);
        Loads.Text := IntToStr(Players[no].Integer1);
      except
      end;
    end;

    procedure SaveUs2;
    var
      f, CharsFile: Integer;
    begin
      If (EdgeWillowCutterFileName = '') then EdgeWillowCutterFileName := 'PowerSkills'
        CharsFile := RewriteFile(ScriptPath + EdgeWillowCutterFileName + '.dat', False)
      For f := 0 to GetArrayLength(players) - 1 do
      begin
        WriteFileString(CharsFile, 'name' +IntToStr(f)+ '=' +players[f].Name+ Chr(13))
        WriteFileString(CharsFile, 'pass' +IntToStr(f)+ '=' +players[f].Pass+ Chr(13))
        WriteFileString(CharsFile, 'active' +IntToStr(f)+ '=' +BoolToStr(players[f].Active)+ Chr(13))
        WriteFileString(CharsFile, 'load' +IntToStr(f)+ '=' +IntToStr(players[f].Integer1)+ Chr(13))
        //Writeln('Saved Player: '+IntToStr(f));
      end;
      CloseFile(charsfile)
    end;

    procedure LoadUs2;
    var
      f, CharsFile, Temp: Integer;
    begin
      if (EdgeWillowCutterFileName = '') then EdgeWillowCutterFileName := 'PowerSkills';
      CharsFile := OpenFile(ScriptPath + EdgeWillowCutterFileName + '.dat', False)
      if (CharsFile < 0) then
      begin
        SaveUs2;
        CharsFile := OpenFile(AppPath + filename + '.dat', False)
        if (CharsFile < 0) then
        begin
          WriteLn('Error Loading Chars');
          Exit;
        end
      end
      ReadFileString(CharsFile, CharsFileString, FileSize(CharsFile))
      CloseFile(CharsFile)
      Temp := CountPlayers;
      If (Temp <= 0) then Temp:= 1;
      SetArrayLength(players, Temp);
      HowManyPlayers := GetArrayLength(players)
      for f := 0 to HowManyPlayers - 1 do
      begin
        players[f].Name := GetFileData(f, 'name')
        players[f].Pass := GetFileData(f, 'pass')
        players[f].Active := StrToBool(GetFileData(f, 'active'))
        players[f].Integer1 := StrToIntDef(GetFileData(f, 'load'), 0)
        //Writeln('Loading Player: '+IntToStr(f));
      end
      CloseFile(CharsFile);
    end;

    {__________________________________________
    |                   Form                   |
    |__________________________________________|}

    procedure Inititate(Sender: TObject);
    begin
      label5.Caption := 'Player '+IntToStr(cUser);
      Players[cUser].Name := UName.Text;
      Players[cUser].Pass := Pword.Text;
      if (activity.Text = 'True') then
        Players[cUser].Active := True
      else
        Players[cUser].Active := False;
      cUser := GetArrayLength(Players) - 1;
    end;


    procedure LeftPlayer(sender: TObject);
    begin
      try
        players[currentplayer + 1].name := players[currentplayer + 1].name
      except
        Exit;
      end
      SavePlayersInForm(CurrentPlayer);
      CurrentPlayer := CurrentPlayer + 1;
      label5.caption := 'Player '+IntToStr(CurrentPlayer);
      LoadPlayersInForm(CurrentPlayer);
    end;

    procedure RightPlayer(sender: TObject);
    begin
      if (Currentplayer <> 0) then
      begin
        SavePlayersInForm(CurrentPlayer);
        CurrentPlayer := CurrentPlayer - 1;
        label5.caption := 'Player '+IntToStr(CurrentPlayer);
        LoadPlayersInForm(CurrentPlayer);
      end
    end;

    procedure Backspace(sender: TObject);
    Begin
      repeat
        if (GetArrayLength(players) = 1) then break
        SetArrayLength(players, GetArrayLength(players) - 1)
        CurrentPlayer := GetArrayLength(Players) - 1;
        label5.caption := 'Player '+IntToStr(CurrentPlayer);
        LoadPlayersInForm(CurrentPlayer);
      until (True)
    end;

    procedure AddUser(sender: TObject);
    begin
      SavePlayersInForm(CurrentPlayer);
      SetArrayLength(Players, GetArrayLength(Players) + 1);
      CurrentPlayer := GetArrayLength(Players) - 1;
      Players[GetArrayLength(Players) - 1].Active := True;
      label5.caption := 'Player '+IntToStr(CurrentPlayer);
      LoadPlayersInForm(CurrentPlayer);
    end;

    procedure CancelScript(sender: TObject);
    var
      v: TVariantArray;
    begin
      SavePlayersInForm(CurrentPlayer);
      SetArrayLength ( V, 0);
      Writeln('Script Cancelled');
      SaveUs2;
      frmDesign.ModalResult:= mrOk;
      StartScript := False;
    end;

    procedure FormClose2(sender: TObject; var CanClose: Boolean);
    begin
      SavePlayersInForm(CurrentPlayer);
      SaveUs2;
      HowManyPlayers := GetArrayLength(players)
      CanClose := True
    end;

    Procedure BScript(Sender: TObject);
    var
      v: TVariantArray;
    begin
      SavePlayersInForm(CurrentPlayer);
      SaveUs2;
      SetArrayLength ( V, 0);
      frmDesign.ModalResult:= mrOk;
      StartScript := True;
      Label5.Caption := 'Player '+IntToStr(cUser);
    end;

    procedure InitForm;
      Begin
      LoadUs2;

      frmDesign := CreateForm;
      frmDesign.Left := 262;
      frmDesign.Top := 167;
      frmDesign.BorderStyle := bsSingle;
      frmDesign.Caption := 'Edge Cutter';
      frmDesign.ClientHeight := 293;
      frmDesign.ClientWidth := 377;
      frmDesign.Color := clCream;
      frmDesign.Font.Color := clWindowText;
      frmDesign.Font.Height := -13;
      frmDesign.Font.Name := 'Comic Sans MS';
      frmDesign.Font.Style := [];
      frmDesign.KeyPreview := True;
      frmDesign.Visible := False;
      frmDesign.PixelsPerInch := 96;

      NPlayer := TButton.Create(frmDesign);
      NPlayer.OnClick:= @LeftPlayer;
      NPlayer.Parent := frmDesign;
      NPlayer.Left := 255;
      NPlayer.Top := 28;
      NPlayer.Width := 75;
      NPlayer.Height := 25;
      NPlayer.Caption := 'Next';
      NPlayer.Font.Color := clWindowText;
      NPlayer.Font.Height := -13;
      NPlayer.Font.Name := 'Comic Sans MS';
      NPlayer.Font.Style := [];
      NPlayer.ParentFont := False;
      NPlayer.TabOrder := 0;

      CPlayer := TButton.Create(frmDesign);
      CPlayer.OnClick:= @AddUser;
      CPlayer.Parent := frmDesign;
      CPlayer.Left := 186;
      CPlayer.Top := 28;
      CPlayer.Width := 67;
      CPlayer.Height := 25;
      CPlayer.Caption := 'Create';
      CPlayer.Font.Color := clWindowText;
      CPlayer.Font.Height := -13;
      CPlayer.Font.Name := 'Comic Sans MS';
      CPlayer.Font.Style := [];
      CPlayer.ParentFont := False;
      CPlayer.TabOrder := 1;

      DPlayer := TButton.Create(frmDesign);
      DPlayer.OnClick:= @Backspace;
      DPlayer.Parent := frmDesign;
      DPlayer.Left := 116;
      DPlayer.Top := 29;
      DPlayer.Width := 68;
      DPlayer.Height := 25;
      DPlayer.Caption := 'Delete';
      DPlayer.Font.Color := clWindowText;
      DPlayer.Font.Height := -13;
      DPlayer.Font.Name := 'Comic Sans MS';
      DPlayer.Font.Style := [];
      DPlayer.ParentFont := False;
      DPlayer.TabOrder := 2;

      PPlayer := TButton.Create(frmDesign);
      PPlayer.OnClick:= @RightPlayer;
      PPlayer.Parent := frmDesign;
      PPlayer.Left := 39;
      PPlayer.Top := 29;
      PPlayer.Width := 75;
      PPlayer.Height := 25;
      PPlayer.Caption := 'Previous';
      PPlayer.Font.Color := clWindowText;
      PPlayer.Font.Height := -13;
      PPlayer.Font.Name := 'Comic Sans MS';
      PPlayer.Font.Style := [];
      PPlayer.ParentFont := False;
      PPlayer.TabOrder := 3;

      Cancel := TButton.Create(frmDesign);
      Cancel.OnClick:= @CancelScript;
      Cancel.Parent := frmDesign;
      Cancel.Left := 200;
      Cancel.Top := 258;
      Cancel.Width := 75;
      Cancel.Height := 25;
      Cancel.Caption := 'Cancel';
      Cancel.Font.Color := clWindowText;
      Cancel.Font.Height := -13;
      Cancel.Font.Name := 'Comic Sans MS';
      Cancel.Font.Style := [];
      Cancel.ParentFont := False;
      Cancel.TabOrder := 4;

      BeginScript := TButton.Create(frmDesign);
      BeginScript.OnClick:= @BScript;
      BeginScript.Parent := frmDesign;
      BeginScript.Left := 90;
      BeginScript.Top := 258;
      BeginScript.Width := 75;
      BeginScript.Height := 25;
      BeginScript.Caption := 'Ok';
      BeginScript.TabOrder := 6;

      GroupBox1 := TGroupBox.Create(frmDesign);
      GroupBox1.Parent := frmDesign;
      GroupBox1.Left := 43;
      GroupBox1.Top := 61;
      GroupBox1.Width := 285;
      GroupBox1.Height := 190;
      GroupBox1.Color := clActiveCaption;
      GroupBox1.DragMode := dmAutomatic;
      GroupBox1.Font.Color := clWindowText;
      GroupBox1.Font.Height := -13;
      GroupBox1.Font.Name := 'Comic Sans MS';
      GroupBox1.Font.Style := [];
      GroupBox1.ParentColor := False;
      GroupBox1.ParentFont := False;
      GroupBox1.TabOrder := 5;

      Label1 := TLabel.Create(GroupBox1);
      Label1.Parent := GroupBox1;
      Label1.Left := 42;
      Label1.Top := 43;
      Label1.Width := 70;
      Label1.Height := 18;
      Label1.Caption := 'User Name:';
      Label1.Font.Color := clWindowText;
      Label1.Font.Height := -13;
      Label1.Font.Name := 'Comic Sans MS';
      Label1.Font.Style := [];
      Label1.ParentFont := False;

      Label2 := TLabel.Create(GroupBox1);
      Label2.Parent := GroupBox1;
      Label2.Left := 50;
      Label2.Top := 73;
      Label2.Width := 61;
      Label2.Height := 18;
      Label2.Caption := 'Password:';
      Label2.Font.Color := clWindowText;
      Label2.Font.Height := -13;
      Label2.Font.Name := 'Comic Sans MS';
      Label2.Font.Style := [];
      Label2.ParentFont := False;

      Label3 := TLabel.Create(GroupBox1);
      Label3.Parent := GroupBox1;
      Label3.Left := 68;
      Label3.Top := 103;
      Label3.Width := 42;
      Label3.Height := 18;
      Label3.Caption := 'Active:';
      Label3.Font.Color := clWindowText;
      Label3.Font.Height := -13;
      Label3.Font.Name := 'Comic Sans MS';
      Label3.Font.Style := [];
      Label3.ParentFont := False;

      Label4 := TLabel.Create(GroupBox1);
      Label4.Parent := GroupBox1;
      Label4.Left := 69;
      Label4.Top := 133;
      Label4.Width := 39;
      Label4.Height := 18;
      Label4.Caption := 'Loads:';

      Label5 := TLabel.Create(GroupBox1);
      Label5.Parent := GroupBox1;
      Label5.Left := 112;
      Label5.Top := 8;
      Label5.Width := 46;
      Label5.Height := 23;
      Label5.Caption := 'Player '+IntToStr(cUser);
      Label5.Font.Color := clWindowText;
      Label5.Font.Height := -16;
      Label5.Font.Name := 'Comic Sans MS';
      Label5.Font.Style := [];
      Label5.ParentFont := False;

      UName := TEdit.Create(GroupBox1);
      UName.Parent := GroupBox1;
      UName.Left := 118;
      UName.Top := 40;
      UName.Width := 121;
      UName.Height := 26;
      UName.ParentShowHint := False;
      UName.ShowHint := True;
      UName.TabOrder := 4;
      UName.Text := Players[0].Name;

      Pword := TEdit.Create(GroupBox1);
      Pword.Parent := GroupBox1;
      Pword.Left := 117;
      Pword.Top := 70;
      Pword.Width := 121;
      Pword.Height := 26;
      Pword.Hint := 'Password';
      Pword.ParentShowHint := False;
      Pword.PasswordChar := '*';
      Pword.ShowHint := True;
      Pword.TabOrder := 1;
      Pword.Text := Players[0].Pass;

      Loads := TEdit.Create(GroupBox1);
      Loads.Parent := GroupBox1;
      Loads.Left := 118;
      Loads.Top := 130;
      Loads.Width := 121;
      Loads.Height := 26;
      Loads.OEMConvert := True;
      Loads.ParentShowHint := False;
      Loads.ShowHint := True;
      Loads.TabOrder := 2;
      Loads.Text := IntToStr(Players[0].Integer1);

      Activity := TComboBox.Create(GroupBox1);
      Activity.Parent := GroupBox1;
      Activity.Left := 117;
      Activity.Top := 100;
      Activity.Width := 122;
      Activity.Height := 26;
      Activity.ItemHeight := 18;
      Activity.ParentShowHint := False;
      Activity.ShowHint := True;
      Activity.TabOrder := 3;
      Activity.Text := BoolToStr(Players[0].Active);
      Activity.Items.Add('True');
      Activity.Items.Add('False');

    end;

    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

    procedure SafeShowFormModal;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('ShowFormModal', v);
    end;

    {__________________________________________
    |                Sigantures                |
    |__________________________________________|}

    Procedure Siganture;
    Begin
        Writeln('_______________________________');
        Writeln('|         Me_ntal"s            |');
        Writeln('|         Edgeville            |');
        Writeln('|       Willow Cutter          |');
        Writeln('|______________________________|');
    end;

    procedure Report;
    begin
         ClearDebug;
         Writeln('_______________________________');
         Writeln('|                              |');
         Writeln('|         Me_ntal"s            |');
         Writeln('|         Edgeville            |');
         Writeln('|       Willow Cutter          |');
         Writeln('|______________________________|');
         Writeln('')
         Writeln('Willows Cut:'+IntToStr(Willows));
         Writeln('Exp Gained:'+IntToStr(TotalXP));
    end;


    {__________________________________________
    |                  Randoms                 |
    |__________________________________________|}

    Function FindFastRandoms:Boolean;   //By WT-Fakawi.
    begin
      for i := 1 to 16 do
      begin
        case I of
          1: CloseWindow;
          2: if FindTalk then
              Result := True;
          3: if FindDead then
              Result := True;
          4: if FindMod then
              Result := True;
          5: if FindMime then
              Result := True;
          6: if FindMaze then
              Result := True;
          7: if FindQuiz then
              Result := True;
          8: if FindDemon then
              Result := True;
          9: if FindScapeRune then
              Result := True;
          10: if FindTalk then
              Result := True;
          11: if FindLamp(LampSkill) then
              Result := True;
          12: if (FindNewBox) then
            begin
              Result := True;
              if (UseBoxSolver) then
                SolveBox
              else
                GambleNewBox;
            end;

          14:
            begin
              if NoGameTab then
              begin
                Result := True;
                Players[CurrentPlayer].loc := 'No GameTab';
                Logout;
                Exit;
              end;
            end;
            16: if RC then
              Result := True;
        end;
        Wait(1);
      end;
    end;

    {__________________________________________
    |           Soon to be banking             |
    |__________________________________________|}

    Procedure Walkto;
    Begin
    end;

    Procedure BankLoad;
    Begin
    end;

    Procedure Walkfro;
    Begin
    end;

    {__________________________________________
    |                  AntiBan                 |
    |__________________________________________|}

    Procedure WereHuman;

    begin

        wait(10)

    end;

    procedure bankreq;
    begin
        if (InvFull) then
           begin
                   LoadNumber := LoadNumber + 1;
                   Walkto;
                   BankLoad;
                   Walkfro;
        end else
        exit;
    end;

    procedure Randomfind;
    begin
      FindFastRandoms;
      FindHead;
      FindNormalRandoms;
      WereHuman;
      bankreq;
    end;

    {__________________________________________
    |                 Main Loop                |
    |__________________________________________|}

    Procedure Doload;
    Var
      cx, cy: Integer;
    begin
      if (InvFull) then bankreq;
      repeat
      begin
      If not(LoggedIn)then Exit;
        If (FindColorSpiralTolerance(x,y, 3160112, msx1,msy1,msx2,msy2, 3))and
        not(FindColorSpiralTolerance(cx, cy, 515029, MSX1, MSY1, 180, 25, 20))and
        not(FindColorSpiralTolerance(cx, cy, 122333, MSX1, MSY1, 123, 15, 10))and
        not(FindColorSpiralTolerance(cx, cy, 65535, MSX1, MSY1, 180, 25, 20))then
           Begin
              MMouse(x, y, 3, 3);
           if(IsUpTextMulti('hop', 'own', 'illo'))then
             begin
                Wait(100 + Random(100));
                Mouse(x, y, 3, 3, True)
                repeat
                  begin
                      Randomfind;
                      wait(500+Random(1000));
                      Report;
                      If (InvFull) then
                         exit;
                  end;
                until (not(IsUpText('hop')));
              end;
           end;
        end;
        until (InvFull)
    end;




    {__________________________________________
    |                Once Setup                |
    |__________________________________________|}

    Procedure SetupScript;
    Begin
        ClearDebug;
        Wait(500)
        rs_DeleteUID;
        ActivateClient;
        LoginPlayer;
        If (Not(LoggedIn)) then
        Begin
          Loginplayer;
        end;
    end;

    Procedure SetupPlayer;
    begin
       HighestAngle;
       MakeCompass('E');
       StartXP := GetXp('Woodcutting');
       FindAxeHeadColor;
    end;

    {__________________________________________
    |                 Main Loop                |
    |__________________________________________|}

    begin
      setupsrl;
      LoadUs;
      ClearDebug;
      cUser := 0;
      Siganture;
      SafeInitForm;
      SafeShowFormModal;
      If not(StartScript) then TerminateScript;
          SetupScript;
          SetupPlayer;
      repeat
       repeat
            Doload;
        until (LoadNumber >= Players[i].Integer1)
            EndXP := GetXp('Woodcutting')
            TotalXP := (EndXP - StartXP)
            Report;
            SRLRandomsReport;
            LogOut;
            NextPlayer(True);
            LoadNumber := 0
            SetupPlayer;
      until False;
    end.

  2. #2
    Join Date
    Feb 2007
    Posts
    3,616
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I'd suggest putting the auto colors for the willows (that you already picked I assume) in constants so the user can change them only if they aren't working. And as for multiplayer, all you need is another variable for loads (if you already have one for the progress report, I think you did) then in the constants have a constant asking the user how many loads to do. So heres an example:

    SCAR Code:
    const

    Loads =10 //loads to do?

    var
      LoadsNum: Integer;
    procedure Whatever;
    begin
      LoadsNum := LoadsNum + 1;
    end;

    begin
      repeat
        if(LoadsNum = Loads)then
        begin
          NextPlayer(True);
          LoadsNum = 0;
        end;
      until(False)
    end.
    see how I made LoadsNum = 0 again? thats so whenever 1 charactor chops 1 load, it wouln't stay at 10 (or whatever the user set it to switch at) because if you left it, it would have had loads num = 10 all the time, and it would never switch players again and you would need a LoadsNumB to go up too display your progress report too. Sorry if that sounded a little confusing, I'm rushing to get off laterz.

  3. #3
    Join Date
    Mar 2007
    Location
    Under a rock
    Posts
    813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    But if you do that JAD, wont it put your progress report back down to doing 0 loads????

  4. #4
    Join Date
    Jun 2006
    Location
    New Zealand
    Posts
    285
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Then use 2 variables instead of one - one for the progress report and one to make the script continue running?

    SCAR Code:
    if(LoadsNum = Loads)then
        begin
          NextPlayer(True);
          ProgressLoadNum := LoadsNum; // This part?
          LoadsNum = 0;
        end;
    etc.
    Huehuehuehuehue

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. help needed for script 55% done
    By sink998 in forum OSR Help
    Replies: 13
    Last Post: 10-09-2008, 04:38 PM
  2. Rune mining script attempt?
    By man slaughter in forum RS3 Outdated / Broken Scripts
    Replies: 24
    Last Post: 02-20-2008, 11:08 PM
  3. Script Needed.
    By Street Life in forum RS3 Outdated / Broken Scripts
    Replies: 2
    Last Post: 05-11-2007, 12:21 AM
  4. i have few script that needed help to fix
    By david$ in forum OSR Help
    Replies: 2
    Last Post: 12-12-2006, 04:44 AM
  5. My attempt at a first script. Failed.
    By MrHams in forum News and General
    Replies: 5
    Last Post: 09-07-2006, 11:41 AM

Posting Permissions

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