Results 1 to 4 of 4

Thread: Runique AFK Trainer

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Runique AFK Trainer

    @hawkzz;


    ATTENTION:

    THIS SCRIPT ONLY:
    Eats sharks
    Drinks prayer potions
    Teleports home at a certain health
    Tracks XP gained and XP per hour


    It will not:

    Loot Items
    Attack monsters
    Teleport away from staff
    bank items


    ^^ those features are for my private repositories



    Instructions


    Start the script logged in

    Fill out the top part of the script:

    Code:
    USERNAME = '';
      EAT_AT = 350;
      DRINK_PRAYER_AT = 450;
      TELE_AT = 150;
    You must put in a username or else the script cannot tell if you are logged in or not and automatically terminate

    Make sure your graphic set up looks like this(this script only looks for food in your inventory and reads minimap text so I'm not sure if this matters but just to be safe):







    Simba Code:
    {$I srl-6/srl.simba}

    const

      USERNAME = '';
      EAT_AT = 350;
      DRINK_PRAYER_AT = 450;
      TELE_AT = 150;



      CLIENTNAME = 'Runique';
      CLIENTWIDTH = 765;
      CLIENTHEIGHT = 525;
      foodDTM = 'mWAAAAHicY2FgYChgYmDIB+IkIK4CYnNGBgZtILYEYjMgnteUDVTFCMesQBIZM6JhEAAAEHUEQw==';
      prayDTM = 'mQwAAAHicY2ZgYHBlYmDwAmJ7IHZmZGAwA2JzIHa/vAgoywjFCMCIKgoAlPADTA==';
      V = '1.00';
    var
      sharkDTM, prayerDTM, startXP:integer;
      rsClient:TSysProc;

    function string.contains(s: string): Boolean;
    begin
      if ((self <> '') and (s <> '')) then
        result := (pos(s, self) > 0)
      else
        result := False;
    end;

    function getSimpleText(Colors:TIntegerArray;x1, y1, x2, y2:integer;font:string):String;
    var
      textTPA:TPointArray;
      textATPA, textATPAS:T2DPointArray;
      i:integer;
      textStr:string;
    begin
      setLength(textATPAS, length(colors));
      for i := 0 to high(colors) do
        findColors(textATPAS[i], Colors[i], x1, y1, x2, y2);
      textTPA := mergeATPA(textATPAS);
      textATPA := SplitTPAEx(textTPA, 1, 10);
      filtertpasbetween(textatpa, 0, 1);
      SortATPAFromFirstPointX(textATPA, Point(0, 0));
      result := getTextATPA(textATPA, 3, font);
    end;

    function getHealth():integer;
    begin;
      try
        result := strToInt(getSimpleText([65280, 65535, 501500, 855541], 724, 72, 750, 90, 'statchars07'));
      except
        result := 0;
      end;
    end;

    function getPrayer():integer;
    begin;
      try
        result := strToInt(getSimpleText([65280, 65535, 501500, 855541], 739, 112, 764, 130, 'statchars07'));
      except
        result := 0;
      end;
    end;

    function getXpBarTPA():TPointArray;
    begin
      findColors(result, 16777215, 424, 101, 519, 118);
    end;

    function getXpBarText():string;
    var
      textTPA:TPointArray;
      textATPA:T2DPointArray;
    begin
      textTPA := getXpBarTPA();
      textATPA := splittpaex(textTPA, 1, 10);
      filtertpasbetween(textatpa, 0, 1);
      SortATPAFromFirstPointX(textATPA, Point(0, 0));
      result := getTextATPA(textatpa, 3, 'smallchars07');
    end;

    function xpBarOpen():boolean;
    begin
      result := getXPBarText().contains('XP:');
    end;

    function getXpBarTotal():integer;
    var
      BARstring:string;
    begin
      BARstring := getXpBarText();
      BARstring := replace(BARstring, '''', '', [rfReplaceAll]);
      BARstring := replace(BARstring, 'XP:', '', [rfReplaceAll]);
      BARstring := replace(BARstring, ' ', '', [rfReplaceAll]);
      result := strtoInt(barString);
    end;

    function activateRsClient(firstTime:boolean):boolean;
    var
      processes: TSysProcArr;
      i: integer;
    begin
      result := false;
      processes := GetProcesses();
      if (firstTime) then
        writeln('Scanning for ' , CLIENTNAME , 'Client..');
      for i := 0 to high(processes) do
        if (processes[i].title.contains(CLIENTNAME)) and (processes[i].width = CLIENTWIDTH) and (processes[i].height = CLIENTHEIGHT) then
        begin
          if (firstTime) then
          begin
            writeln('Found client');
            writeln('Target set to: ' , toStr(processes[i]));
          end;
          rsClient := processes[i];
          setTarget(processes[i]);
          ActivateClient();
          exit(true);
        end;
    end;

    function getClientName():string;
    begin
      activateRsClient(false);
      result := rsClient.title;
    end;

    function isLoggedIn():boolean; override;
    begin
      if (USERNAME = '') then
      begin
        writeln('Please enter a username at the top of the script');
        terminateScript();
      end else
        result := getClientName().contains(USERNAME);
    end;

    function getFightingMonster():string;
    begin
      result := getSimpleText([16777215], 33, 78, 142, 103, 'UpChars07');
    end;

    function perHour(what:extended):int64;
    begin
      result := Round(what * (3600.0 / (GetTimeRunning / 1000.0)));
    end;

    procedure state(s:string);
    var
      h, p, currentXP:integer;
    begin
      currentXP := getXPBarTotal();
      h := getHealth();
      p := getPrayer();
      clearDebug();
      writeln('======================================Version[',toStr(V),']');
      writeln('State: ' , s);
      writeln('Health: ' , toStr(h), '[', toStr(h - EAT_AT),']');
      writeln('Prayer: ' , toStr(p), '[', toStr(p - DRINK_PRAYER_AT),']');
      writeln('XP Gained: ' , toStr(currentXP - startXP), ' Per hour: ' , toStr(perHour(currentXP - startXP)));
      writeln('======================================');
    end;

    procedure checkHealth();
    var
      i, x, y:integer;
    begin
      if (getHealth() < EAT_AT) then
      begin
        if findDTM(sharkDTM, x, y, 562, 257, 728, 507) then
        begin
          state('Eating');
          mouse(Point(x, y), mouse_left);
          wait(2000);
        end else
          if (getHealth() < TELE_AT) then
          begin
            state('Health too low and no food teleporting home!');
            sendKeys('::home', 30, 30);
            terminateScript();
          end;
      end else
        if (getPrayer() < DRINK_PRAYER_AT) then
          if findDTM(prayerDTM, x, y, 562, 257, 728, 507) then
          begin
            mouse(Point(x, y), mouse_left);
            state('Drinking prayer potion');
            wait(2000);
          end;
    end;

    procedure initDTMz();
    begin
      sharkDTM := DTMFromString(foodDTM);
      prayerDTM := DTMFromString(prayDTM);
    end;

    procedure freememory;
    begin
      freeDTM(sharkDTM);
      freeDTM(prayerDTM);
    end;

    procedure loop();
    begin
      if (not isLoggedIn()) then
      begin
        state('Logged out');
        terminateScript();
      end else
      begin
        if (getFightingMonster() <> '') then
        begin
          state('Fighting ' + getFightingMonster() + 's Checking health and prayer');
          wait(2000);
        end else
          state('Checking health and prayer');
      end;
      checkHealth();
    end;

    begin
      initDTMz();
      addOnTerminate('freeMemory');
      activateRsClient(true);
      if (not isLoggedIn()) then
      begin
        writeln('Please login before starting the script');
        terminateScript();
      end else
      begin
        if (not XPBarOpen()) then
        begin
          mouse(Point(535, 110), mouse_left);
          wait(1000);
        end;
        startXP := getXPBarTotal();
      end;
      repeat
        loop();
        wait(2000);
      Until False;
    end.

  2. #2
    Join Date
    Jun 2016
    Posts
    23
    Mentioned
    3 Post(s)
    Quoted
    15 Post(s)

    Default

    Hey, I have tried the script and it worked perfect for like 30min, then i got an error and script stopped.

    Error: "vP:17584950" is an invalid integer at line 95
    Execution failed.
    The following DTMs were not freed: [0, 1]
    The following bitmaps were not freed: [Minimap Mask]

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by hawkzz View Post
    Hey, I have tried the script and it worked perfect for like 30min, then i got an error and script stopped.

    Error: "vP:17584950" is an invalid integer at line 95
    Execution failed.
    The following DTMs were not freed: [0, 1]
    The following bitmaps were not freed: [Minimap Mask]
    Didn't even look at 95 this is the only thing it could be

    Simba Code:
    function getXpBarTotal():integer;
    var
      BARstring:string;
    begin
      BARstring := getXpBarText();
      BARstring := replace(BARstring, '''', '', [rfReplaceAll]);
      BARstring := replace(BARstring, 'XP:', '', [rfReplaceAll]);
      BARstring := replace(BARstring, ' ', '', [rfReplaceAll]);
    try
      result := strtoInt(barString);
    except
    end;
    end;


    Replace the xp bar function with that. Can I see a screenshot of your xp bar? The issue is I coded in the text area, and my XP was 8 digits long. Yours is probably 9 so it cut off part of it and read the text weird

  4. #4
    Join Date
    Jun 2016
    Posts
    23
    Mentioned
    3 Post(s)
    Quoted
    15 Post(s)

    Default

    I think i didnt have my XP bar open, now i have tried with open and its working fine so far.

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
  •