Results 1 to 3 of 3

Thread: Acces violation error :S

  1. #1
    Join Date
    Jan 2009
    Location
    Belgium
    Posts
    175
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default Acces violation error :S

    i have added bitmaps to my script and now i get an acces violation error:

    [Runtime Error] : Exception: Access violation at address 006B3445 in module 'scar.exe'

    any help??

    Code:
    program MapleSnijder;
    {.include SRL/SRL.scar}
    
    var
     Maple, Knife: Integer;
    
    function LoadBitmaps: Boolean;
    begin
       Maple := BitmapFromString(5, 4, 'beNqz5o205g235Aky4wkw5fY24' +
           'oaQngZcLrpcTtqc7npcQDZQxM8YJAVEQJWhFjxALZEAUIYLFg==');
    
      Knife := BitmapFromString(6, 5, 'beNpjYHK2NvRwMGFgYMpISUlJS' +
          'IiLioRz05KSEmJiIkND4SJJcXHREeHT+vshIlP6ertbW5tqaoBsIH' +
           'LX44IjBgA+dxdO');
    end;
    
    function GetMapleFromBank: Boolean;
    var
     x, y: Integer;
    begin
     if FindBitmapToleranceIn(Maple, x, y, MSX1, MSY1, MSX2, MSY2, 5) then
     begin
      Writeln('Found Maple in bank!');
      MMouse(x, y, 2, 2);
      Wait(80 + Random(100));
      Mouse(x, y, 0, 0, False);
      Wait(500 + Random(100));
      ChooseOption('Withdraw-30');
      CloseWindow;
      Wait(200 + Random(100));
      if FindBitmapToleranceIn(Maple, x, y, MIX1, MIY1, MIX2, MIY2, 5) then
      Writeln('Found Maple in inventory, moving on!')
     else
     begin
      Writeln('Could not find maple in inventory, logging out.');
      Logout;
     end;
     end;
     Result := True;
     FreeBitmap(Maple);
    end;
    
    function CutMaple: Boolean;
    var
     x, y: Integer;
    begin
      if FindBitmapToleranceIn(Knife, x, y, MIX1, MIY1, MSX2, MIY2, 5) then
      begin
       Writeln('Found Knife in inventory!');
       Mouse(x, y, 1, 1, True);
       if FindBitmapToleranceIn(Maple, x, y, MIX1, MIY1, MIX2, MIY2, 5) then
       begin
        Mouse(x, y, 1, 1, True);
        MouseBox(MCX1, MCY1, MCX2, MCY2, 2);
        ChooseOption('Make X');
        Wait(100 + Random(200));
        TypeSend('27');
        Wait(50000);
       end else
        Writeln('Could not find Knife in inventory, logging out.');
      end;
     Result := True;
     FreeBitmap(Maple);
     FreeBitmap(Knife);
    end;
    
    procedure MainLoop;
    begin
     SetupSRL;
     ActivateClient;
     ClearDebug;
     if GetMapleFromBank then
      Writeln('We have clicked the Maple logs!')
     else
     begin
      Writeln('We have not clicked the Maple logs.');
     end;
     if CutMaple then
      Writeln('We have cutted Maple longbows!')
     else
     begin
      Writeln('We did not have cutted Maple longbows.');
     end;
    end;
    
    begin
     MainLoop;
    end.

  2. #2
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It's your main loop procedure just by looking at it. All them elses should go where they're needed. Clicked should go in GetMapleFromBank and Cut(there is no need for cutted since it's both plural and singular) should go in cut maple.

    Like this,

    SCAR Code:
    function CutMaple: Boolean;
    var
     x, y: Integer;
    begin
      if FindBitmapToleranceIn(Knife, x, y, MIX1, MIY1, MSX2, MIY2, 5) then
      begin
       Writeln('Found Knife in inventory!');
       Mouse(x, y, 1, 1, True);
       if FindBitmapToleranceIn(Maple, x, y, MIX1, MIY1, MIX2, MIY2, 5) then
       begin
        Mouse(x, y, 1, 1, True);
        MouseBox(MCX1, MCY1, MCX2, MCY2, 2);
        ChooseOption('Make X');
        Wait(100 + Random(200));
        TypeSend('27');
        Wait(50000);
        Writeln('We have cut Maple longbows!')
       end else
        Writeln('Could not find Knife in inventory, logging out.');
        Writeln('We did not cut Maple longbows.');
      Result := True;
     FreeBitmap(Maple);
     FreeBitmap(Knife);
    end;

    But you call no procedure in your main loop.
    It should be like
    SCAR Code:
    procedure MainLoop;
    begin
     SetupSRL;
     ActivateClient;
     ClearDebug;
     repeat
     CutMaple;
     GetMapleFromBank;
     until(//whatever);
    end.

    I suggest you read a few more tutorials.

  3. #3
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    You have to load your Bitmaps in the you main loop. The way you have it now results in an access violation because you're trying to search for a bitmap without telling SCAR what to search for.

    In your main loop, just add
    SCAR Code:
    LoadBitmaps;
    after you clear the debug box, and that should fix your problems.

    Cheers,

    Coh3n

    EDIT: @ Junkj - He does call his procedures in his main loop. The if..then..else statements in the main loop just fine.
    Last edited by Coh3n; 11-11-2009 at 08:49 PM.

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
  •