Results 1 to 7 of 7

Thread: out of range error..

  1. #1
    Join Date
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default out of range error..

    out of range error..

    after running my script..i get an runtime error, here's my script so far

    SCAR Code:
    program FallyCowCruncher;
    {.include srl/srl.scar}
    {.include srl/srl/skill/fighting.scar}

    var
    x,y,a: integer;

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

      Players[0].Name := '';
      Players[0].Pass := '';
      Players[0].Nick := '';
      Players[0].Integers[1] :=0; //desired attack
      Players[0].Integers[2] :=50; //desired strength
      Players[0].Integers[3] :=0; //desired defense
      Players[1].Integers[4] :=1;
      Players[0].Active := true;

      Players[1].Name := '';
      Players[1].Pass := '';
      Players[1].Nick := '';
      Players[1].Integers[1] :=0; //desired attack
      Players[1].Integers[2] :=0; //desired strength
      Players[1].Integers[3] :=0; //desired defense
      Players[1].Integers[4] :=1;
      Players[1].Active := False;

     
      Players[2].Name := '';
      Players[2].Pass := '';
      Players[2].Nick := '';
      Players[2].Integers[1] :=0; //desired attack
      Players[2].Integers[2] :=0; //desired strength
      Players[2].Integers[3] :=0; //desired defense
      Players[2].Integers[4] :=1;
      Players[2].Active := False;

      Players[3].Name := '';
      Players[3].Pass := '';
      Players[3].Nick := '';
      Players[3].Integers[1] :=0; //desired attack
      Players[3].Integers[2] :=0; //desired strength
      Players[3].Integers[3] :=0; //desired defense
      Players[3].Integers[4] :=1;
      Players[3].Active := False;
    end;

    function AttackMode:boolean;
    var
      i,att,str,def:integer;
    begin
      if not(loggedIn) then exit;
      result:=true;
      if (timefrommark(a)>30000)or(players[currentplayer].skill='') then
      begin
        Mouse(575,183,10,10,true);
        wait(200);
        att:=getskillinfo('attack',false);
        str:=getskillinfo('strength',false);
        def:=getskillinfo('defence',false);
        writeln(inttostr(att)+' attack');
        writeln(inttostr(str)+' strength');
        writeln(inttostr(def)+' defence');
        marktime(a);
        if (lowercasE(players[currentplayer].skill)='attack') then
          if (att<players[currentplayer].integers[1]) then exit else players[currentplayer].skill:='';
        if (lowercasE(players[currentplayer].skill)='strength') then
          if (str<players[currentplayer].integers[2]) then exit else players[currentplayer].skill:='';
        if (lowercasE(players[currentplayer].skill)='defence') then
          if (def<players[currentplayer].integers[3]) then exit else players[currentplayer].skill:='';
        for i:=0 to 0 do
        begin
          if (players[currentplayer].skill='') then
          begin
            if (att<players[currentplayer].integers[1]) then
              if not(players[currentplayer].integers[1]=99) then
              begin
                players[currentplayer].skill:='attack';
                break;
              end;
            if (str<players[currentplayer].integers[2]) then
              if not(players[currentplayer].integers[2]=99) then
              begin
                players[currentplayer].skill:='strength';
                break;
              end;
            if (def<players[currentplayer].integers[3]) then
              if not(players[currentplayer].integers[3]=99) then
              begin
                players[currentplayer].skill:='defence';
                break;
              end;
            if (players[currentplayer].integers[1]=99) then players[currentplayer].skill:='attack';
            if (players[currentplayer].integers[2]=99) then players[currentplayer].skill:='strength';
            if (players[currentplayer].integers[3]=99) then players[currentplayer].skill:='defence';
          end;
        end;
        Mouse(542,183,10,10,true);
        case lowercase(players[currentplayer].skill) of
          'attack': setfightmode(1);
          'strength': setfightmode(2);
          'defence','defense': setfightmode(4);
          else result:=false;
        end;
      end;
    end;

    procedure SetRetaliate(ret:boolean);
    var
     i:integer;
    begin
      if not(loggedIn) then exit;
      gametab(1);
      for i:=1 to 5 do
      begin
        case getColor(600,390) of
          4540745: if ret=true then mouse(600+random(100),370+random(20),0,0,true) else exit;
          1711220: if ret=false then mouse(600+random(100),370+random(20),0,0,true) else exit;
        end;
        wait(200);
      end;
    end;

    Procedure FightSetup;
    begin
      If not(loggedin) then Exit;
      MakeCompass('s');
      SetRun(true);
      AttackMode;
      SetAngle(True);
      SetRetaliate(true);
      Mouse(643,183,10,10,true);
    end;

    procedure LogIn;
    begin
      if not(loggedin) then LoginPlayer;
      Wait(500);
      FindNormalRandoms;
      MakeCompass('n');
      Mouse(672,482,5,5,true);
      SetRun(false);
      SetBar('Brightness',4);
    end;

      //taken off men_tal's cow killing script
    procedure CollectHide;

    var
      j: integer;
      Hide:Array [0..1] of integer;

    begin
      Hide[0] := 10790320;
      Hide[1] := 11382199;
     
      for j := 0 to 1 do
      begin
        if FindColorSpiralTolerance(x,y,Hide[j],MSX1,MSY1,MSX2,MSY2,10) then
        begin
          Mouse(x, y, 3, 3, false);
          ChooseOption('ide');
          Flag;
          FindNormalRandoms;
        end;
      end
    end;

    function RandClick(item , option:string): boolean;
    begin
      if IsUpText(item) then
      begin
        case Random(4) of
          0,1,2: Mouse(x,y,10,10,true);
          3: begin
               Mouse(x,y,10,10,false);
               ChooseOption(option);
             end;
        end;
        Result := true;
      end;
    end;


    procedure KillDaCow;
    var
      CowsKilled,o: Integer;
      madtype: array [1..7] of string;
      CowColor: array [0..4] of Integer;
    begin
      CowsKilled := 0;
      Writeln('now to own some cows');
      CowColor[0] := 12238787;
      CowColor[1] := 3755348;;
      CowColor[2] := 2765117;
      CowColor[3] := 5002080;
      CowColor[4] := 6911365;
     
      MadType[1] :='darn..';
      MadType[2] :='grr got it before me';
      MadType[3] :='lol';
      MadType[4] :='keep getting beaten to them';
      MadType[5] :='grrr..';
      MadType[6] :='darn, peaople keep getting it over me';
      MadType[7] :='darn i''m a noob';
     
      FightSetup;
      repeat
      for o := 0 to 3 do
      begin
        FindNormalRandoms;
        if FindColorTolerance(x,y,Cowcolor[o],0,0,518,339,4) then
        begin
          MMouse(x,y,10,10);
          Wait(100);
          if IsUpText('ow')=true then
          begin
            RandClick('ow','ttack');
            Flag;
            Wait(750+random(1000));
            if FindBlackChatMessage('omeone') then
            Typesend(madtype[1+random(6)]);
            begin
              KillDaCow;
            end;
            wait(2000);
            if infight = true then
            begin
              repeat
                Wait(500);
              until Infight = false;
            CowsKilled := CowsKilled + 1;
            wait(1000);
            Collecthide;
            end;
          end;
        Wait(500);
        end;
      end;
      until(InvFull);
    end;


    procedure ToPen;
    var
    z,TheRoadColor:integer;
    begin
      login;
      Z:=0
      Makecompass('n');
      TheRoadColor := findfallyroadColor;
      Wait(500);
      if radialwalk(TheRoadColor,180,270,40,1,1) then
      begin
        wait(500);
        end else Exit;
          repeat
            radialroadwalk(TheRoadColor,165,200,50,1,1);
            Writeln('lalala');
            wait(200);
          until(findsymbolin(x,y,'tree',628,8,704,165));
        mouse(x + 10,y,10,5,true);
        flag;
        if findcolortolerance(x,y,235,628,8,705,117,20) then
        begin
          mouse(x,y + 5,5,5,true);
          flag;
          wait(500);
        end;
        if findcolorSpiraltolerance(x,y,5467001,0,0,516,338,10) then
        begin
          randclick('ate','pen');
          Z:= Z + 1;
        end else exit;
    end;

    procedure ToBank;
    var
      LoadsDone: Integer;
    begin
      LoadsDone := 0;
      LoadsDone := LoadsDone + 1;
      if players[currentplayer].integers[4] <= LoadsDone then
      begin
      Logout;
      NextPlayer(true);
      end
    end;

    begin
      SetupSRL;
      ActivateClient;
      DeclarePlayers;
      repeat
      ToPen;
      KillDaCow;
      ToBank;
      until(false);
    end.

    after running for a few minutes, i get..[Runtime Error] : Out Of Range in line 214 in script C:\Users\~`Kevin`~\Documents\scripts\FallyCowCrunc her.scar

    help is much appreciated, if you want to test it, start the player out at fally east bank...also, if you know a way to get rid of the autorespond without it restarting the procedure over again, and keeping the fact it needs to restart if it finds a new someone is already fighting it thing...

    also, any other feedback is awesome
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

  2. #2
    Join Date
    Sep 2007
    Location
    Pennsylvania
    Posts
    3,396
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Code:
    Players[0].Name := '';
      Players[0].Pass := '';
      Players[0].Nick := '';
      Players[0].Integers[1] :=0; //desired attack
      Players[0].Integers[2] :=50; //desired strength
      Players[0].Integers[3] :=0; //desired defense
     Players[1].Integers[4] :=1;
      Players[0].Active := true;


    That might be all, I'll look through the rest of it and see if I can find anything...

  3. #3
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    program FallyCowCruncher;
    {.include srl/srl.scar}
    {.include srl/srl/skill/fighting.scar}

    var
    x,y,a: integer;

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

      Players[0].Name := '';
      Players[0].Pass := '';
      Players[0].Nick := '';
      Players[0].Integers[1] :=0; //desired attack
      Players[0].Integers[2] :=50; //desired strength
      Players[0].Integers[3] :=0; //desired defense
      Players[0].Integers[4] :=1;
      Players[0].Active := true;

      Players[1].Name := '';
      Players[1].Pass := '';
      Players[1].Nick := '';
      Players[1].Integers[1] :=0; //desired attack
      Players[1].Integers[2] :=0; //desired strength
      Players[1].Integers[3] :=0; //desired defense
      Players[1].Integers[4] :=1;
      Players[1].Active := False;


      Players[2].Name := '';
      Players[2].Pass := '';
      Players[2].Nick := '';
      Players[2].Integers[1] :=0; //desired attack
      Players[2].Integers[2] :=0; //desired strength
      Players[2].Integers[3] :=0; //desired defense
      Players[2].Integers[4] :=1;
      Players[2].Active := False;

      Players[3].Name := '';
      Players[3].Pass := '';
      Players[3].Nick := '';
      Players[3].Integers[1] :=0; //desired attack
      Players[3].Integers[2] :=0; //desired strength
      Players[3].Integers[3] :=0; //desired defense
      Players[3].Integers[4] :=1;
      Players[3].Active := False;
    end;

    function AttackMode:boolean;
    var
      i,att,str,def:integer;
    begin
      if not(loggedIn) then exit;
      result:=true;
      if (timefrommark(a)>30000)or(players[currentplayer].skill='') then
      begin
        Mouse(575,183,10,10,true);
        wait(200);
        att:=getskillinfo('attack',false);
        str:=getskillinfo('strength',false);
        def:=getskillinfo('defence',false);
        writeln(inttostr(att)+' attack');
        writeln(inttostr(str)+' strength');
        writeln(inttostr(def)+' defence');
        marktime(a);
        if (lowercasE(players[currentplayer].skill)='attack') then
          if (att<players[currentplayer].integers[1]) then exit else players[currentplayer].skill:='';
        if (lowercasE(players[currentplayer].skill)='strength') then
          if (str<players[currentplayer].integers[2]) then exit else players[currentplayer].skill:='';
        if (lowercasE(players[currentplayer].skill)='defence') then
          if (def<players[currentplayer].integers[3]) then exit else players[currentplayer].skill:='';
        for i:=0 to 0 do
        begin
          if (players[currentplayer].skill='') then
          begin
            if (att<players[currentplayer].integers[1]) then
              if not(players[currentplayer].integers[1]=99) then
              begin
                players[currentplayer].skill:='attack';
                break;
              end;
            if (str<players[currentplayer].integers[2]) then
              if not(players[currentplayer].integers[2]=99) then
              begin
                players[currentplayer].skill:='strength';
                break;
              end;
            if (def<players[currentplayer].integers[3]) then
              if not(players[currentplayer].integers[3]=99) then
              begin
                players[currentplayer].skill:='defence';
                break;
              end;
            if (players[currentplayer].integers[1]=99) then players[currentplayer].skill:='attack';
            if (players[currentplayer].integers[2]=99) then players[currentplayer].skill:='strength';
            if (players[currentplayer].integers[3]=99) then players[currentplayer].skill:='defence';
          end;
        end;
        Mouse(542,183,10,10,true);
        case lowercase(players[currentplayer].skill) of
          'attack': setfightmode(1);
          'strength': setfightmode(2);
          'defence','defense': setfightmode(4);
          else result:=false;
        end;
      end;
    end;

    procedure SetRetaliate(ret:boolean);
    var
     i:integer;
    begin
      if not(loggedIn) then exit;
      gametab(1);
      for i:=1 to 5 do
      begin
        case getColor(600,390) of
          4540745: if ret=true then mouse(600+random(100),370+random(20),0,0,true) else exit;
          1711220: if ret=false then mouse(600+random(100),370+random(20),0,0,true) else exit;
        end;
        wait(200);
      end;
    end;

    Procedure FightSetup;
    begin
      If not(loggedin) then Exit;
      MakeCompass('s');
      SetRun(true);
      AttackMode;
      SetAngle(True);
      SetRetaliate(true);
      Mouse(643,183,10,10,true);
    end;

    procedure LogIn;
    begin
      if not(loggedin) then LoginPlayer;
      Wait(500);
      FindNormalRandoms;
      MakeCompass('n');
      Mouse(672,482,5,5,true);
      SetRun(false);
      SetBar('Brightness',4);
    end;

      //taken off men_tal's cow killing script
    procedure CollectHide;

    var
      j: integer;
      Hide:Array [0..1] of integer;

    begin
      Hide[0] := 10790320;
      Hide[1] := 11382199;

      for j := 0 to 1 do
      begin
        if FindColorSpiralTolerance(x,y,Hide[j],MSX1,MSY1,MSX2,MSY2,10) then
        begin
          Mouse(x, y, 3, 3, false);
          ChooseOption('ide');
          Flag;
          FindNormalRandoms;
        end;
      end
    end;

    function RandClick(item , option:string): boolean;
    begin
      if IsUpText(item) then
      begin
        case Random(4) of
          0,1,2: Mouse(x,y,10,10,true);
          3: begin
               Mouse(x,y,10,10,false);
               ChooseOption(option);
             end;
        end;
        Result := true;
      end;
    end;


    procedure KillDaCow;
    var
      CowsKilled,o: Integer;
      madtype: array [1..7] of string;
      CowColor: array [0..4] of Integer;
    begin
      try
      CowsKilled := 0;
      Writeln('now to own some cows');
      CowColor[0] := 12238787;
      CowColor[1] := 3755348;;
      CowColor[2] := 2765117;
      CowColor[3] := 5002080;
      CowColor[4] := 6911365;

      MadType[1] :='darn..';
      MadType[2] :='grr got it before me';
      MadType[3] :='lol';
      MadType[4] :='keep getting beaten to them';
      MadType[5] :='grrr..';
      MadType[6] :='darn, peaople keep getting it over me';
      MadType[7] :='darn i''m a noob';

      FightSetup;
      repeat
      for o := 0 to 4 do
      begin
        FindNormalRandoms;
        if FindColorTolerance(x,y,Cowcolor[o],0,0,518,339,4) then
        begin
          MMouse(x,y,10,10);
          Wait(100);
          if IsUpText('ow')=true then
          begin
            RandClick('ow','ttack');
            Flag;
            Wait(750+random(1000));
            if FindBlackChatMessage('omeone') then
            Typesend(madtype[1+random(6)]);
            begin
              KillDaCow;
            end;
            wait(2000);
            if infight = true then
            begin
              repeat
                Wait(500);
              until Infight = false;
            CowsKilled := CowsKilled + 1;
            wait(1000);
            Collecthide;
            end;
          end;
        Wait(500);
        end;
      end;
      until(InvFull);
      except
        Writeln('Saved That Run-Time Error, Thanks Timer!');
      end;
    end;


    procedure ToPen;
    var
    z,TheRoadColor:integer;
    begin
      login;
      Z:=0
      Makecompass('n');
      TheRoadColor := findfallyroadColor;
      Wait(500);
      if radialwalk(TheRoadColor,180,270,40,1,1) then
      begin
        wait(500);
        end else Exit;
          repeat
            radialroadwalk(TheRoadColor,165,200,50,1,1);
            Writeln('lalala');
            wait(200);
          until(findsymbolin(x,y,'tree',628,8,704,165));
        mouse(x + 10,y,10,5,true);
        flag;
        if findcolortolerance(x,y,235,628,8,705,117,20) then
        begin
          mouse(x,y + 5,5,5,true);
          flag;
          wait(500);
        end;
        if findcolorSpiraltolerance(x,y,5467001,0,0,516,338,10) then
        begin
          randclick('ate','pen');
          Z:= Z + 1;
        end else exit;
    end;

    procedure ToBank;
    var
      LoadsDone: Integer;
    begin
      LoadsDone := 0;
      LoadsDone := LoadsDone + 1;
      if players[currentplayer].integers[4] <= LoadsDone then
      begin
      Logout;
      NextPlayer(true);
      end
    end;

    begin
      SetupSRL;
      ActivateClient;
      DeclarePlayers;
      repeat
        ToPen;
        KillDaCow;
        ToBank;
      until(false);
    end.

  4. #4
    Join Date
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    lol, it would help if you'd tell me what you did timer, just doing it for me isn't gonna help much is it?
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

  5. #5
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Its meant to be
    for 0:= 0 to 4 do....

    Your meant to put up all the arrays you had 4 but you only called up 3 in your
    KillDaCow Procedure.
    Hence the error

  6. #6
    Join Date
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    hmm, i didn't mean to do that...but wouldn't not calling it just mean that when looking for colors it would only do 0-3 though?
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

  7. #7
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It was problems with your Array Lengths, I Couldn't Really Fix Them Becasue, idk.. LoL so I Added In Try and Except Those Bypass All Runtime Errors, It Will Work, and Then, No Run Time Error

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Out of Range Error
    By Torrent of Flame in forum OSR Help
    Replies: 7
    Last Post: 12-20-2008, 09:24 PM
  2. Out of range error still...=(
    By oakley123 in forum OSR Help
    Replies: 2
    Last Post: 10-22-2008, 05:48 AM
  3. Odd out of range error..
    By JAD in forum OSR Help
    Replies: 7
    Last Post: 05-09-2007, 09:28 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
  •