Results 1 to 6 of 6

Thread: Need Help with My Form

  1. #1
    Join Date
    Dec 2006
    Posts
    908
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Exclamation Need Help with My Form

    So I'm new to forms and i want to use them. So i gave it a try on my current project, and i got an error.

    Once after completing the form (go ahead and run it, start filling it out yourselves), and then the script starts declaring players, i get the error

    Simba Code:
    Error: Exception: Access violation at line 36

    So heres my script.

    Simba Code:
    program AutoSuperheat;
    {$DEFINE SMART}
    {$IFDEF SMART}
    {$i SRL\SRL\Misc\SMART.scar}
    {$ENDIF}
    {$i SRL\SRL.scar}

    const
      FAILSAFE_CHESTCOLOR = 5592409;
      FAILSAFE_TOLERANCE = 5;

    var
      Global: TPoint;

    var
      EndInitForm : Boolean;
      frmDesign : TForm;
      Label1, Label2, Label3, Label4, Label5, Label6, Label7, Label9, Label8, Label10, Label11, Label12, Label13 : TLabel;
      ComboBox1, ComboBox2, ComboBox3 : TComboBox;
      ListBox1 : TListBox;
      CheckBox1, CheckBox3, CheckBox4 : TCheckBox;
      Edit1, Edit2, Edit3, Edit4, Edit5, Edit6, Edit7 : TEdit;
      Button1, Button2, Button3 : TButton;
      GroupBox1 : TGroupBox;
      Image1 : TImage;
      b: Integer;

    {NEED HELP, ERROR: EXCEPTION: ACCESS VIOLATION AT LINE 38 AND SO FORTH WHEN I TRY DECLARING PLAYERS FROM FORM'S INPUTS}

    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      with Players[0] do
      begin
        Name := Edit1.Text; {FROM HERE}
        Pass := Edit2.Text;
        Nick := '';
        Pin := Edit3.Text;
        Players[CurrentPlayer].Loc := 'Banking';
        Active := True;

        Strings[0] := ComboBox1.Text; //Which Bank   Soul Wars Bank or Grand Exchange
        Integers[0] := 500;//Antiban% - Default = 500 = 5%
        Integers[1] := 25;//Mouse Speed - Script's maximum is 50. Therefor, 50 = 100%, 25 = 50% and so on.
        Integers[2] := StrToInt(Edit4.Text);//Break In minuites?
        Integers[3] := StrToInt(Edit5.Text);//Break In additional or subtractional. Enables randomness to breaks customary to user.
        Integers[4] := StrToInt(Edit6.Text);//Break for in minuites?
        Integers[5] := StrToInt(Edit7.Text);//Break for in additional or subtractional. Enables randomness to breaks customary to user.
        Integers[6] := ListBox1.ItemIndex;//Which ore, ya weird so let me lay it out. 0 - runite, 1 - adamant, 2 - mithril, 3 - gold, 4 - steel, 5 - iron
        Booleans[0] := CheckBox4.Checked;//Break?
      end;                                              {TO HERE}
    end;

    procedure InitFormOnClose(Sender : TObject; var Action : TCloseAction);
    begin
      if (not(frmDesign.ModalResult = 1)) then
        EndInitForm := True;
    end;

    procedure StartScript(Sender: TObject);
    begin
      WriteLn(Edit1.Text);
      WriteLn(Edit2.Text);
      WriteLn(Edit3.Text);
      WriteLn(Inttostr(ListBox1.ItemIndex));
      WriteLn(BoolToStr(CheckBox4.Checked));
      WriteLn(Replace(ComboBox3.Text, '%', ''));
    end;

    procedure InitForm;
    begin
      frmDesign := CreateForm;
      with frmDesign do
      begin
        OnClose := @InitFormOnClose;
        BorderStyle := bsSingle;
        BorderIcons := [biMaximize,biMinimize];
        Left := 444;
        Top := 152;
        Caption := 'AutoSuperheat';
        ClientHeight := 377;
        ClientWidth := 447;
        Color := clBtnFace;
        Font.Color := clWindowText;
        Font.Height := -11;
        Font.Name := 'MS Sans Serif';
        Font.Style := [];
        PixelsPerInch := 96;
      end;
      Label1 := TLabel.Create(frmDesign);
      with Label1 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 112;
        Width := 25;
        Height := 13;
        Caption := 'Bank';
      end;
      Label2 := TLabel.Create(frmDesign);
      with Label2 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 160;
        Width := 17;
        Height := 13;
        Caption := 'Ore';
      end;
      Label3 := TLabel.Create(frmDesign);
      with Label3 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 160;
        Width := 25;
        Height := 13;
        Caption := 'Misc.';
      end;
      Label4 := TLabel.Create(frmDesign);
      with Label4 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 280;
        Width := 48;
        Height := 13;
        Caption := 'Username';
      end;
      Label5 := TLabel.Create(frmDesign);
      with Label5 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 280;
        Width := 46;
        Height := 13;
        Caption := 'Password';
      end;
      Label6 := TLabel.Create(frmDesign);
      with Label6 do
      begin
        Parent := frmDesign;
        Left := 288;
        Top := 280;
        Width := 18;
        Height := 13;
        Caption := 'PIN';
      end;
      Label7 := TLabel.Create(frmDesign);
      with Label7 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 112;
        Width := 71;
        Height := 13;
        Caption := 'Anti-Ban Setup';
      end;
      Label9 := TLabel.Create(frmDesign);
      with Label9 do
      begin
        Parent := frmDesign;
        Left := 360;
        Top := 152;
        Width := 18;
        Height := 20;
        Caption := '+/-';
        Font.Color := clWindowText;
        Font.Height := -16;
        Font.Name := 'MS Sans Serif';
        Font.Style := [];
      end;
      Label8 := TLabel.Create(frmDesign);
      with Label8 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 136;
        Width := 128;
        Height := 13;
        Caption := 'Break In...          Random   ';
      end;
      Label10 := TLabel.Create(frmDesign);
      with Label10 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 184;
        Width := 119;
        Height := 13;
        Caption := 'Break for...         Random';
      end;
      Label11 := TLabel.Create(frmDesign);
      with Label11 do
      begin
        Parent := frmDesign;
        Left := 360;
        Top := 200;
        Width := 18;
        Height := 20;
        Caption := '+/-';
        Font.Color := clWindowText;
        Font.Height := -16;
        Font.Name := 'MS Sans Serif';
        Font.Style := [];
      end;
      Label12 := TLabel.Create(frmDesign);
      with Label12 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 232;
        Width := 40;
        Height := 13;
        Caption := 'Anti-Ban';
      end;
      Label13 := TLabel.Create(frmDesign);
      with Label13 do
      begin
        Parent := frmDesign;
        Left := 360;
        Top := 232;
        Width := 66;
        Height := 13;
        Caption := 'Mouse Speed';
      end;
      ComboBox1 := TComboBox.Create(frmDesign);
      with ComboBox1 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 128;
        Width := 121;
        Height := 21;
        ItemHeight := 13;
        TabOrder := 0;
        Text := 'Select a bank...';
        with Items do
        begin
          Add('Soul Wars Bank');
          Add('Grand Exchange');
        end;
      end;
      ListBox1 := TListBox.Create(frmDesign);
      with ListBox1 do
      begin
        Parent := frmDesign;
        Tag := 1;
        Left := 16;
        Top := 184;
        Width := 97;
        Height := 81;
        ItemHeight := 13;
        with Items do
        begin
          Add('Runite');
          Add('Adamantite');
          Add('Mithril');
          Add('Gold');
          Add('Steel');
          Add('Iron');
        end;
        TabOrder := 1;
      end;
      CheckBox1 := TCheckBox.Create(frmDesign);
      with CheckBox1 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 184;
        Width := 129;
        Height := 16;
        Caption := 'Goldsmith gauntlets?';
        Checked := True;
        State := cbChecked;
        TabOrder := 2;
      end;
      CheckBox3 := TCheckBox.Create(frmDesign);
      with CheckBox3 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 216;
        Width := 129;
        Height := 16;
        Caption := 'Use SMART debug?';
        TabOrder := 3;
      end;
      Edit1 := TEdit.Create(frmDesign);
      with Edit1 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 296;
        Width := 97;
        Height := 21;
        TabOrder := 4;
      end;
      Edit2 := TEdit.Create(frmDesign);
      with Edit2 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 296;
        Width := 97;
        Height := 21;
        PasswordChar := '*';
        TabOrder := 5;
      end;
      Edit3 := TEdit.Create(frmDesign);
      with Edit3 do
      begin
        Parent := frmDesign;
        Left := 288;
        Top := 296;
        Width := 48;
        Height := 21;
        PasswordChar := '*';
        TabOrder := 6;
        Text := '0000';
      end;
      Button1 := TButton.Create(frmDesign);
      with Button1 do
      begin
        Parent := frmDesign;
        Left := 144;
        Top := 336;
        Width := 72;
        Height := 25;
        Caption := 'Start Script';
        ModalResult := 1;
        TabOrder := 7;
        Button1.OnClick := @StartScript;
      end;
      Button2 := TButton.Create(frmDesign);
      with Button2 do
      begin
        Parent := frmDesign;
        Left := 224;
        Top := 336;
        Width := 81;
        Height := 24;
        Caption := 'Save Options';
        ModalResult := 6;
        TabOrder := 8;
      end;
      Edit4 := TEdit.Create(frmDesign);
      with Edit4 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 152;
        Width := 49;
        Height := 21;
        TabOrder := 9;
        Text := '300';
      end;
      Edit5 := TEdit.Create(frmDesign);
      with Edit5 do
      begin
        Parent := frmDesign;
        Left := 384;
        Top := 152;
        Width := 41;
        Height := 21;
        TabOrder := 10;
        Text := '100';
      end;
      Edit6 := TEdit.Create(frmDesign);
      with Edit6 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 200;
        Width := 48;
        Height := 21;
        TabOrder := 11;
        Text := '25';
      end;
      Edit7 := TEdit.Create(frmDesign);
      with Edit7 do
      begin
        Parent := frmDesign;
        Left := 384;
        Top := 200;
        Width := 40;
        Height := 21;
        TabOrder := 12;
        Text := '10';
      end;
      ComboBox2 := TComboBox.Create(frmDesign);
      with ComboBox2 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 248;
        Width := 48;
        Height := 21;
        ItemHeight := 13;
        TabOrder := 13;
        Text := '5%';
        with Items do
        begin
          Add('50%');
          Add('25%');
          Add('10%');
          Add('5%');
          Add('1%');
        end;
      end;
      ComboBox3 := TComboBox.Create(frmDesign);
      with ComboBox3 do
      begin
        Parent := frmDesign;
        Left := 376;
        Top := 248;
        Width := 48;
        Height := 21;
        ItemHeight := 13;
        TabOrder := 14;
        Text := '70%';
        with Items do
        begin
          Add('100%');
          Add('90%');
          Add('80%');
          Add('70%');
          Add('60%');
          Add('50%');
          Add('40%');
          Add('30%');
          Add('25%');
        end;
      end;
      CheckBox4 := TCheckBox.Create(frmDesign);
      with CheckBox4 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 200;
        Width := 129;
        Height := 16;
        Caption := 'Take breaks?';
        Checked := True;
        State := cbChecked;
        TabOrder := 15;
      end;
      GroupBox1 := TGroupBox.Create(frmDesign);
      with GroupBox1 do
      begin
        Parent := frmDesign;
        Left := 8;
        Top := 8;
        Width := 433;
        Height := 96;
        Caption := 'AutoSuperheat';
        TabOrder := 16;
      end;
      Image1 := TImage.Create(GroupBox1);
      with Image1 do
      begin
        Parent := GroupBox1;
        Left := 8;
        Top := 0;
        Width := 416;
        Height := 72;
        {b := LoadBitmap(ScriptPath + 'Logo.bmp');
        {$IFDEF SIMBA}

        DrawBitmap(b, Image1.Canvas, 0, 0);
        {$ENDIF}}
      end;
      Button3 := TButton.Create(frmDesign);
      with Button3 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 232;
        Width := 113;
        Height := 25;
        Caption := 'View Current Profits?';
        TabOrder := 17;
      end;
    end;

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

    procedure ShowInitFormModal;
    begin
      frmDesign.ShowModal;
    end;

    procedure SafeShowInitFormModal;
    var
      v : TVariantArray;
    begin
      SetArrayLength(v, 0);
      ThreadSafeCall('ShowInitFormModal', v);
    end;

    procedure MainInitForm;
    begin
      try
        SafeInitForm;
        SafeShowInitFormModal;
      finally
        FreeForm(frmDesign);
      except
        WriteLn('An error seems to have occurred in: InitForm');
      end;
    end;

    type TOre = record
      UpText: TStringArray;
      Color:  Integer;
      Tolerance: Byte;
      Amount: Byte;
    end;

    var
      TOreArray: Array [0..1] of TOre;
      BreakIn, BreakFor: Integer;

    function CreateOre(Color, Tolerance: Integer): Integer;
    var
      DMP: TDTMPointDef;
      DSP: Array [0..5] of TDTMPointDef;
      TempTDTM: TDTM;
    begin
      DMP.x := 450;
      DMP.y := 108;
      DMP.AreaSize := 5;
      DMP.AreaShape := 0;
      DMP.Color := Color;
      DMP.Tolerance := Tolerance;

      DSP[0].x := 450;
      DSP[0].y := 108;
      DSP[0].AreaSize := 5;
      DSP[0].AreaShape := 0;
      DSP[0].Color := Color;
      DSP[0].Tolerance := Tolerance;

      DSP[1].x := 460;
      DSP[1].y := 112;
      DSP[1].AreaSize := 1;
      DSP[1].AreaShape := 0;
      DSP[1].Color := 131072;
      DSP[1].Tolerance := 255;

      DSP[2].x := 446;
      DSP[2].y := 121;
      DSP[2].AreaSize := 1;
      DSP[2].AreaShape := 0;
      DSP[2].Color := 131072;
      DSP[2].Tolerance := 255;

      DSP[3].x := 434;
      DSP[3].y := 108;
      DSP[3].AreaSize := 1;
      DSP[3].AreaShape := 0;
      DSP[3].Color := 131072;
      DSP[3].Tolerance := 255;

      DSP[4].x := 463;
      DSP[4].y := 101;
      DSP[4].AreaSize := 1;
      DSP[4].AreaShape := 0;
      DSP[4].Color := 131072;
      DSP[4].Tolerance := 255;

      DSP[5].x := 438;
      DSP[5].y := 115;
      DSP[5].AreaSize := 1;
      DSP[5].AreaShape := 0;
      DSP[5].Color := 131072;
      DSP[5].Tolerance := 255;

      TempTDTM.MainPoint := DMP;
      TempTDTM.SubPoints := DSP;
      Result := AddDTM(TempTDTM);
    end;

    procedure DeclareOres;
    begin
      case Players[CurrentPlayer].Integers[6] of
        5:
          with TOreArray[0] do
          begin
            UpText := ['ron ore'];
            Color := 1449523;
            Tolerance := 20;
            Amount := 28;
          end;
        4:
          begin
            with TOreArray[0] do
            begin
              UpText := ['ron ore'];
              Color := 1449523;
              Tolerance := 20;
              Amount := 14;
            end;
            with TOreArray[1]  do
            begin
              UpText := ['oal'];
              Color := 1778724;
              Tolerance := 20;
              Amount := 14;
            end;
          end;
        3:
          with TOreArray[0] do
          begin
            UpText := ['old ore'];
            Color := 1741495;
            Tolerance := 15;
            Amount := 28;
          end;
        2:
          begin
            with TOreArray[0] do
            begin
              UpText := ['ithril ore'];
              Color := 5256757;
              Tolerance := 20;
              Amount := 5;
            end;
            with TOreArray[1]  do
            begin
              UpText := ['oal'];
              Color := 1778724;
              Tolerance := 20;
              Amount := 20;
            end;
          end;
        1:
          begin
            with TOreArray[0] do
            begin
              UpText := ['damantite ore'];
              Color := 4081469;
              Tolerance := 20;
              Amount := 3;
            end;
            with TOreArray[1]  do
            begin
              UpText := ['oal'];
              Color := 1778724;
              Tolerance := 20;
              Amount := 18;
            end;
          end;
        0:
          begin
            with TOreArray[0] do
            begin
              UpText := ['unite ore'];
              Color := 5722435;
              Tolerance := 20;
              Amount := 3;
            end;
            with TOreArray[1]  do
            begin
              UpText := ['oal'];
              Color := 1778724;
              Tolerance := 20;
              Amount := 24;
            end;
          end;
      end;
    end;

    procedure CheckObjective(Time: Integer);
    var
      arA, arP, arAP: TPointArray;
      P: TPoint;
    begin
      if (not(GameTab(tab_Objectives))) then
        Exit;
      FindColors(arA, 42516, 595, 387, 691, 401);
      FindColors(arP, 5844, 595, 387, 691, 401);
      arAP := CombineTPA(arA, arP);
      if Length(arAP) < 1000 then
      begin
        if (not(GameTab(tab_Stats))) then
          Exit;
        case (Random(2)) of
          0: P := SkillToCoords('Smithing');
          1: P := SkillToCoords('Magic');
        end;
        Mouse(P.x, P.y, 10, 10, False);
        if (WaitOptionMulti(['et', 'bjective'], 1500)) then
        begin
          Wait(RandomRange(500, 1000));
          TypeSend('99');
          if (not(GameTab(tab_Objectives))) then
            Exit;
        end;
      end;
      MouseBox(585, 383, 701, 405, 3);
      Wait(Time);
      Exit;
    end;

    procedure TakeBreak;
    var
      Time: Array [0..2] of Integer;
      i: Integer;
    begin
      if (Players[CurrentPlayer].Booleans[0] = False) then
        Exit;
      if (GetSystemTime > BreakIn) then
      begin
        case (Random(2)) of
          0: BreakFor := (Players[CurrentPlayer].Integers[4] * 60000) + Random(Players[CurrentPlayer].Integers[5] * 60000);
          1: BreakFor := (Players[CurrentPlayer].Integers[4] * 60000) - Random(Players[CurrentPlayer].Integers[5] * 60000);
        end;
        LogOut;
        ConvertTime(BreakFor, Time[0], Time[1], Time[2]);
        WriteLn('Breaking for ' + IntToStr(Time[0]) + ' Hours, ' + IntToStr(Time[1]) + ' Minuites, and ' + IntToStr(Time[2]) + ' Seconds.');
        repeat
          Wait(100);
          i := i + 1
          if (i > 300) then
          begin
            ConvertTime(BreakFor - GetSystemTime, Time[0], Time[1], Time[2]);
            i := 0;
            WriteLn('Time remaining ' + IntToStr(Time[0]) + ' Hours, ' + IntToStr(Time[1]) + ' Minuites, and ' + IntToStr(Time[2]) + ' Seconds.');
          end;
        until (GetSystemTime > BreakFor);
        case (Random(2)) of
          0: BreakIn := (Players[CurrentPlayer].Integers[2] * 60000) + Random(Players[CurrentPlayer].Integers[3] * 60000);
          1: BreakIn := (Players[CurrentPlayer].Integers[2] * 60000) - Random(Players[CurrentPlayer].Integers[3] * 60000);
        end;
        LogInPlayer;
      end;
    end;

    function WaitBankScreen(Time: Integer): Boolean;
    var
      t: LongInt;
    begin
      Result := False;
      t := GetSystemTime + Time;
      while (GetSystemTime < t) do
      begin
        if (BankScreen) then
        begin
          Result := True;
          Exit;
        end;
        if (Length(Players[CurrentPlayer].Pin) = 4) then
          if (PinScreen) then
          begin
            InPin(Players[CurrentPlayer].Pin);
            Wait(RandomRange(1500, 3000));
            ClickToContinue;
          end;
        Wait(RandomRange(75, 100));
      end;
    end;

    procedure RandomHuman;
    begin
      case (Random(Players[CurrentPlayer].Integers[0])) of
        0: CheckObjective(RandomRange(1000, 3000));
        1: HoverSkill('Smithing', False);
        2: HoverSkill('Magic', False);
        3: PickupMouse;
        4: BoredHuman;
        5: ExamineInv;
        6: RandomMovement;
        7: RandomAngle('Up');
        8: RandomRClick;
        9:
          begin
            MakeCompass(Random(360));
            Wait(RandomRange(500, 1000));
            MakeCompass('N');
          end;
      end;
    end;

    function FindChest(): Boolean;
    var
      ATPA: T2DPointArray;
      TPA: TPointArray;
      P: TPoint;
      CTS, h, i: Integer;
      t, l: LongInt;
    begin
      MakeCompass('N');
      SetAngle(True);
      t := GetSystemTime;
      repeat
        if ((GetSystemTime - t) > 20000) then
          Break;
        CTS := GetColorToleranceSpeed;
        ColorToleranceSpeed(2);
        SetColorSpeed2Modifiers(0.04, 0.12);
        FindColorsSpiralTolerance(MSCX, MSCY, TPA, 8027016, MSX1, MSY1, MSX2, MSY2, 31);
        SetColorSpeed2Modifiers(0.2, 0.2);
        ColorToleranceSpeed(CTS);
        if (Length(TPA) < 1) then
          Continue;
        ATPA := TPAToATPAEx(TPA, 30, 30);
        SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY - 15));
        l := GetSystemTime;
        h := High(ATPA);
        for i := 0 to h do
        begin
          if ((GetSystemTime - l) > 15000) then
            Break;
          if (BankScreen) then
          begin
            Result := True;
            Break;
          end;
          if (Length(ATPA[i]) < 200) then
            Continue;
          P := MiddleTPA(ATPA[i]);
          MMouse(P.x, P.y, 3, 3);
          if (not (WaitUpTextMulti(['ank chest', 'Bank', 'chest'], 1500))) then
            Continue;
          GetMousePos(P.x, P.y);
          Mouse(P.x, P.y, 0, 0, False);
          if (not(WaitOption('Use', 1500))) then
            Continue;
          if (WaitBankScreen(750)) then
          begin
            Result := True;
            Break;
          end;
        end;
      until (Result);
      if (Result) then
        Exit
      else
      begin
        P := Point(MSCX, MSCY - 15);
        if (FindObjTPA(P.x, P.y, FAILSAFE_CHESTCOLOR, FAILSAFE_TOLERANCE, 1, 30, 30, 100, ['ank chest'])) then
        begin
          Mouse(P.x, P.y, 0, 0, False);
          if (WaitOption('Use', 1500)) then
            if WaitBankScreen(750) then
            begin
              Result := True;
              Exit;
            end else
              Exit;
        end;
      end;
    end;

    function Bank(): Boolean;
    var
      DTM, i, l, t: Integer;
      a: Extended;
      P: TPoint;
    begin
      a := SymbolAccuracy;
      l := 0;
      Result := False;
      repeat
        if (FindChest) then
          Break;
        if (BankScreen) then
          Break;
        if (l >= 5) then
          Exit;
        if (FindSymbol(P.x, P.y, 'Bank')) then
        begin
          Mouse(P.x, P.y, 1, 1, True);
          Flag;
        end else
          SymbolAccuracy := SymbolAccuracy - 0.1;
        l := l + 1;
      until (False);
      SymbolAccuracy := a;
      t := 0;
      repeat
        Deposit(1, 27, True);
        t := t + 1;
        if (t > 5) then
          Exit;
        Wait(750);
      until (InvCount = 1);
      FixBankTab;
      FixBank;
      DTM := CreateOre(TOreArray[0].Color, TOreArray[0].Tolerance);
      for i := 0 to 5 do
      begin
        if (not(FindDTM(DTM, P.x, P.y, MBX1, MBY1, MBX2, MBY2))) then
        begin
          FreeDTM(DTM);
          Exit;
        end;
        MouseBox(P.x - 10, P.y - 10, P.x + 10, P.y + 10, 3);
        if (WaitUpTextMulti(TOreArray[0].UpText, 1500)) then
        begin
          GetMousePos(P.x, P.y);
          Mouse(P.x, P.y, 0, 0, False);
          if (TOreArray[0].Amount = 14) then
            if (WaitOption('ithdraw-14', 1500)) then
              Break;
          if (TOreArray[0].Amount = 28) then
            if (WaitOption('ithdraw All', 1500)) then
              Break;
          if (TOreArray[0].Amount < 28) then
            if (WaitOption('ithdraw-x', 1500)) then
            begin
              Wait(RandomRange(500, 750));
              TypeSend(IntToStr(TOreArray[0].Amount));
              Break;
            end;
        end;
      end;
      FreeDTM(DTM);
      if (TOreArray[1].Color <> 0) then
      begin
        DTM := CreateOre(TOreArray[1].Color, TOreArray[1].Tolerance);
        for i := 0 to 5 do
        begin
          if (not(FindDTM(DTM, P.x, P.y, MBX1, MBY1, MBX2, MBY2))) then
          begin
            FreeDTM(DTM);
            Exit;
          end;
          MouseBox(P.x - 10, P.y - 10, P.x + 10, P.y + 10, 3);
          if (WaitUpTextMulti(TOreArray[1].UpText, 1500))  then
          begin
            GetMousePos(P.x, P.y);
            Mouse(P.x, P.y, 0, 0, True);
            if (TOreArray[1].Amount = 14) then
              if (WaitOption('ithdraw-14', 1500)) then
                Break;
            case Random(25) of
              0..24: if (WaitOption('ithdraw All', 1500)) then Break;
              25:
                begin
                  if (WaitOption('ithdraw-x', 1500))then
                  begin
                    Wait(RandomRange(750, 1500));
                    TypeSend(IntToStr(TOreArray[1].Amount));
                    Break;
                  end;
                end;
            end;
          end;
        end;
        FreeDTM(DTM);
      end;
      CloseBank;
      Wait(RandomRange(500, 750));
      if (not(GameTab(tab_Inv))) then
        Exit;
      DTM := CreateOre(TOreArray[0].Color, TOreArray[0].Tolerance);
      Result := (CountItemsIn('inv', 'SRL_DTM', DTM, []) = TOreArray[0].Amount);
      FreeDTM(DTM);
    end;

    function CastLoop(): Boolean;
    var
      Bitmap, DTM, i: Integer;
      P: TPoint;
    begin
      DTM := CreateOre(TOreArray[0].Color, TOreArray[0].Tolerance);
      Bitmap := BitmapFromString(14, 7, 'meJw9kDEKwkAQRdmNJrFIbpBecPE' +
               'MizewtRAsUnsAsbH1CKmtrdNYpYq9jYXYKEFE1EZZEN86IAzhzf9/' +
               'Z2ej41ynpR5tqUD1I1sHswvV0pZKehuUaPXUcQ6TgVFUZ44Ch92DV' +
               'hktR+Ss13/gk6bACseLwe7uLZXJhPbwBjAfMamaf5Ka7q+EuQsLwJ' +
               'JlAPP64PplGGJreH08Sxhgjr/UFHxJOucIyFtwadPTmyQgy5CUZcS' +
               'dLB+0AK0k/eSq4Tn8li8k64Ze');
      GameTab(28);
      i := 0;
      repeat
        if (GetCurrentTab = tab_Magic) then
        begin
          if (not(FindBitmapToleranceIn(Bitmap, Global.x, Global.y, MIX1, MIY1, MIX2, MIY2, 20))) then
          begin
            Result := False;
            Exit;
          end;
          MouseBox(Global.x - 1, Global.y - 12, Global.x + 15, Global.y + 10 , 3);
          if (WaitUpTextMulti(['Cast', 'uperheat'], 1000)) then
          begin
            GetMousePos(P.x, P.y);
            Mouse(P.x, P.y, 0, 0, True);
          end else
            Continue;
        end else
        begin
          GameTab(tab_Magic);
          Continue;
        end;
        if (WaitUpTextMulti(['uperheat', 'tem', '->'], 1500)) and (GetCurrentTab = tab_Inv) then
        begin
          if (FindDTM(DTM, P.x, P.y, MIX1, MIY1, MIX2, MIY2)) then
          begin
            MouseBox(P.x - 10, P.y - 10, P.x + 10, P.y + 10, 3);
            if (WaitUpTextMulti(TOreArray[0].UpText, 1000)) then
            begin
              GetMousePos(P.x, P.y);
              Mouse(P.x, P.y, 0, 0, True);
              i := i + 1;
              RandomHuman;
              Wait(RandomRange(150, 750));
              GameTab(tab_Magic);
            end else
            begin
              RandomHuman;
              GameTab(tab_Magic);
              Continue;
            end;
          end else
          begin
            GetMousePos(P.x, P.y);
            Mouse(P.x,  P.y, 0, 0, False);
            WaitOption('Cancel', 1000);
            Break;
          end;
        end else
        begin
          GameTab(tab_Magic);
          Continue;
        end;
      until (i >= TOreArray[0].Amount);
      GameTab(tab_Inv);
      Result := (not(FindDTM(DTM, P.x, P.y, MIX1, MIY1, MIX2, MIY2)));
      FreeDTM(DTM);
      FreeBitmap(Bitmap);
    end;

    function MainLoop(): Boolean;
    var
      State: String;
    begin
      case (Random(2)) of
        0: BreakIn := (Players[CurrentPlayer].Integers[2] * 60000) + Random(Players[CurrentPlayer].Integers[3] * 60000);
        1: BreakIn := (Players[CurrentPlayer].Integers[2] * 60000) - Random(Players[CurrentPlayer].Integers[3] * 60000);
      end;
      State := Players[CurrentPlayer].Loc;
      LogInPlayer;
      repeat
        case (State) of
          'Banking': if (Bank) then State := 'Casting' else Break;
          'Casting': if (CastLoop) then State:= 'Banking' else Break;
        end;
        TakeBreak;
      until (False);
      Result := True;
    end;

    begin
      ClearDebug;
      MainInitForm;
      if (EndInitForm) then
        TerminateScript;
      FreeBitmap(b);
      {$IFDEF SMART}
      SMART_Server := 81;
      SMART_Members := True;
      SMART_Signed := True;
      {$ENDIF}
      SetUpSRL;
      DeclarePlayers;
      WriteLn(Players[CurrentPlayer].Name);
      DeclareOres;
      MainLoop;
      LogOut;
    end.

    And if you could guide me into fixing the problem it would be greatly appreciated by me and a bunch of other people who need a Superheat script. Thanks!

    EDIT:

    Also the script isnt meant to work fully after the form so dont expect it to do more than 1 or 2 runs before it starts crashing

  2. #2
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    declaring your form should look like this -

    SCAR Code:
    frmDesign := CreateForm;
      with frmDesign do
      begin
        OnClose := @InitFormOnClose;
        BorderStyle := bsSingle;
        //BorderIcons := [biMaximize,biMinimize];
        SetBounds(444, 152, 447, 377);
        Caption := 'AutoSuperheat';
      end;
    You don't need all that stuff at the bottom because it's set as the default. And getting rid of the close button is not nice move.

    i dont think your error has to do with that, but i cant reproduce the error because of other problems with simba crashing
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  3. #3
    Join Date
    Dec 2006
    Posts
    908
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    Still getting error

  4. #4
    Join Date
    Sep 2010
    Posts
    37
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    it says to me that your if def statements aren't done properly, I fixed that, tried to run it and it says a bitmap is missing. If you would kindly provide me with a version without the bitmaps included (although that might be the error) I would appreciate it. (I'm just learning how to make forms at the moment too so I thought maybe I could help out)

  5. #5
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Needed a few changes but it works on my pc.
    You can't have "{$IFDEF}" or any of those inside of "{ }" comments!
    You should use "//".
    Also no need to include smart just define it and srl will include it itself.

    Code:
    program AutoSuperheat;
    {$DEFINE SMART}
    {$i SRL\SRL.scar}
    
    const
      FAILSAFE_CHESTCOLOR = 5592409;
      FAILSAFE_TOLERANCE = 5;
    
    var
      Global: TPoint;
    
    var
      EndInitForm : Boolean;
      frmDesign : TForm;
      Label1, Label2, Label3, Label4, Label5, Label6, Label7, Label9, Label8, Label10, Label11, Label12, Label13 : TLabel;
      ComboBox1, ComboBox2, ComboBox3 : TComboBox;
      ListBox1 : TListBox;
      CheckBox1, CheckBox3, CheckBox4 : TCheckBox;
      Edit1, Edit2, Edit3, Edit4, Edit5, Edit6, Edit7 : TEdit;
      Button1, Button2, Button3 : TButton;
      GroupBox1 : TGroupBox;
      Image1 : TImage;
      b: Integer;
    
    {NEED HELP, ERROR: EXCEPTION: ACCESS VIOLATION AT LINE 38 AND SO FORTH WHEN I TRY DECLARING PLAYERS FROM FORM'S INPUTS}
    
    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
    
      with Players[0] do
      begin
        Name := Edit1.Text; {FROM HERE}
        Pass := Edit2.Text;
        Nick := '';
        Pin := Edit3.Text;
        Players[CurrentPlayer].Loc := 'Banking';
        Active := True;
    
        Strings[0] := ComboBox1.Text; //Which Bank   Soul Wars Bank or Grand Exchange
        Integers[0] := 500;//Antiban% - Default = 500 = 5%
        Integers[1] := 25;//Mouse Speed - Script's maximum is 50. Therefor, 50 = 100%, 25 = 50% and so on.
        Integers[2] := StrToInt(Edit4.Text);//Break In minuites?
        Integers[3] := StrToInt(Edit5.Text);//Break In additional or subtractional. Enables randomness to breaks customary to user.
        Integers[4] := StrToInt(Edit6.Text);//Break for in minuites?
        Integers[5] := StrToInt(Edit7.Text);//Break for in additional or subtractional. Enables randomness to breaks customary to user.
        Integers[6] := ListBox1.ItemIndex;//Which ore, ya weird so let me lay it out. 0 - runite, 1 - adamant, 2 - mithril, 3 - gold, 4 - steel, 5 - iron
        Booleans[0] := CheckBox4.Checked;//Break?
      end;                                              {TO HERE}
    end;
    
    procedure InitFormOnClose(Sender : TObject; var Action : TCloseAction);
    begin
      if (not(frmDesign.ModalResult = 1)) then
        EndInitForm := True;
    end;
    
    procedure StartScript(Sender: TObject);
    begin
      WriteLn(Edit1.Text);
      WriteLn(Edit2.Text);
      WriteLn(Edit3.Text);
      WriteLn(Inttostr(ListBox1.ItemIndex));
      WriteLn(BoolToStr(CheckBox4.Checked));
      WriteLn(Replace(ComboBox3.Text, '%', ''));
    end;
    
    procedure InitForm;
    begin
      frmDesign := CreateForm;
      with frmDesign do
      begin
        OnClose := @InitFormOnClose;
        BorderStyle := bsSingle;
        BorderIcons := [biMaximize,biMinimize];
        Left := 444;
        Top := 152;
        Caption := 'AutoSuperheat';
        ClientHeight := 377;
        ClientWidth := 447;
        Color := clBtnFace;
        Font.Color := clWindowText;
        Font.Height := -11;
        Font.Name := 'MS Sans Serif';
        Font.Style := [];
        PixelsPerInch := 96;
      end;
      Label1 := TLabel.Create(frmDesign);
      with Label1 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 112;
        Width := 25;
        Height := 13;
        Caption := 'Bank';
      end;
      Label2 := TLabel.Create(frmDesign);
      with Label2 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 160;
        Width := 17;
        Height := 13;
        Caption := 'Ore';
      end;
      Label3 := TLabel.Create(frmDesign);
      with Label3 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 160;
        Width := 25;
        Height := 13;
        Caption := 'Misc.';
      end;
      Label4 := TLabel.Create(frmDesign);
      with Label4 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 280;
        Width := 48;
        Height := 13;
        Caption := 'Username';
      end;
      Label5 := TLabel.Create(frmDesign);
      with Label5 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 280;
        Width := 46;
        Height := 13;
        Caption := 'Password';
      end;
      Label6 := TLabel.Create(frmDesign);
      with Label6 do
      begin
        Parent := frmDesign;
        Left := 288;
        Top := 280;
        Width := 18;
        Height := 13;
        Caption := 'PIN';
      end;
      Label7 := TLabel.Create(frmDesign);
      with Label7 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 112;
        Width := 71;
        Height := 13;
        Caption := 'Anti-Ban Setup';
      end;
      Label9 := TLabel.Create(frmDesign);
      with Label9 do
      begin
        Parent := frmDesign;
        Left := 360;
        Top := 152;
        Width := 18;
        Height := 20;
        Caption := '+/-';
        Font.Color := clWindowText;
        Font.Height := -16;
        Font.Name := 'MS Sans Serif';
        Font.Style := [];
      end;
      Label8 := TLabel.Create(frmDesign);
      with Label8 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 136;
        Width := 128;
        Height := 13;
        Caption := 'Break In...          Random   ';
      end;
      Label10 := TLabel.Create(frmDesign);
      with Label10 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 184;
        Width := 119;
        Height := 13;
        Caption := 'Break for...         Random';
      end;
      Label11 := TLabel.Create(frmDesign);
      with Label11 do
      begin
        Parent := frmDesign;
        Left := 360;
        Top := 200;
        Width := 18;
        Height := 20;
        Caption := '+/-';
        Font.Color := clWindowText;
        Font.Height := -16;
        Font.Name := 'MS Sans Serif';
        Font.Style := [];
      end;
      Label12 := TLabel.Create(frmDesign);
      with Label12 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 232;
        Width := 40;
        Height := 13;
        Caption := 'Anti-Ban';
      end;
      Label13 := TLabel.Create(frmDesign);
      with Label13 do
      begin
        Parent := frmDesign;
        Left := 360;
        Top := 232;
        Width := 66;
        Height := 13;
        Caption := 'Mouse Speed';
      end;
      ComboBox1 := TComboBox.Create(frmDesign);
      with ComboBox1 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 128;
        Width := 121;
        Height := 21;
        ItemHeight := 13;
        TabOrder := 0;
        Text := 'Select a bank...';
        with Items do
        begin
          Add('Soul Wars Bank');
          Add('Grand Exchange');
        end;
      end;
      ListBox1 := TListBox.Create(frmDesign);
      with ListBox1 do
      begin
        Parent := frmDesign;
        Tag := 1;
        Left := 16;
        Top := 184;
        Width := 97;
        Height := 81;
        ItemHeight := 13;
        with Items do
        begin
          Add('Runite');
          Add('Adamantite');
          Add('Mithril');
          Add('Gold');
          Add('Steel');
          Add('Iron');
        end;
        TabOrder := 1;
      end;
      CheckBox1 := TCheckBox.Create(frmDesign);
      with CheckBox1 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 184;
        Width := 129;
        Height := 16;
        Caption := 'Goldsmith gauntlets?';
        Checked := True;
        State := cbChecked;
        TabOrder := 2;
      end;
      CheckBox3 := TCheckBox.Create(frmDesign);
      with CheckBox3 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 216;
        Width := 129;
        Height := 16;
        Caption := 'Use SMART debug?';
        TabOrder := 3;
      end;
      Edit1 := TEdit.Create(frmDesign);
      with Edit1 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 296;
        Width := 97;
        Height := 21;
        TabOrder := 4;
      end;
      Edit2 := TEdit.Create(frmDesign);
      with Edit2 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 296;
        Width := 97;
        Height := 21;
        PasswordChar := '*';
        TabOrder := 5;
      end;
      Edit3 := TEdit.Create(frmDesign);
      with Edit3 do
      begin
        Parent := frmDesign;
        Left := 288;
        Top := 296;
        Width := 48;
        Height := 21;
        PasswordChar := '*';
        TabOrder := 6;
        Text := '0000';
      end;
      Button1 := TButton.Create(frmDesign);
      with Button1 do
      begin
        Parent := frmDesign;
        Left := 144;
        Top := 336;
        Width := 72;
        Height := 25;
        Caption := 'Start Script';
        ModalResult := 1;
        TabOrder := 7;
        Button1.OnClick := @StartScript;
      end;
      Button2 := TButton.Create(frmDesign);
      with Button2 do
      begin
        Parent := frmDesign;
        Left := 224;
        Top := 336;
        Width := 81;
        Height := 24;
        Caption := 'Save Options';
        ModalResult := 6;
        TabOrder := 8;
      end;
      Edit4 := TEdit.Create(frmDesign);
      with Edit4 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 152;
        Width := 49;
        Height := 21;
        TabOrder := 9;
        Text := '300';
      end;
      Edit5 := TEdit.Create(frmDesign);
      with Edit5 do
      begin
        Parent := frmDesign;
        Left := 384;
        Top := 152;
        Width := 41;
        Height := 21;
        TabOrder := 10;
        Text := '100';
      end;
      Edit6 := TEdit.Create(frmDesign);
      with Edit6 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 200;
        Width := 48;
        Height := 21;
        TabOrder := 11;
        Text := '25';
      end;
      Edit7 := TEdit.Create(frmDesign);
      with Edit7 do
      begin
        Parent := frmDesign;
        Left := 384;
        Top := 200;
        Width := 40;
        Height := 21;
        TabOrder := 12;
        Text := '10';
      end;
      ComboBox2 := TComboBox.Create(frmDesign);
      with ComboBox2 do
      begin
        Parent := frmDesign;
        Left := 304;
        Top := 248;
        Width := 48;
        Height := 21;
        ItemHeight := 13;
        TabOrder := 13;
        Text := '5%';
        with Items do
        begin
          Add('50%');
          Add('25%');
          Add('10%');
          Add('5%');
          Add('1%');
        end;
      end;
      ComboBox3 := TComboBox.Create(frmDesign);
      with ComboBox3 do
      begin
        Parent := frmDesign;
        Left := 376;
        Top := 248;
        Width := 48;
        Height := 21;
        ItemHeight := 13;
        TabOrder := 14;
        Text := '70%';
        with Items do
        begin
          Add('100%');
          Add('90%');
          Add('80%');
          Add('70%');
          Add('60%');
          Add('50%');
          Add('40%');
          Add('30%');
          Add('25%');
        end;
      end;
      CheckBox4 := TCheckBox.Create(frmDesign);
      with CheckBox4 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 200;
        Width := 129;
        Height := 16;
        Caption := 'Take breaks?';
        Checked := True;
        State := cbChecked;
        TabOrder := 15;
      end;
      GroupBox1 := TGroupBox.Create(frmDesign);
      with GroupBox1 do
      begin
        Parent := frmDesign;
        Left := 8;
        Top := 8;
        Width := 433;
        Height := 96;
        Caption := 'AutoSuperheat';
        TabOrder := 16;
      end;
      Image1 := TImage.Create(GroupBox1);
      with Image1 do
      begin
        Parent := GroupBox1;
        Left := 8;
        Top := 0;
        Width := 416;
        Height := 72;
        //b := LoadBitmap(ScriptPath + 'Logo.bmp');
        //{$IFDEF SIMBA}
        //DrawBitmap(b, Image1.Canvas, 0, 0);
        //{$ENDIF}
      end;
      Button3 := TButton.Create(frmDesign);
      with Button3 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 232;
        Width := 113;
        Height := 25;
        Caption := 'View Current Profits?';
        TabOrder := 17;
      end;
    end;
    
    procedure SafeInitForm;
    var
      v : TVariantArray;
    begin
      SetArrayLength(v, 0);
      ThreadSafeCall('InitForm', v);
    end;
    
    procedure ShowInitFormModal;
    begin
      frmDesign.ShowModal;
    end;
    
    procedure SafeShowInitFormModal;
    var
      v : TVariantArray;
    begin
      SetArrayLength(v, 0);
      ThreadSafeCall('ShowInitFormModal', v);
    end;
    
    procedure MainInitForm;
    begin
      try
        SafeInitForm;
        SafeShowInitFormModal;
      finally
        FreeForm(frmDesign);
      except
        WriteLn('An error seems to have occurred in: InitForm');
      end;
    end;
    
    type TOre = record
      UpText: TStringArray;
      Color:  Integer;
      Tolerance: Byte;
      Amount: Byte;
    end;
    
    var
      TOreArray: Array [0..1] of TOre;
      BreakIn, BreakFor: Integer;
    
    function CreateOre(Color, Tolerance: Integer): Integer;
    var
      DMP: TDTMPointDef;
      DSP: Array [0..5] of TDTMPointDef;
      TempTDTM: TDTM;
    begin
      DMP.x := 450;
      DMP.y := 108;
      DMP.AreaSize := 5;
      DMP.AreaShape := 0;
      DMP.Color := Color;
      DMP.Tolerance := Tolerance;
    
      DSP[0].x := 450;
      DSP[0].y := 108;
      DSP[0].AreaSize := 5;
      DSP[0].AreaShape := 0;
      DSP[0].Color := Color;
      DSP[0].Tolerance := Tolerance;
    
      DSP[1].x := 460;
      DSP[1].y := 112;
      DSP[1].AreaSize := 1;
      DSP[1].AreaShape := 0;
      DSP[1].Color := 131072;
      DSP[1].Tolerance := 255;
    
      DSP[2].x := 446;
      DSP[2].y := 121;
      DSP[2].AreaSize := 1;
      DSP[2].AreaShape := 0;
      DSP[2].Color := 131072;
      DSP[2].Tolerance := 255;
    
      DSP[3].x := 434;
      DSP[3].y := 108;
      DSP[3].AreaSize := 1;
      DSP[3].AreaShape := 0;
      DSP[3].Color := 131072;
      DSP[3].Tolerance := 255;
    
      DSP[4].x := 463;
      DSP[4].y := 101;
      DSP[4].AreaSize := 1;
      DSP[4].AreaShape := 0;
      DSP[4].Color := 131072;
      DSP[4].Tolerance := 255;
    
      DSP[5].x := 438;
      DSP[5].y := 115;
      DSP[5].AreaSize := 1;
      DSP[5].AreaShape := 0;
      DSP[5].Color := 131072;
      DSP[5].Tolerance := 255;
    
      TempTDTM.MainPoint := DMP;
      TempTDTM.SubPoints := DSP;
      Result := AddDTM(TempTDTM);
    end;
    
    procedure DeclareOres;
    begin
      case Players[CurrentPlayer].Integers[6] of
        5:
          with TOreArray[0] do
          begin
            UpText := ['ron ore'];
            Color := 1449523;
            Tolerance := 20;
            Amount := 28;
          end;
        4:
          begin
            with TOreArray[0] do
            begin
              UpText := ['ron ore'];
              Color := 1449523;
              Tolerance := 20;
              Amount := 14;
            end;
            with TOreArray[1]  do
            begin
              UpText := ['oal'];
              Color := 1778724;
              Tolerance := 20;
              Amount := 14;
            end;
          end;
        3:
          with TOreArray[0] do
          begin
            UpText := ['old ore'];
            Color := 1741495;
            Tolerance := 15;
            Amount := 28;
          end;
        2:
          begin
            with TOreArray[0] do
            begin
              UpText := ['ithril ore'];
              Color := 5256757;
              Tolerance := 20;
              Amount := 5;
            end;
            with TOreArray[1]  do
            begin
              UpText := ['oal'];
              Color := 1778724;
              Tolerance := 20;
              Amount := 20;
            end;
          end;
        1:
          begin
            with TOreArray[0] do
            begin
              UpText := ['damantite ore'];
              Color := 4081469;
              Tolerance := 20;
              Amount := 3;
            end;
            with TOreArray[1]  do
            begin
              UpText := ['oal'];
              Color := 1778724;
              Tolerance := 20;
              Amount := 18;
            end;
          end;
        0:
          begin
            with TOreArray[0] do
            begin
              UpText := ['unite ore'];
              Color := 5722435;
              Tolerance := 20;
              Amount := 3;
            end;
            with TOreArray[1]  do
            begin
              UpText := ['oal'];
              Color := 1778724;
              Tolerance := 20;
              Amount := 24;
            end;
          end;
      end;
    end;
    
    procedure CheckObjective(Time: Integer);
    var
      arA, arP, arAP: TPointArray;
      P: TPoint;
    begin
      if (not(GameTab(tab_Objectives))) then
        Exit;
      FindColors(arA, 42516, 595, 387, 691, 401);
      FindColors(arP, 5844, 595, 387, 691, 401);
      arAP := CombineTPA(arA, arP);
      if Length(arAP) < 1000 then
      begin
        if (not(GameTab(tab_Stats))) then
          Exit;
        case (Random(2)) of
          0: P := SkillToCoords('Smithing');
          1: P := SkillToCoords('Magic');
        end;
        Mouse(P.x, P.y, 10, 10, False);
        if (WaitOptionMulti(['et', 'bjective'], 1500)) then
        begin
          Wait(RandomRange(500, 1000));
          TypeSend('99');
          if (not(GameTab(tab_Objectives))) then
            Exit;
        end;
      end;
      MouseBox(585, 383, 701, 405, 3);
      Wait(Time);
      Exit;
    end;
    
    procedure TakeBreak;
    var
      Time: Array [0..2] of Integer;
      i: Integer;
    begin
      if (Players[CurrentPlayer].Booleans[0] = False) then
        Exit;
      if (GetSystemTime > BreakIn) then
      begin
        case (Random(2)) of
          0: BreakFor := (Players[CurrentPlayer].Integers[4] * 60000) + Random(Players[CurrentPlayer].Integers[5] * 60000);
          1: BreakFor := (Players[CurrentPlayer].Integers[4] * 60000) - Random(Players[CurrentPlayer].Integers[5] * 60000);
        end;
        LogOut;
        ConvertTime(BreakFor, Time[0], Time[1], Time[2]);
        WriteLn('Breaking for ' + IntToStr(Time[0]) + ' Hours, ' + IntToStr(Time[1]) + ' Minuites, and ' + IntToStr(Time[2]) + ' Seconds.');
        repeat
          Wait(100);
          i := i + 1
          if (i > 300) then
          begin
            ConvertTime(BreakFor - GetSystemTime, Time[0], Time[1], Time[2]);
            i := 0;
            WriteLn('Time remaining ' + IntToStr(Time[0]) + ' Hours, ' + IntToStr(Time[1]) + ' Minuites, and ' + IntToStr(Time[2]) + ' Seconds.');
          end;
        until (GetSystemTime > BreakFor);
        case (Random(2)) of
          0: BreakIn := (Players[CurrentPlayer].Integers[2] * 60000) + Random(Players[CurrentPlayer].Integers[3] * 60000);
          1: BreakIn := (Players[CurrentPlayer].Integers[2] * 60000) - Random(Players[CurrentPlayer].Integers[3] * 60000);
        end;
        LogInPlayer;
      end;
    end;
    
    function WaitBankScreen(Time: Integer): Boolean;
    var
      t: LongInt;
    begin
      Result := False;
      t := GetSystemTime + Time;
      while (GetSystemTime < t) do
      begin
        if (BankScreen) then
        begin
          Result := True;
          Exit;
        end;
        if (Length(Players[CurrentPlayer].Pin) = 4) then
          if (PinScreen) then
          begin
            InPin(Players[CurrentPlayer].Pin);
            Wait(RandomRange(1500, 3000));
            ClickToContinue;
          end;
        Wait(RandomRange(75, 100));
      end;
    end;
    
    procedure RandomHuman;
    begin
      case (Random(Players[CurrentPlayer].Integers[0])) of
        0: CheckObjective(RandomRange(1000, 3000));
        1: HoverSkill('Smithing', False);
        2: HoverSkill('Magic', False);
        3: PickupMouse;
        4: BoredHuman;
        5: ExamineInv;
        6: RandomMovement;
        7: RandomAngle('Up');
        8: RandomRClick;
        9:
          begin
            MakeCompass(Random(360));
            Wait(RandomRange(500, 1000));
            MakeCompass('N');
          end;
      end;
    end;
    
    function FindChest(): Boolean;
    var
      ATPA: T2DPointArray;
      TPA: TPointArray;
      P: TPoint;
      CTS, h, i: Integer;
      t, l: LongInt;
    begin
      MakeCompass('N');
      SetAngle(True);
      t := GetSystemTime;
      repeat
        if ((GetSystemTime - t) > 20000) then
          Break;
        CTS := GetColorToleranceSpeed;
        ColorToleranceSpeed(2);
        SetColorSpeed2Modifiers(0.04, 0.12);
        FindColorsSpiralTolerance(MSCX, MSCY, TPA, 8027016, MSX1, MSY1, MSX2, MSY2, 31);
        SetColorSpeed2Modifiers(0.2, 0.2);
        ColorToleranceSpeed(CTS);
        if (Length(TPA) < 1) then
          Continue;
        ATPA := TPAToATPAEx(TPA, 30, 30);
        SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY - 15));
        l := GetSystemTime;
        h := High(ATPA);
        for i := 0 to h do
        begin
          if ((GetSystemTime - l) > 15000) then
            Break;
          if (BankScreen) then
          begin
            Result := True;
            Break;
          end;
          if (Length(ATPA[i]) < 200) then
            Continue;
          P := MiddleTPA(ATPA[i]);
          MMouse(P.x, P.y, 3, 3);
          if (not (WaitUpTextMulti(['ank chest', 'Bank', 'chest'], 1500))) then
            Continue;
          GetMousePos(P.x, P.y);
          Mouse(P.x, P.y, 0, 0, False);
          if (not(WaitOption('Use', 1500))) then
            Continue;
          if (WaitBankScreen(750)) then
          begin
            Result := True;
            Break;
          end;
        end;
      until (Result);
      if (Result) then
        Exit
      else
      begin
        P := Point(MSCX, MSCY - 15);
        if (FindObjTPA(P.x, P.y, FAILSAFE_CHESTCOLOR, FAILSAFE_TOLERANCE, 1, 30, 30, 100, ['ank chest'])) then
        begin
          Mouse(P.x, P.y, 0, 0, False);
          if (WaitOption('Use', 1500)) then
            if WaitBankScreen(750) then
            begin
              Result := True;
              Exit;
            end else
              Exit;
        end;
      end;
    end;
    
    function Bank(): Boolean;
    var
      DTM, i, l, t: Integer;
      a: Extended;
      P: TPoint;
    begin
      a := SymbolAccuracy;
      l := 0;
      Result := False;
      repeat
        if (FindChest) then
          Break;
        if (BankScreen) then
          Break;
        if (l >= 5) then
          Exit;
        if (FindSymbol(P.x, P.y, 'Bank')) then
        begin
          Mouse(P.x, P.y, 1, 1, True);
          Flag;
        end else
          SymbolAccuracy := SymbolAccuracy - 0.1;
        l := l + 1;
      until (False);
      SymbolAccuracy := a;
      t := 0;
      repeat
        Deposit(1, 27, True);
        t := t + 1;
        if (t > 5) then
          Exit;
        Wait(750);
      until (InvCount = 1);
      FixBankTab;
      FixBank;
      DTM := CreateOre(TOreArray[0].Color, TOreArray[0].Tolerance);
      for i := 0 to 5 do
      begin
        if (not(FindDTM(DTM, P.x, P.y, MBX1, MBY1, MBX2, MBY2))) then
        begin
          FreeDTM(DTM);
          Exit;
        end;
        MouseBox(P.x - 10, P.y - 10, P.x + 10, P.y + 10, 3);
        if (WaitUpTextMulti(TOreArray[0].UpText, 1500)) then
        begin
          GetMousePos(P.x, P.y);
          Mouse(P.x, P.y, 0, 0, False);
          if (TOreArray[0].Amount = 14) then
            if (WaitOption('ithdraw-14', 1500)) then
              Break;
          if (TOreArray[0].Amount = 28) then
            if (WaitOption('ithdraw All', 1500)) then
              Break;
          if (TOreArray[0].Amount < 28) then
            if (WaitOption('ithdraw-x', 1500)) then
            begin
              Wait(RandomRange(500, 750));
              TypeSend(IntToStr(TOreArray[0].Amount));
              Break;
            end;
        end;
      end;
      FreeDTM(DTM);
      if (TOreArray[1].Color <> 0) then
      begin
        DTM := CreateOre(TOreArray[1].Color, TOreArray[1].Tolerance);
        for i := 0 to 5 do
        begin
          if (not(FindDTM(DTM, P.x, P.y, MBX1, MBY1, MBX2, MBY2))) then
          begin
            FreeDTM(DTM);
            Exit;
          end;
          MouseBox(P.x - 10, P.y - 10, P.x + 10, P.y + 10, 3);
          if (WaitUpTextMulti(TOreArray[1].UpText, 1500))  then
          begin
            GetMousePos(P.x, P.y);
            Mouse(P.x, P.y, 0, 0, True);
            if (TOreArray[1].Amount = 14) then
              if (WaitOption('ithdraw-14', 1500)) then
                Break;
            case Random(25) of
              0..24: if (WaitOption('ithdraw All', 1500)) then Break;
              25:
                begin
                  if (WaitOption('ithdraw-x', 1500))then
                  begin
                    Wait(RandomRange(750, 1500));
                    TypeSend(IntToStr(TOreArray[1].Amount));
                    Break;
                  end;
                end;
            end;
          end;
        end;
        FreeDTM(DTM);
      end;
      CloseBank;
      Wait(RandomRange(500, 750));
      if (not(GameTab(tab_Inv))) then
        Exit;
      DTM := CreateOre(TOreArray[0].Color, TOreArray[0].Tolerance);
      Result := (CountItemsIn('inv', 'SRL_DTM', DTM, []) = TOreArray[0].Amount);
      FreeDTM(DTM);
    end;
    
    function CastLoop(): Boolean;
    var
      Bitmap, DTM, i: Integer;
      P: TPoint;
    begin
      DTM := CreateOre(TOreArray[0].Color, TOreArray[0].Tolerance);
      Bitmap := BitmapFromString(14, 7, 'meJw9kDEKwkAQRdmNJrFIbpBecPE' +
               'MizewtRAsUnsAsbH1CKmtrdNYpYq9jYXYKEFE1EZZEN86IAzhzf9/' +
               'Z2ej41ynpR5tqUD1I1sHswvV0pZKehuUaPXUcQ6TgVFUZ44Ch92DV' +
               'hktR+Ss13/gk6bACseLwe7uLZXJhPbwBjAfMamaf5Ka7q+EuQsLwJ' +
               'JlAPP64PplGGJreH08Sxhgjr/UFHxJOucIyFtwadPTmyQgy5CUZcS' +
               'dLB+0AK0k/eSq4Tn8li8k64Ze');
      GameTab(28);
      i := 0;
      repeat
        if (GetCurrentTab = tab_Magic) then
        begin
          if (not(FindBitmapToleranceIn(Bitmap, Global.x, Global.y, MIX1, MIY1, MIX2, MIY2, 20))) then
          begin
            Result := False;
            Exit;
          end;
          MouseBox(Global.x - 1, Global.y - 12, Global.x + 15, Global.y + 10 , 3);
          if (WaitUpTextMulti(['Cast', 'uperheat'], 1000)) then
          begin
            GetMousePos(P.x, P.y);
            Mouse(P.x, P.y, 0, 0, True);
          end else
            Continue;
        end else
        begin
          GameTab(tab_Magic);
          Continue;
        end;
        if (WaitUpTextMulti(['uperheat', 'tem', '->'], 1500)) and (GetCurrentTab = tab_Inv) then
        begin
          if (FindDTM(DTM, P.x, P.y, MIX1, MIY1, MIX2, MIY2)) then
          begin
            MouseBox(P.x - 10, P.y - 10, P.x + 10, P.y + 10, 3);
            if (WaitUpTextMulti(TOreArray[0].UpText, 1000)) then
            begin
              GetMousePos(P.x, P.y);
              Mouse(P.x, P.y, 0, 0, True);
              i := i + 1;
              RandomHuman;
              Wait(RandomRange(150, 750));
              GameTab(tab_Magic);
            end else
            begin
              RandomHuman;
              GameTab(tab_Magic);
              Continue;
            end;
          end else
          begin
            GetMousePos(P.x, P.y);
            Mouse(P.x,  P.y, 0, 0, False);
            WaitOption('Cancel', 1000);
            Break;
          end;
        end else
        begin
          GameTab(tab_Magic);
          Continue;
        end;
      until (i >= TOreArray[0].Amount);
      GameTab(tab_Inv);
      Result := (not(FindDTM(DTM, P.x, P.y, MIX1, MIY1, MIX2, MIY2)));
      FreeDTM(DTM);
      FreeBitmap(Bitmap);
    end;
    
    function MainLoop(): Boolean;
    var
      State: String;
    begin
      case (Random(2)) of
        0: BreakIn := (Players[CurrentPlayer].Integers[2] * 60000) + Random(Players[CurrentPlayer].Integers[3] * 60000);
        1: BreakIn := (Players[CurrentPlayer].Integers[2] * 60000) - Random(Players[CurrentPlayer].Integers[3] * 60000);
      end;
      State := Players[CurrentPlayer].Loc;
      LogInPlayer;
      repeat
        case (State) of
          'Banking': if (Bank) then State := 'Casting' else Break;
          'Casting': if (CastLoop) then State:= 'Banking' else Break;
        end;
        TakeBreak;
      until (False);
      Result := True;
    end;
    
    begin
      ClearDebug;
      MainInitForm;
      if (EndInitForm) then
        TerminateScript;
      //FreeBitmap(b);
      {$IFDEF SMART}
      SMART_Server := 81;
      SMART_Members := True;
      SMART_Signed := True;
      {$ENDIF}
      SetUpSRL;
      DeclarePlayers;
      WriteLn(Players[CurrentPlayer].Name);
      DeclareOres;
      MainLoop;
      LogOut;
    end.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  6. #6
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    You freed the form and then tried to get the values. You can't do that

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
  •