Results 1 to 11 of 11

Thread: Invalid Pointer Error.

  1. #1
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Invalid Pointer Error.

    SCAR Code:
    program New;
    {.Include SRL/SRL.scar}
    {.include srl/srl/misc/Reports.scar}
    {.include srl/srl/misc/GrandExchange.scar}
    {.include GEInclude.scar}


    const
      Smart = false;
      SmartWorld = 20;

    { If MaxRunTime is met before MaxCycles, script will terminate. Same Vise- versa }


    var didbuy, didsell: boolean;
    Itemprice, CheckEvery, MaxRunTime, MaxCycles : integer;
    ItemToAlch : string;

    var
      // InitForm variables.
      EndInitForm, StopWaiting : Boolean;
      frmDesign : TForm;
      Label1, Label2, Label3, Label4,
      Label5 : TLabel;
      Button1, Button2 : TButton;
      Edit1, Edit2, Edit3, Edit4 : TEdit;
     
    var
      // InitForm variables.
      frmDesign2 : TForm;
      Label67, Label68, Label69, Label70,
      Label71, Label6, Label8, Label9,
      Label7, Label10, Label11, Label12 : array[0..65536] of TLabel;
      Edit68, Edit69, Edit70, Edit71,
      Edit5, Edit6, Edit8, Edit9,
      Edit7, Edit10, Edit11, Edit12 : array[0..65536] of TEdit;
      RadioButton3, RadioButton4, RadioButton5 : array[0..65536] of TRadioButton;
      Button3, Button4 : TButton;
      PageControl : TPageControl;
      TabPages : array [0..65535] of TTabSheet;
      Playaz : Integer;
      GroupBox1 : array[0..65536] of TGroupBox;

    procedure DeclarePlayers;
    Var
      I : Integer;
    begin
      Try
        For I := 1 To High(Edit71) do
          wait(1);
      Except
        HowManyPlayers := I;
        NumberOfPlayers(HowManyPlayers);
        CurrentPlayer := 0;
        writeln('Declaring Players');
      end;
      for i := 1 to HowManyPlayers do
      with Players[I - 1] do
      begin
        Name := Edit68[I - 1].text;
        Pass := Edit69[I - 1].text;
        Nick := Edit70[I - 1].text;
        Pin := Edit71[I - 1].text;
        Active := True;
        try
          BoxRewards := Explode(',', Edit5[I - 1].text);
        except
          BoxRewards := [Edit5[I - 1].text];
        end;
        Booleans[1] := RadioButton3[I - 1].checked;  //Buy?
        Integers[0] := StrToIntDef(Edit6[I - 1].text, 0); //Buy Amount
        Strings[0] := Edit8[I - 1].text; //Buy Name
        Strings[1] := Edit9[I - 1].text; //Buy Price, min, med, or max

        Booleans[2] := RadioButton4[I - 1].checked; //Sell
        Integers[1] := StrToIntDef(Edit7[I - 1].text, 0); //Sell amount
        Integers[2] := StrToIntDef(Edit10[I - 1].text, 1); //Item's Inventory spot
        Strings[2] := Edit11[I - 1].text; //Sell Name
        Strings[3] := Edit12[I - 1].text; //Sell Price, min, med, or max

        booleans[3] := RadioButton5[I - 1].checked; //only collect when offer is finished
      end;
    end;

    Function Contain(Stringz, Strings : String) : Boolean;
    Begin
      Result := Pos(Stringz, Strings) <> 0;
    End;

    Procedure HideForm(Sender: TObject);
    Begin
      if Sender = button1 then
      begin
        frmdesign.visible := false;
        frmDesign2.visible := true;
      end else
      begin
        frmdesign.visible := true;
        frmdesign2.visible := false;
      end;
    end;

    Function ItemId(Quereh : String) : String;
    Var
      ItemPage : String;
      C : Integer;
    Begin
      ItemPage := lowercase(GetPage('http://schumaker40.site90.com/Auth.scar'));
      If Not Contain(Quereh, ItemPage) Then
      Begin
        Result := 'Unknown Item Id';
        Exit;
      End;
      C := Pos(Quereh, ItemPage);
      While not (StrGet(ItemPage, C) = Chr(10)) Do
      Begin
        Dec(C);
      End;
      Result := GetNumbers(Copy(ItemPage, C, Length(Quereh)));
    end;

    Procedure GrabPrice;
    Var
      WebPage, ID : String;
    begin
      ID := ItemID(Lowercase(ItemToAlch));
      If ID <> '' Then
      begin
        WebPage := GetPage('http://itemdb-rs.runescape.com/viewitem.ws?obj=' + ID);
        WriteLn('Low price of a(n) ' + ItemToAlch + ': ' + Between('<b>Minimum price:</b> ', Chr(10) + '</span>', WebPage) + ' gold pieces.');
        WriteLn('Market price of a(n) ' + ItemToAlch + ': ' + Between('<b>Market price:</b> ', Chr(10) + '</span>', WebPage) + ' gold pieces.');
        WriteLn('High price of a(n) ' + ItemToAlch + ': ' + Between('<b>Maximum price:</b> ', Chr(10) + '</span>', WebPage) + ' gold pieces.');
        If Contain('k', Between('<b>Market price:</b> ', Chr(10) + '</span>', WebPage)) then
          ItemPrice := (StrToInt(GetNumbers(Between('<b>Market price:</b> ', (Chr(10)) + '</span>', WebPage))) * 1000)
        else
        If Contain('m', Between('<b>Market price:</b> ', Chr(10) + '</span>', WebPage)) then
          ItemPrice := StrToInt(GetNumbers(Between('<b>Market price:</b> ', Chr(10) + '</span>', WebPage))) * 1000000
        else
          ItemPrice := StrToInt(GetNumbers(Between('<b>Market price:</b> ', Chr(10) + '</span>', WebPage)));
      end else
        WriteLn('Could not retrieve a proper item id, please make sure you typed the name properly!');
    end;


    procedure scriptterminate;
    begin
      prog;
    end;

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

    Function IntToStrDef(Str : integer; Def : string) : string;
    begin
      try
        Result := IntToStr(Str);
        exit;
      except
        Result := Def;
        exit;
      end;
    end;

    Procedure UpdatePlayer;
    Begin
      WriteLn(Playaz);
      TabPages[Playaz] := TTabSheet.Create(frmDesign2);
      TabPages[Playaz].Caption := 'Player ' + IntToStrDef(Playaz, '0');
      TabPages[Playaz].PageControl := PageControl;
      GroupBox1[Playaz] := TGroupBox.Create(frmDesign2);
      with GroupBox1[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 8;
        Top := 104;
        Width := 280;
        Height := 20;
        Caption := '';
      end;
      Label67[Playaz] := TLabel.Create(frmDesign2);
      with Label67[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 8;
        Top := 24;
        Width := 48;
        Height := 13;
        Caption := 'Username';
      end;
      Label68[Playaz] := TLabel.Create(frmDesign2);
      with Label68[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 8;
        Top := 48;
        Width := 46;
        Height := 13;
        Caption := 'Password';
      end;
      Label69[Playaz] := TLabel.Create(frmDesign2);
      with Label69[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 184;
        Top := 24;
        Width := 48;
        Height := 13;
        Caption := 'Nickname';
      end;
      Label70[Playaz] := TLabel.Create(frmDesign2);
      with Label70[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 184;
        Top := 48;
        Width := 55;
        Height := 13;
        Caption := 'Pin Number';
      end;
      Label71[Playaz] := TLabel.Create(frmDesign2);
      with Label71[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 96;
        Top := 72;
        Width := 66;
        Height := 13;
        Caption := 'Lamp Reward';
      end;
      Label6[Playaz] := TLabel.Create(frmDesign2);
      with Label6[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 8;
        Top := 128;
        Width := 69;
        Height := 13;
        Caption := 'Amount to Buy';
      end;
      Label8[Playaz] := TLabel.Create(frmDesign2);
      with Label8[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 8;
        Top := 152;
        Width := 51;
        Height := 13;
        Caption := 'Item Name';
      end;
      Label9[Playaz] := TLabel.Create(frmDesign2);
      with Label9[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 8;
        Top := 176;
        Width := 24;
        Height := 13;
        Caption := 'Price';
      end;
      Label7[Playaz] := TLabel.Create(frmDesign2);
      with Label7[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 192;
        Top := 128;
        Width := 68;
        Height := 13;
        Caption := 'Amount to Sell';
      end;
      Label10[Playaz] := TLabel.Create(frmDesign2);
      with Label10[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 192;
        Top := 152;
        Width := 65;
        Height := 13;
        Caption := 'Inventory Slot';
      end;
      Label11[Playaz] := TLabel.Create(frmDesign2);
      with Label11[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 192;
        Top := 176;
        Width := 51;
        Height := 13;
        Caption := 'Item Name';
      end;
      Label12[Playaz] := TLabel.Create(frmDesign2);
      with Label12[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 192;
        Top := 200;
        Width := 24;
        Height := 13;
        Caption := 'Price';
      end;
      Edit68[Playaz] := TEdit.Create(frmDesign2);
      with Edit68[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 80;
        Top := 24;
        Width := 97;
        Height := 21;
        TabOrder := 8;
      end;
      Edit69[Playaz] := TEdit.Create(frmDesign2);
      with Edit69[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 80;
        Top := 48;
        Width := 97;
        Height := 21;
        TabOrder := 9;
      end;
      Edit70[Playaz] := TEdit.Create(frmDesign2);
      with Edit70[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 240;
        Top := 24;
        Width := 97;
        Height := 21;
        TabOrder := 10;
      end;
      Edit71[Playaz] := TEdit.Create(frmDesign2);
      with Edit71[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 240;
        Top := 48;
        Width := 97;
        Height := 21;
        TabOrder := 11;
      end;
      Edit5[Playaz] := TEdit.Create(frmDesign2);
      with Edit5[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 168;
        Top := 72;
        Width := 97;
        Height := 21;
        TabOrder := 12;
        Text := 'XP';
      end;
      RadioButton3[Playaz] := TRadioButton.Create(frmDesign2);
      with RadioButton3[Playaz] do
      begin
        Parent := GroupBox1[Playaz];
        Left := 2;
        Top := 2;
        Width := 113;
        Height := 17;
        Caption := 'Buy Items?';
        TabOrder := 13;
      end;
      Edit6[Playaz] := TEdit.Create(frmDesign2);
      with Edit6[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 81;
        Top := 128;
        Width := 97;
        Height := 21;
        TabOrder := 14;
      end;
      Edit8[Playaz] := TEdit.Create(frmDesign2);
      with Edit8[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 80;
        Top := 152;
        Width := 97;
        Height := 21;
        TabOrder := 15;
      end;
      Edit9[Playaz] := TEdit.Create(frmDesign2);
      with Edit9[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 80;
        Top := 176;
        Width := 97;
        Height := 21;
        TabOrder := 16;
        Text := 'Med';
      end;
      RadioButton4[Playaz] := TRadioButton.Create(frmDesign2);
      with RadioButton4[Playaz] do
      begin
        Parent := GroupBox1[Playaz];
        Left := 192;
        Top := 2;
        Width := 113;
        Height := 17;
        Caption := 'Sell Items?';
        TabOrder := 17;
      end;
      Edit7[Playaz] := TEdit.Create(frmDesign2);
      with Edit7[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 264;
        Top := 128;
        Width := 121;
        Height := 21;
        TabOrder := 18;
      end;
      Edit10[Playaz] := TEdit.Create(frmDesign2);
      with Edit10[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 264;
        Top := 152;
        Width := 121;
        Height := 21;
        TabOrder := 19;
      end;
      Edit11[Playaz] := TEdit.Create(frmDesign2);
      with Edit11[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 264;
        Top := 176;
        Width := 121;
        Height := 21;
        TabOrder := 20;
      end;
      Edit12[Playaz] := TEdit.Create(frmDesign2);
      with Edit12[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 264;
        Top := 200;
        Width := 121;
        Height := 21;
        TabOrder := 21;
        Text := 'Med';
      end;
      RadioButton5[Playaz] := TRadioButton.Create(frmDesign2);
      with RadioButton5[Playaz] do
      begin
        Parent := TabPages[Playaz];
        Left := 8;
        Top := 216;
        Width := 193;
        Height := 17;
        Caption := 'Only collect if the offer is completed?';
        TabOrder := 22;
      end;
      Inc(Playaz);
    End;

    Procedure UpdatePlayers(Sender : TObject);
    Var
      V : TVariantArray;
    Begin
      ThreadSafeCall('UpdatePlayer', v);
    end;

    // This form was parsed using DFM Form Parser v.26c Beta by Ron.
    // Generated from Mercher Player Form.dfm.
    procedure InitForm2;
    var
      TimeInitForm : Integer;
    begin
      TimeInitForm := GetSystemTime;
      frmDesign2 := CreateForm;
      with frmDesign2 do
      begin
        OnClose := @InitFormOnClose2;
        Position := poScreenCenter;
        BorderStyle := bsSingle;
        BorderIcons := [biMinimize,biSystemMenu];
        ClientWidth := 393;
        ClientHeight := 295;
        Caption := 'Player Set Up';
        Color := clBtnFace;
        Font.Color := clWindowText;
        Font.Height := -11;
        Font.Name := 'MS Sans Serif';
        Font.Style := [];
        PixelsPerInch := 96;
      end;
      PageControl := TPageControl.Create(frmDesign2);
      PageControl.Parent := frmDesign2;
      PageControl.Top := 2;
      PageControl.Left := 2;
      PageControl.Width := 390;
      PageControl.Height := 265;
      Playaz := 1;
      TabPages[0] := TTabSheet.Create(frmDesign2);
      TabPages[0].Caption := 'Player 0';
      TabPages[0].PageControl := PageControl;
      GroupBox1[0] := TGroupBox.Create(frmDesign2);
      with GroupBox1[0] do
      begin
        Parent := TabPages[0];
        Left := 8;
        Top := 104;
        Width := 280;
        Height := 20;
        Caption := '';
      end;
      Label67[0] := TLabel.Create(frmDesign2);
      with Label67[0] do
      begin
        Parent := TabPages[0];
        Left := 8;
        Top := 24;
        Width := 48;
        Height := 13;
        Caption := 'Username';
      end;
      Label68[0] := TLabel.Create(frmDesign2);
      with Label68[0] do
      begin
        Parent := TabPages[0];
        Left := 8;
        Top := 48;
        Width := 46;
        Height := 13;
        Caption := 'Password';
      end;
      Label69[0] := TLabel.Create(frmDesign2);
      with Label69[0] do
      begin
        Parent := TabPages[0];
        Left := 184;
        Top := 24;
        Width := 48;
        Height := 13;
        Caption := 'Nickname';
      end;
      Label70[0] := TLabel.Create(frmDesign2);
      with Label70[0] do
      begin
        Parent := TabPages[0];
        Left := 184;
        Top := 48;
        Width := 55;
        Height := 13;
        Caption := 'Pin Number';
      end;
      Label71[0] := TLabel.Create(frmDesign2);
      with Label71[0] do
      begin
        Parent := TabPages[0];
        Left := 96;
        Top := 72;
        Width := 66;
        Height := 13;
        Caption := 'Lamp Reward';
      end;
      Label6[0] := TLabel.Create(frmDesign2);
      with Label6[0] do
      begin
        Parent := TabPages[0];
        Left := 8;
        Top := 128;
        Width := 69;
        Height := 13;
        Caption := 'Amount to Buy';
      end;
      Label8[0] := TLabel.Create(frmDesign2);
      with Label8[0] do
      begin
        Parent := TabPages[0];
        Left := 8;
        Top := 152;
        Width := 51;
        Height := 13;
        Caption := 'Item Name';
      end;
      Label9[0] := TLabel.Create(frmDesign2);
      with Label9[0] do
      begin
        Parent := TabPages[0];
        Left := 8;
        Top := 176;
        Width := 24;
        Height := 13;
        Caption := 'Price';
      end;
      Label7[0] := TLabel.Create(frmDesign2);
      with Label7[0] do
      begin
        Parent := TabPages[0];
        Left := 192;
        Top := 128;
        Width := 68;
        Height := 13;
        Caption := 'Amount to Sell';
      end;
      Label10[0] := TLabel.Create(frmDesign2);
      with Label10[0] do
      begin
        Parent := TabPages[0];
        Left := 192;
        Top := 152;
        Width := 65;
        Height := 13;
        Caption := 'Inventory Slot';
      end;
      Label11[0] := TLabel.Create(frmDesign2);
      with Label11[0] do
      begin
        Parent := TabPages[0];
        Left := 192;
        Top := 176;
        Width := 51;
        Height := 13;
        Caption := 'Item Name';
      end;
      Label12[0] := TLabel.Create(frmDesign2);
      with Label12[0] do
      begin
        Parent := TabPages[0];
        Left := 192;
        Top := 200;
        Width := 24;
        Height := 13;
        Caption := 'Price';
      end;
      Edit68[0] := TEdit.Create(frmDesign2);
      with Edit68[0] do
      begin
        Parent := TabPages[0];
        Left := 80;
        Top := 24;
        Width := 97;
        Height := 21;
        TabOrder := 8;
      end;
      Edit69[0] := TEdit.Create(frmDesign2);
      with Edit69[0] do
      begin
        Parent := TabPages[0];
        Left := 80;
        Top := 48;
        Width := 97;
        Height := 21;
        TabOrder := 9;
      end;
      Edit70[0] := TEdit.Create(frmDesign2);
      with Edit70[0] do
      begin
        Parent := TabPages[0];
        Left := 240;
        Top := 24;
        Width := 97;
        Height := 21;
        TabOrder := 10;
      end;
      Edit71[0] := TEdit.Create(frmDesign2);
      with Edit71[0] do
      begin
        Parent := TabPages[0];
        Left := 240;
        Top := 48;
        Width := 97;
        Height := 21;
        TabOrder := 11;
      end;
      Edit5[0] := TEdit.Create(frmDesign2);
      with Edit5[0] do
      begin
        Parent := TabPages[0];
        Left := 168;
        Top := 72;
        Width := 97;
        Height := 21;
        TabOrder := 12;
        Text := 'XP';
      end;
      RadioButton3[0] := TRadioButton.Create(frmDesign2);
      with RadioButton3[0] do
      begin
        Parent := GroupBox1[0];
        Left := 2;
        Top := 2;
        Width := 113;
        Height := 17;
        Caption := 'Buy Items?';
        TabOrder := 13;
      end;
      Edit6[0] := TEdit.Create(frmDesign2);
      with Edit6[0] do
      begin
        Parent := TabPages[0];
        Left := 81;
        Top := 128;
        Width := 97;
        Height := 21;
        TabOrder := 14;
      end;
      Edit8[0] := TEdit.Create(frmDesign2);
      with Edit8[0] do
      begin
        Parent := TabPages[0];
        Left := 80;
        Top := 152;
        Width := 97;
        Height := 21;
        TabOrder := 15;
      end;
      Edit9[0] := TEdit.Create(frmDesign2);
      with Edit9[0] do
      begin
        Parent := TabPages[0];
        Left := 80;
        Top := 176;
        Width := 97;
        Height := 21;
        TabOrder := 16;
        Text := 'Med';
      end;
      RadioButton4[0] := TRadioButton.Create(frmDesign2);
      with RadioButton4[0] do
      begin
        Parent := GroupBox1[0];
        Left := 192;
        Top := 2;
        Width := 113;
        Height := 17;
        Caption := 'Sell Items?';
        TabOrder := 17;
      end;
      Edit7[0] := TEdit.Create(frmDesign2);
      with Edit7[0] do
      begin
        Parent := TabPages[0];
        Left := 264;
        Top := 128;
        Width := 121;
        Height := 21;
        TabOrder := 18;
      end;
      Edit10[0] := TEdit.Create(frmDesign2);
      with Edit10[0] do
      begin
        Parent := TabPages[0];
        Left := 264;
        Top := 152;
        Width := 121;
        Height := 21;
        TabOrder := 19;
      end;
      Edit11[0] := TEdit.Create(frmDesign2);
      with Edit11[0] do
      begin
        Parent := TabPages[0];
        Left := 264;
        Top := 176;
        Width := 121;
        Height := 21;
        TabOrder := 20;
      end;
      Edit12[0] := TEdit.Create(frmDesign2);
      with Edit12[0] do
      begin
        Parent := TabPages[0];
        Left := 264;
        Top := 200;
        Width := 121;
        Height := 21;
        TabOrder := 21;
        Text := 'Med';
      end;
      RadioButton5[0] := TRadioButton.Create(frmDesign2);
      with RadioButton5[0] do
      begin
        Parent := TabPages[0];
        Left := 8;
        Top := 216;
        Width := 193;
        Height := 17;
        Caption := 'Only collect if the offer is completed?';
        TabOrder := 22;
      end;
      Button3 := TButton.Create(frmDesign2);
      with Button3 do
      begin
        Parent := frmDesign2;
        Left := 75;
        Top := 267;
        Width := 121;
        Height := 25;
        Caption := 'Save and Close';
        TabOrder := 23;
        Onclick := @HideForm;
      end;
      Button4 := TButton.Create(frmDesign2);
      with Button4 do
      begin
        Parent := frmDesign2;
        Left := 225;
        Top := 267;
        Width := 80;
        Height := 25;
        Caption := 'New Player';
        TabOrder := 23;
        OnClick := @UpdatePlayers;
      end;
      WriteLn('InitForm compiled in ' + IntToStr(GetSystemTime - TimeInitForm) + ' milliseconds!');
    end;

    procedure SafeInitForm2;
    var
      v : TVariantArray;
    begin
      SetArrayLength(v, 0);
      ThreadSafeCall('InitForm2', v);
    end;

    procedure ShowInitFormModal2;
    begin
      frmDesign2.Show;
      frmdesign2.visible := false;
    end;

    procedure SafeShowInitFormModal2;
    var
      v : TVariantArray;
    begin
      SetArrayLength(v, 0);
      ThreadSafeCall('ShowInitFormModal2', v);
      while (not stopwaiting) do
        wait(15);
    end;

    procedure MainInitForm2(Sender : TObject);
    begin
      try
        SafeInitForm2;
        SafeShowInitFormModal2;
      finally
        FreeForm(frmDesign2);
      except
        WriteLn('An error seems to have occurred in: InitForm');
      end;
    end;

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

    Procedure Main(Sender : TObject);
    begin
      StopWaiting := True;
      CheckEvery := StrToIntDef(Edit1.text, 30);
      MaxRunTime := StrToIntDef(Edit2.text, 30);
      MaxCycles := StrToIntDef(Edit3.text, 10);
      ItemToAlch := Edit4.text;
      frmdesign.Free;
      DeclarePlayers;
      AwkSetUp(10 + random(5), SmartWorld, Smart, true);
      activateclient;
      marktime(running);
      repeat
        didbuy:= players[currentplayer].booleans[4];
        didsell:= players[currentplayer].booleans[5];
        repeat
          if not loggedin then loginplayer;
          findnormalrandoms;
          if not inge then
          begin
            A_Debug('Player is not in GE');
            players[currentplayer].active := false;
            NextPlayerP;
          end;
          Exchange;
          collect;
          if not didsell then SellOffer;
          if not didbuy then BuyOffer;
          if MCYcle = 0 then collect;
          CloseWindow;
          findnormalrandoms;
          prog;
          inc(cycle);
          NextPlayerP;
        until cycle = high(players);
        waitnow(CheckEvery);
        cycle := 0;
        inc(MCycle);
      until (timefrommark(running) >= (1000 * 60 * MaxRunTime + random(10))) or
        (MCycle = MaxCycles) or allplayersinactive;
    end;


    procedure InitForm;
    var
      TimeInitForm : Integer;
    begin
      TimeInitForm := GetSystemTime;
      frmDesign := CreateForm;
      with frmDesign do
      begin
        OnClose := @InitFormOnClose;
        Position := poScreenCenter;
        BorderStyle := bsSingle;
        BorderIcons := [biMinimize,biSystemMenu];
        ClientWidth := 276;
        ClientHeight := 155;
        Caption := 'Grand Exchange Merchanter';
        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 := 24;
        Width := 87;
        Height := 17;
        Caption := 'Check how often?';
      end;
      Label2 := TLabel.Create(frmDesign);
      with Label2 do
      begin
        Parent := frmDesign;
        Left := 80;
        Top := 8;
        Width := 73;
        Height := 13;
        Caption := 'General Set Up';
      end;
      Label3 := TLabel.Create(frmDesign);
      with Label3 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 48;
        Width := 99;
        Height := 13;
        Caption := 'Maximum Run Time?';
      end;
      Label4 := TLabel.Create(frmDesign);
      with Label4 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 72;
        Width := 103;
        Height := 13;
        Caption := 'Cycles per character?';
      end;
      Label5 := TLabel.Create(frmDesign);
      with Label5 do
      begin
        Parent := frmDesign;
        Left := 16;
        Top := 96;
        Width := 103;
        Height := 13;
        Caption := 'Item to grab price for?';
      end;
      Button1 := TButton.Create(frmDesign);
      with Button1 do
      begin
        Parent := frmDesign;
        Left := 24;
        Top := 120;
        Width := 97;
        Height := 25;
        Caption := 'Character Set Up';
        TabOrder := 8;
        Onclick := @HideForm;
      end;
      Edit1 := TEdit.Create(frmDesign);
      with Edit1 do
      begin
        Parent := frmDesign;
        Left := 120;
        Top := 24;
        Width := 145;
        Height := 21;
        TabOrder := 9;
        Text := '';
      end;
      Edit2 := TEdit.Create(frmDesign);
      with Edit2 do
      begin
        Parent := frmDesign;
        Left := 120;
        Top := 48;
        Width := 145;
        Height := 21;
        TabOrder := 10;
        Text := '';
      end;
      Edit3 := TEdit.Create(frmDesign);
      with Edit3 do
      begin
        Parent := frmDesign;
        Left := 120;
        Top := 72;
        Width := 145;
        Height := 21;
        TabOrder := 11;
        Text := '';
      end;
      Edit4 := TEdit.Create(frmDesign);
      with Edit4 do
      begin
        Parent := frmDesign;
        Left := 120;
        Top := 96;
        Width := 145;
        Height := 21;
        TabOrder := 12;
        Text := '';
      end;
      Button2 := TButton.Create(frmDesign);
      with Button2 do
      begin
        Parent := frmDesign;
        Left := 152;
        Top := 120;
        Width := 73;
        Height := 25;
        Caption := 'Start!';
        TabOrder := 13;
        OnClick := @Main;
      end;
      WriteLn('InitForm compiled in ' + IntToStr(GetSystemTime - TimeInitForm) + ' milliseconds!');
    end;

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

    procedure ShowInitFormModal;
    begin
      frmDesign.Show;
    end;

    procedure SafeShowInitFormModal;
    var
      v : TVariantArray;
    begin
      SetArrayLength(v, 0);
      ThreadSafeCall('ShowInitFormModal', v);
      MainInitForm2(button1);
      while (not stopwaiting) do
        wait(15);
    end;

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

    begin
      ClearDebug;
      GetSelf.WindowState := wsMinimized;
      MainInitForm;
      GetSelf.WindowState := wsNormal;
      if (EndInitForm) then
        TerminateScript;
    end.

    GEInclude.scar (save in Includes):

    SCAR Code:
    procedure prog;
    begin
        cleardebug;
        SRLPlayerReport(
                    ResultDebugBox, 0, false,
                    [True, False, False, False, False, True],
                    ['Buy Offers Made', 'Sell Offers Made'],
                    [], [3, 4], [], []);
    end;

    procedure NextPlayerP;
    begin
      LogOut;
      prog;
      NextPlayer(Players[(CurrentPlayer + 1)].Active);
      loginplayer;
    end;

    procedure collect;
    begin
      case players[currentplayer].booleans[3] of
        true : GERecoverFinished;
        false : GERecoverAll;
      end;
    end;

    procedure A_Debug(text: string);
    begin
      writeln('[' + thetime + '] ' + Players[currentplayer].Name +  ': Error Occured at: ' + text + '.');
      alert('[' + thetime + ']' + ' Error Occured at: ' + text + '.');
    end;

    function A_FindObj(color, tol : integer; uptext : string; left : boolean): boolean;
    var
      T : tpointarray;
      i, x, y, d: integer;
      time : integer;
      FindThis : boolean;
    begin
      result:= true;
      d:= 0;
      if not loggedin then loginplayer;
      ColorToleranceSpeed(3);
      time := 0;
      marktime(time);
      while not FindThis do
      begin
        FindColorsSpiralTolerance(MSCX, MSCY, T, color, MSX1, MSY1, MSX2, MSY2, tol);
        FindThis := Length(T) > 0; //thanks to noidea :)
        if timefrommark(time) > 5000 then break;
      end;
      ColorToleranceSpeed(1);
      if Length(T) = 0 then
      begin
        A_Debug('color not found');
        result:= false;
        exit;
      end;
      for i:= 0 to high(t) do
      begin
        mmouse(T[i].X, T[i].Y, 0, 0);
        if isuptext(uptext) then
        begin
          getmousepos(x, y);
          mouse(x, y, 0, 0, left);
          wait(100 + random(2000));
        end;
      end;
      if not result then
      begin
        A_Debug('Something has gone wrong');
        players[currentplayer].active := false;
      end;
    end;

    function Exchange : boolean;
    var time : integer;
    begin
      if not loggedin then loginplayer;
      if not A_FindObj(6455440, 5, 'Desk', false) then //Booth
        if not A_FindObj(4335153, 5, 'Grand Exchange clerk', false) then //Exchange Clerk
        begin
          A_Debug('Cannot Get to exchange screen');
          players[currentplayer].active := false;
          exit;
        end;
      Chooseoption('Exchange');
      marktime(time);
      while not (getcolor(244, 42) = 39116) or (getcolor(242, 96) = 39372) or
        (getcolor(217, 69) = 3424329) do
        begin
          wait(100);
          if timefrommark(time) > 5000 then exit;
        end;
      while not pinscreen or (getcolor(279, 69) = 39372) do wait(100 + random(200));
      if pinscreen then InPin(players[currentplayer].pin);
      result := true;
    end;


    function BuyOffer : boolean;
    begin
      if not players[currentplayer].Booleans[1] then exit;
      if not GEBuy(players[currentplayer].Strings[0], players[currentplayer].Strings[1], inttostr(players[currentplayer].Integers[0])) then
      begin
        A_Debug('Buy Offer Somehow messed up');
        exit;
      end;
      result := true;
      players[currentplayer].booleans[4] := true;
      GEMenuExit;
      inc(players[currentplayer].integers[3]);
      wait(1000 + random(5000));
    end;

    function SellOffer : boolean;
    begin
      if not players[currentplayer].Booleans[2] then exit;
      if not GESell(players[currentplayer].Strings[3], inttostr(players[currentplayer].Integers[1]), 2) then
      begin
        A_Debug('Sell Offer Somehow messed up');
        exit;
      end;
      result := true;
      players[currentplayer].booleans[5] := true;
      GEMenuExit;
      inc(players[currentplayer].integers[4]);
      wait(1000 + random(5000));
    end;

    procedure waitnow(CheckEvery: Integer);
    begin
      if loggedin then logout;
      wait(1000 * 60 * CheckEvery + random(10));
    end;

    var running, cycle, Mcycle : integer;

    procedure AwkSetUp(m, w : integer; s, l: boolean);
    begin
      if (w > 0) and s then Smart_Server := w;
      setupsrl;
      mousespeed := m + random(5);
      if l then
      if not loggedin then loginplayer;
    end;

    That's my current form. If I click Set Up Players, then Add Players, I receive an Invalid Pointer Error. I'm not sure how to fix it, or even what's wrong (not that good with forms).

    Any help? :/.

    ~Sand
    Last edited by Sandstorm; 10-17-2009 at 08:28 PM.

  2. #2
    Join Date
    Mar 2008
    Location
    The Netherlands
    Posts
    1,395
    Mentioned
    1 Post(s)
    Quoted
    1 Post(s)

    Default

    Pointers?!?! THIS! IS! SPARTAAAA!


  3. #3
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ... I'm serious dude, please don't spam my topic.

    ~Sand

  4. #4
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    i have no idea XD

    i probably fail at forms more
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  5. #5
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    So.... spam?

    I think so.

    ~Sand

  6. #6
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Does it give line number or anything?

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  7. #7
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    No, it's a pop up error (like the "not responding, end now" thing).

    ~Sand

  8. #8
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    An invalid pointer reference occurs when a pointer's value is referenced even though the pointer doesn't point to a valid block.
    Thats alot of code to look through lol.

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  9. #9
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Expecting someone else to debug that for you is ludicrous considering how unreadable having just one form in a script is. If you expect them to, then at least give sufficient help to enable them to.

    What does it output before crashing? Have you added in extra writeln's to see exactly where it crashes? Have you any possible ideas as to why it does or which procedure is possibly causing it? Basic debugging can at least narrow down the problem so that someone can help more easily.

    If you can determine the line and still can't see the problem then I'll be happy to help.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  10. #10
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by rogeruk View Post
    Thats alot of code to look through lol.
    Yes; but SCAR does not support using pointers in scripts, except for procedure pointers, so start looking there.

    However, since pointers aren't supported, I could just as well be a bug in SCAR. (Internally)



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  11. #11
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by mixster View Post
    Expecting someone else to debug that for you is ludicrous considering how unreadable having just one form in a script is. If you expect them to, then at least give sufficient help to enable them to.

    What does it output before crashing? Have you added in extra writeln's to see exactly where it crashes? Have you any possible ideas as to why it does or which procedure is possibly causing it? Basic debugging can at least narrow down the problem so that someone can help more easily.

    If you can determine the line and still can't see the problem then I'll be happy to help.
    I know that it's in the UpdatePlayers procedure. I'll throw in some writelns to see if I can get a smaller codeblock. You're right though, probably should've done that before :/.

    So I just got an Access violation error, directed me to this line:

    Label68[Playaz] := TLabel.Create(frmDesign2);

    Line 193, I believe.

    ~Sand
    Last edited by Sandstorm; 10-18-2009 at 12:15 AM.

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
  •