Results 1 to 5 of 5

Thread: Speed troubles, Canvas Error

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

    Default Speed troubles, Canvas Error

    During the work on my cow killer i get a weird error that says the canvas doesnt allow drawing. What does this mean? and how can i stop it.

    It occurs while my script wants to bank. It uses radial walking and clicks the first point but than errors up.

    Also how else could i make the script run faster, it kills the cow and uses a wait procedure for the cow to drop. But than it takes a bit to find the cow hide. Any advice?

    Also can anybody look through and tell me how to improve it.

    SCAR Code:
    program Skinner;
    {
          #####   ##    ##                                      ###
       ######  /#### #####                                       ###
      /#   /  /  ##### #####                        #             ##
     /    /  /   # ##  # ##                        ##             ##
         /  /    #     #                           ##             ##
        ## ##    #     #      /##  ###  /###     ######## /###    ##       /###
        ## ##    #     #     / ###  ###/ #### / ######## / ###  / ##      / #### /
        ## ##    #     #    /   ###  ##   ###/     ##   /   ###/  ##     ##  ###/
        ## ##    #     #   ##    ### ##    ##      ##  ##    ##   ##    ####
        ## ##    #     ##  ########  ##    ##      ##  ##    ##   ##      ###
        #  ##    #     ##  #######   ##    ##      ##  ##    ##   ##        ###
           /     #      ## ##        ##    ##      ##  ##    ##   ##          ###
       /##/      #      ## ####    / ##    ##      ##  ##    /#   ##     /###  ##
      /  #####           ## ######/  ###   ###     ##   ####/ ##  ### / / #### /
     / #   ##                #####    ###   ###     ##   ###   ##  ##/     ###/
     #  #
      ##    #######      /
          /       ###  #/         #
         /         ##  ##        ###
         ##        #   ##         #
          ###          ##
         ## ###        ##  /##  ###   ###  /###   ###  /###     /##  ###  /###
          ### ###      ## / ###  ###   ###/ #### / ###/ #### / / ###  ###/ #### /
            ### ###    ##/   /    ##    ##   ###/   ##   ###/ /   ###  ##   ###/
              ### /##  ##   /     ##    ##    ##    ##    ## ##    ### ##
                #/ /## ##  /      ##    ##    ##    ##    ## ########  ##
                 #/ ## ## ##      ##    ##    ##    ##    ## #######   ##
                  # /  ######     ##    ##    ##    ##    ## ##        ##
        /##        /   ##  ###    ##    ##    ##    ##    ## ####    / ##
       /  ########/    ##   ### / ### / ###   ###   ###   ### ######/  ###
      / #    #####       ##   ##/   ##/   ###   ###   ###   ### #####    ###
      #  #
      #  #
       ##                                 Verison 0.2

    Thanks for downloading Me_ntal's skinner, Please email me your progress reports
    [email]thyess@gmail.com[/email] or post them on the thread. Update planned to improve the walking
    and slaughtering of cows.

    Special Thanks to
                Pentti,
                JAD,
                WT-fawki
                Wizzup
                Nielsie95
                Boreas
                ~Alex~
    and anyone at the SRL forums.

    To run:
    1. Either start in the bank or the cow field.
    2. Make sure your player is weilding a weapon. (hand combat coming)
    3. Focus and press play.
    4. Post your progress reports and tell me how to improve

                                    ~Mental~
    }


    {.include SRL/SRL.scar}
    {.include SRL/SRL/Skill/Fighting.scar}

    var {counters}
      toll, logd, bankd, xet, KillingAttempts, killd, CArray, hidecolor,  MissedColor, HitColor: integer;
    var {Colors}
      CowColor: array[1..4] of integer;
    var
      HideDTM, HideBMP : integer;

    const cowpatience  = 40000;

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

      Players[0].Name := '';
      Players[0].Pass := '';
      Players[0].Nick := ''; {3-4 letters of your name}
      Players[0].Skill := 'strength'; {Fight Mode, attack, deffence, strength and even}
      Players[0].Active := True; {Use player?}
      Players[0].integer2 := 10; {how many cows?}
    end;

    {======================================================================
                                 Colors
    =======================================================================}


    procedure CowColors;
    begin
      MissedColor := 16728128;
      HitColor := 192;
      CowColor[1] := 12238787;
      CowColor[2] := 2307389;
      CowColor[3] := 9812173;
      CowColor[4] := 2765117;
      hidecolor := 11185588;
      HideDTM := DTMFromString('78DA6314656060286740013BD7AF67F80FA41' +
           '981F83F103082D46432A001462412488B018916026AD831EDC250' +
           'A30024AA09A89105123904D47001893AFC6A0049030AF5');
      HideBMP := BitmapFromString(7, 4, 'C4BBBAD8D3D2BCB3B3B9AEADCEC' +
           '7C6B1A5A5B6ABAAC2B9B9C5BCBCD4CECEC7BFBFAB9F9FB9AEADB9' +
           'AEADC2B9B9C1B8B7D8D3D2A19696BBB1B1BAB0B0B9AEADC5BCBCC' +
           '5BCBCB3A8A7CBC4C4A89C9CBBB1B1BBB1B1');
           
    end;

    {======================================================================
                                 Randoms                                 //
                                 WT-Fawki
    =======================================================================}

    function FindFastRandoms: Boolean; {By Wt-Fakawi}
    var
      i: Integer;
    begin
      for i := 1 to 8 do
      begin
        case I of
          1: if FindDead then
              Result := True;
          2: if FindMod then
              Result := True;
          3: if FindMime then
              Result := True;
          4: if FindMaze then
              Result := True;
          5: if FindQuiz then
              Result := True;
          6: if FindDemon then
              Result := True;
          7: begin
              if NoGameTab then
              begin
                Result := True;
                Players[CurrentPlayer].loc := 'No GameTab';
                Logout;
                Exit;
              end;
            end;
          7: begin
              if InBlack then
              begin
                Result := True;
                Players[CurrentPlayer].loc := 'InBlack';
                Logout;
                Exit;
              end;
            end;
          8: RC;
        end;
        wait(1);
      end;
    end;

    procedure RunRandoms;
    begin
      FindFastRandoms;
      FindNormalRandoms;
    end;


    {======================================================================
                                 Anti-Ban                                //
    =======================================================================}


    procedure WereHuman;
    begin
      if not (LoggedIn) then Exit;
        begin
         case Random(60) of
          0: HoverSkill('attack', false);
          5: AlmostLogout;
          10:begin
              GameTab(1 + Random(12));
              Wait(1500 + Random(500));
              GameTab(4);
              end;
          15: HoverSkill('random', false);
          20: begin
             case random(10) of
               0: TypeSend('Attack lvls?');
               3: TypeSend('Strength levels');
               5: TypeSend('defence lvls');
               7: TypeSend('prayer levels');
               9: TypeSend('hp?');
             end;
           end;
          25: begin
              GameTab(Random(5));
              Wait(1500 + Random(500));
              GameTab(4);
             end;
          30: begin
              GameTab(1);
              Wait(1500 + Random(500));
              GameTab(4);
            end;
        end;
      end
    end;

    {======================================================================
                           Checks If were infight                        //
                                  Wt-Fawki
    =======================================================================}


    Function InFightAt(x, y: Integer):Boolean;
    var
      dx, dy: Integer;
    begin
     if  (FindColor(dx, dy, GreenStatusColor, x - 20, y - 10, x + 20, y + 10)) or
         (FindColor(dx, dy, RedStatusColor, x - 20, y - 10, x + 20, y + 10)) or
         (FindColor(dx, dy, MissedColor, x - 20, y - 10, x + 20, y + 10)) or
         (FindColor(dx, dy, HitColor, x - 20, y - 10, x + 20, y + 10)) then
          Result:=True;
    end;

    {======================================================================
                               Get Combat Level                           //
    =======================================================================}


    function getcombatlevelb: integer;
    var
      Curtab, i: integer;
      Cmblvl: string;
    begin
      CurTab := getcurrenttab;
      gametab(1);
      Cmblvl := GetTextAtEx(671, 230, 100, StatChars, False, True, 0, 5, -1, 2, True, tr_Digits);
      if (Trim(Cmblvl) = '') then
        for i := 1 to 5 do
        begin
          Cmblvl := GetTextAtEx(671 + i, 230, 100, StatChars, False, True, 0, 5, -1, 2, True, tr_Digits);
          if (Trim(Cmblvl) <> '') then Exit;
        end;
      if (not (Trim(Cmblvl) = '')) then
        result := StrToInt(Trim(Cmblvl));
      wait(500 + random(200));
      gametab(Curtab);
    end;

    {======================================================================
                                   Player Report                         //
    =======================================================================}


    procedure PlayerReport;
    var i: integer;
    begin
      for I := 0 to HowManyPlayers - 1 do
      begin
        WriteLn(Players[i].Name + ' = ' + booltostr(Players[i].Active));
        WriteLn('Att ' + inttostr(Players[i].level[1]) + ', Str ' + inttostr(Players[i].level[2]) + ', Def ' + inttostr(Players[i].level[3]));
        WriteLn('Cmb ' + inttostr(Players[i].integer1) + ', Hps ' + inttostr(Players[i].level[8]) + ', Pry ' + inttostr(Players[i].level[5]));
        WriteLn('Worked For: ' + IntToStr(Players[i].Worked) + ' min, Killed : ' + IntToStr(Players[i].Killed) + ', Loc: ' + Players[i].loc);
        WriteLn('Banked: ' + IntToStr(Players[i].Banked) + ' loads');
        WriteLn('');
        Writeln('================================================================');
      end
    end;

    {======================================================================
                                   Progress Report                       //
    =======================================================================}


    procedure ProgressReport;
    begin
      writeln('');
      WriteLn('================================================================');
      WriteLn('|                        Me_ntals Skinner                       |');
      Writeln('================================================================');
      Writeln('  Worked For ' + TimeRunning);
      Writeln('  Logged In ' + InttoStr(logd));
      Writeln('  Banked ' + InttoStr(bankd));
      writeln('  Kills  ' + InttoStr(killd));
      Writeln('================================================================');
    end;

    {======================================================================
                                   Introduction                          //
    =======================================================================}


    procedure Introd;
    begin
     repeat
      wait(250);
      cleardebug;
      xet:= xet -1;
      writeln('               Me_ntals Skinner');
      writeln('');
      writeln('             Loading please wait');
      writeln('                      '+inttostr(xet));
     until(xet = 0)
     cleardebug;
     if (xet = 0) then
     writeln('                    Here We ago');
     writeln('                 ~Mentals Skinner~');
    end;

    {======================================================================
                                Even Combat                              //
                        Idea Stolen From GS by Wt-Fawki
    =======================================================================}

    procedure evenlevels;
    begin
     GetAllLevels;
     if (Players[CurrentPlayer].level[1] < Players[CurrentPlayer].level[2]) and
        (Players[CurrentPlayer].level[1] < Players[CurrentPlayer].level[3]) then
        begin
        SetFightMode(1);
        exit;
        end;
     if (Players[CurrentPlayer].level[2] < Players[CurrentPlayer].level[1]) and
        (Players[CurrentPlayer].level[2] < Players[CurrentPlayer].level[3]) then
        begin
        SetFightMode(2);
        exit;
        end;
     if (Players[CurrentPlayer].level[3] < Players[CurrentPlayer].level[1]) and
        (Players[CurrentPlayer].level[3] < Players[CurrentPlayer].level[2]) then
        begin
        SetFightMode(3);
        exit;
        end;
    end;

    {======================================================================
                                   Set Combat                            //
    =======================================================================}


    procedure Combattype;
    begin
      if Lowercase(Players[CurrentPlayer].Skill) = 'attack' then SetFightMode(1);
      if Lowercase(Players[CurrentPlayer].Skill) = 'strength' then SetFightMode(2);
      if Lowercase(Players[CurrentPlayer].Skill) = 'defence' then SetFightMode(4);
      if Lowercase(Players[CurrentPlayer].Skill) = 'auto' then evenlevels;
      if Lowercase(Players[CurrentPlayer].Skill) = 'even' then evenlevels;
      gametab(4);
    end;

    {======================================================================
                          Waits While Attacking Cows
                           Modified Verison from Gs
    =======================================================================}


    Procedure patience;
    var cowwait : integer;
    begin
     marktime(cowwait);
     repeat
      Wait(250 + Random(250));
      if (TimeFromMark(cowwait) > ((cowpatience/2)+random((cowpatience/2))))then exit;
     until (not(InFight));
    end;

    {======================================================================
                                 Attack Cows                             //
    =======================================================================}


    function SlaughterCow: Boolean;
    var  CBx, CBy: Integer;
    Begin
    For CArray:=1 to 4 do
    Begin
        if (FindColorSpiralTolerance(CBx, CBy, CowColor[CArray], MSX1, MSY1, MSX2, MSY2, 15)) then
          Begin
            MMouse(CBx, CBy, 0, 0);
            if (IsUpText('Cow')) then
              Begin
                KillingAttempts := KillingAttempts + 1
                Mouse(CBx, CBy, 0, 0, True);
                Flag;
                wait(5000+random(4000));
                if (InChatMulti('alr', 'und ',' att')) then
                  Begin
                    Result:=True;
                    Exit;
                  end;
                if (InChatMulti('ome', 'one ',' ing')) then
                  Begin
                    Result:=False;
                          Exit;
                  end;
                end;
            end;
        if (KillingAttempts = 50) then
          begin
            WriteLn('Too Busy World');
            TerminateScript;
          end;
        end;
    end;

    {======================================================================
                              Walks to Field                             //
    =======================================================================}


    procedure ToField;
    var i : integer;
    begin
      i := 0
      RadialRoadWalk(findfallyRoadColor, 270, 180, 50, 1, 1);
      flag;
      i := i +1
      RadialRoadWalk(findfallyRoadColor, 200, 170, 65, 1, 1);
      flag;
      i := i +1
      RadialRoadWalk(RoadColor, 200, 170, 65, 1, 1);
      flag;
      i := i +1
      RadialWalk(96513, 300, 0, 110, 1,1);  //yew tree
      flag;
       i := i +1
      if (RadialWalkEx(x, y, MMCX, MMCY, 234, 10, 115, 90, 60)) then Mouse(x, y, 5, 5, true);
      flag;
      if i = 5 then exit;
      i := i +1
      if i = 5 then exit;
    end;

    {======================================================================
                                Walks To bank                            //
    =======================================================================}


    procedure WalkBank;
    var i : integer;
    begin
      i := 0
      if (RadialWalkEx(x, y, MMCX, MMCY, 234, 280, 430, 70, 60)) then Mouse(x, y, 5, 5, true);
      flag;
      i := i +1
      RadialWalk(96513, 300, 150, 300, 1,1);  //yew tree
      flag;
      i := i +1
      RadialWalk(6579307, 300, 270, 55, 1,1);  //road
      flag;
      i := i +1
      RadialRoadWalk(findfallyRoadColor, 375, 350, 60, 1, 1);  //fally
      flag;
      i := i +1
      RadialRoadWalk(findfallyRoadColor, 355, 380, 60, 1, 1);
      flag;
      i := i +1
      RadialWalk(9547703 , 20, 70, 45, 1, 1);  //fallybank
      flag;
      if i = 6 then exit;
      i := i +1
      if i = 6 then exit;
    end;

    {======================================================================
                                Collects Hide
    =======================================================================}


    procedure CollectHide;
    var hidebmp:integer;
    var acc:extended;
    begin
    hidebmp := BitmapFromString(6, 5, 'z78DA7331747674767419522400C' +
           '8192CA7');

     FindDeformedBitmapToleranceIn( hidebmp, x, y, MSX1, MSY1, MSX2, MSY2, 20, 1, True, acc)
      if acc >= 0.9 then
       begin
        MMouse(x,y,0,0);
        wait(100+Random(100));
        mouse(x, y, 0, 0, false);
        ChooseOption(x, y, 'ide');
        freebitmap(hidebmp)
       end;
    end;

    {======================================================================
                                Banks Hide                              //
    =======================================================================}


    procedure BankHides;
    var bx, by: integer;
    begin
      if (FindDTM(HideDTM, bx, by, 552, 203, 742, 469)) then
      begin
        Mouse(x, y, 1, 1, false);
        Wait(100 + Random(100));
        ChooseOption(x, y, 'All');
        bankd := bankd + 1;
        CloseBank;
        DropAll;
      end;
    end;

    {======================================================================
                           Finds and Opens the Bank                    //
                  Modified verison of openbankglass by wizzup?
    =======================================================================}


    procedure OpenAccount;
    var BB :TPoint;
    begin
     if (FindColorTolerance(BB.x, BB.y, 10594993, MSX1, MSY1, MSX2, MSY2, 4)) then
      begin
        MMouse(BB.x, BB.y, 4, 4);
        if (IsUpTextMulti('ank', 'booth', 'ooth')) then
        begin
          Mouse(BB.x, BB.y, 0, 0, False);
          Wait(100);
          ChooseOption(BB.x, BB.y, 'uickly');
          FFlag(0);
          Wait(2000 + Random(500));
          BankHides;
        end;
      end
      else
      begin
        if (FindObj(BB.x, BB.y, 'ank', 10594993, 14)) then
        begin
          Mouse(BB.x, BB.y, 0, 0, False);
          Wait(50);
          ChooseOption(BB.x, BB.y, 'uickly');
          FFlag(0);
          Wait(2000 + Random(500));
          BankHides;
        end;
      end;
    end;



    {======================================================================
                             Determines Where we are                    //
    =======================================================================}


    function WereAtBank: Boolean;
    begin
      if FindSymbol(x, y, 'bank') then
      begin
        mouse(x, y, 0, 0, true);
        flag;
        Players[currentplayer].loc := 'bank';
        result := true
        WriteLn('Were at Bank')
      end;
    end;

    {======================================================================
                                   Setup's
    =======================================================================}


    procedure SetupScript;
    begin
      DeclarePlayers;
      CowColors;
      ClearDebug;
      ClearReport;
      MouseSpeed     := 25;
      KillingAttempts := 0;
      toll := 0;
      bankd := 0;
      killd := 0;
      logd := 0;
      Introd;
      wait(1000);
      ActivateClient;
      loginplayer;
    end;

    procedure SetupPlayer;
    begin
      logd := logd + 1;
      HighestAngle;
      CombatType;
      SetChat('on', 1);
      SetChat('friends', 2);
      SetChat('off', 3);
      MakeCompass('N');
    end;

    {======================================================================
                                   Main Loop
    =======================================================================}


    begin
      SetupSRL;
      xet:=10;
      SetupScript;
      repeat
        if (not (LoggedIn)) then loginplayer;
        SetupPlayer
          repeat
          if (WereAtBank) then Tofield else
          begin
            repeat
                if(SlaughterCow) then KillingAttempts := 0;
                   Patience;
                   CollectHide;
                   werehuman;
                   RunRandoms;
            until ((InvFull))
          end;
          WalkBank;
          RunRandoms;
          OpenAccount;
          RunRandoms;
          ToField;
          ProgressReport;
          PlayerReport;
          Combattype;
          SetRun(True);
        until (toll >= Players[CurrentPlayer].integer2)
          if (toll >= Players[CurrentPlayer].integer2) then
        begin
          GetAllLevels;
          Players[currentplayer].integer1 := getcombatlevelb;
          ProgressReport;
          PlayerReport;
          SRLRandomsReport;
          LogOut;
          NextPlayer(True);
          toll := 0;
          SetupPlayer;
        end;
      until False;
    end.

  2. #2
    Join Date
    Apr 2007
    Posts
    220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I can't see your problem about that canvas thing because the script compiles succesfully... And making a DTM of Cowhide is a good idea. Or maybe FindOBj(a color with tolerance and the name of the object).

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

    Default

    no i had the same error....try using a different version of SCAR
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


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

    Default

    actually the cowhide is found using a deformed bitmap, and it banks the cowhide by using a DTM. I feel that i have used most of the SRL functions and the next update that will enable mage support has a few of my own developed functions.

    I just want to get it working 100% before i start adding more features.

  5. #5
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    That canvas error pops up when you're trying to do something off-screen.

    Make sure that all your searches are taking place inside the client window. Mistakes in loops are usually the culprit.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 05-28-2008, 07:01 PM
  2. [Runtime Error]:Canvas does not allow drawing
    By sp00nfu11 in forum OSR Help
    Replies: 3
    Last Post: 03-22-2008, 12:52 PM
  3. Replies: 9
    Last Post: 02-05-2008, 01:36 PM
  4. Replies: 4
    Last Post: 02-02-2008, 10:04 AM
  5. Runtime Canvas error..
    By itSchRis917 in forum OSR Help
    Replies: 12
    Last Post: 09-22-2007, 04:58 PM

Posting Permissions

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