Results 1 to 17 of 17

Thread: WorldSwitcher.scar

  1. #1
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default WorldSwitcher.scar

    SCAR Code:
    {*******************************************************************************
    Function OpenWorldScreen: Boolean;
    by: Nava2
    Description: Opens the world screen. Returns true if world screen is opened.
    *******************************************************************************}

    function OpenWorldScreen: Boolean;
    var
      TPA: array [0..1] of TPointArray;
      W, TheDC, iTime: Integer;
      Box: TBox;
    begin
      Result := WorldScreen;
      if Result then Exit;

      W := BitmapFromString(17, 13, 'beNpjYKAb+I8ESBXBNAfTcDwK' +
           'CGrBVIPmDEz15GlB1oWVgSfokBUQ1EKM8whqwRV0eIIRv5OIBQByA' +
           'K1T');
      TheDC := GetTargetDC;
      SetTargetDC(GetBitmapDc(w));
      FindColorsTolerance(TPA[0], clWhite, 0, 0, 17, 13, 0);
      SetTargetDC(TheDC);
      FindColorsTolerance(TPA[1], 13158, 305, 239, 368, 272, 3);
      if FindTPAinTPA(TPA[0], TPA[1], TPA[0]) then
      begin
        Box := GetTPABounds(TPA[0]);
        Box := IntToBox(Box.x1, Box.y1, Box.x1 + 82, Box.y2);
        MouseBox(Box.x1, Box.y1, Box.x2, Box.y2, 1);
        iTime := GetTimeRunning + 2000;
        while not Result do
        begin
          if GetTimeRunning > iTime then Exit;
          Wait(RandomRange(40, 80));
          Result := WorldScreen;
        end;
      end;
    end;

    This works regardless of if you have a favourited world now, or if there is already a world picked.

    Edit:

    I was getting annoyed with my worlds.INI always being out of date, so I wrote these up. Not sure about the current policy on accessing the Jagex website but here is what I fixed up. mixster's world's parser was the Key base for this.

    SCAR Code:
    function UpdateWorlds: Boolean;
    var
      worldList: TWorldArray;
      str, Path: string;
      tsa, tsb: TStringArray;
      W, I, H, Time: Integer;
    begin
      try
        Result := True;
        Path := AppPath + 'Includes\SRL\SCSS\Worlds.INI';
        Writeln('NOTE: Attempting to update the Worlds.INI, please allow the script to access this file.');
        Time := GetTimeRunning;
        W := RewriteFile(Path, False);
        CloseFile(W);
        str := GetPage('http://www.runescape.com/slu.ws?order=WMPLA');
        Delete(str, 1, Pos('<a href="?order=MWPLA">', str));
        Delete(str, 1, Pos('<tr', str) + 3);
        tsa := m_Explode(str, '<tr');
        SetLength(worldList, High(tsa) + 1);
        H := High(tsa);
        for I := 0 to H do
          with worldList[I] do
          begin
            tsb := m_Explode(tsa[I], '<td');
            if High(tsb) <= 7 then
            begin
              Writeln('Skipping world ' + IntToStr(I + 1) + ' because explosion didn''t return enough values');
              Continue;
            end;
            PlayerNo := StrToIntDef(Copy(tsb[2], 2, Pos(' Players', tsb[2]) - 2), 2000);
            case Uppercase(Between('"', '"', tsb[3])) of
              'US': Location := 'United States';
              'NL': Location := 'Netherlands';
              'CA': Location := 'Canada';
              'AU': Location := 'Australia';
              'SE': Location := 'Sweden';
              'FI': Location := 'Finland';
              'GB': Location := 'Great Britain';
              'NZ': Location := 'New Zealand';
              'DK': Location := 'Denmark';
              'BE': Location := 'Belguim';
              'BR': Location := 'Brazil';
              'MX': Location := 'Mexico';
              'IE': Location := 'Ireland';
              'NO': Location := 'Norway';
              else
                Writeln('Location: ' + Between('"', '"', tsb[3]) + ' unknown. Please notify someone of this.');
            end;
            Prefix := Between('http://', '.runescape', tsb[1]);
            if Prefix = '' then
              Prefix := Replace(Lowercase(Between('>' + #10, #10 + #10, tsb[1])), ' ', '');
            Number := StrToIntDef(Replace(Prefix, 'world', ''), -1);
            if Number = -1 then
              Writeln(tsb[1] + ' || ' + Prefix);
            Activity := Between('>', '<', tsb[4]);
            if Activity = '-' then
              Activity := '';
            LootShare := Between('title="', '"', tsb[5]) = 'Y';
            QuickChat := Between('title="', '"', tsb[6]) = 'Y';
            PvP := Between('title="', '"', tsb[7]) = 'Y';
            Members := Between('>', '<', tsb[8]) = 'Members';
          end;
        //Writeln('Writing to the INI File. T: ' + IntToStr(GetTimeRunning - W));
        WriteINI('Worlds', 'Count', IntToStr(High(worldList) + 1), Path);
        WriteINI('Worlds', 'High', IntToStr(worldList[High(worldList)].Number) + #13#10, Path);
        H := High(worldList);
        for I := 0 to H do
          with worldList[I] do
          begin
            Str := 'World' + IntToStr(Number);
            DeleteINI(Str, '', Path);
            WriteINI(Str, 'Prefix', Prefix, Path);
            WriteINI(Str, 'Activity', Activity, Path);
            WriteINI(Str, 'Members', BoolToStr(Members), Path);
            //WriteINI(Str, 'Flag', fla + 'Flag', Path);
            WriteINI(Str, 'Location', Location, Path);
            WriteINI(Str, 'LootShare', BoolToStr(LootShare), Path);
            WriteINI(Str, 'QuickChat', BoolToStr(QuickChat), Path);
            WriteINI(Str, 'PvP', BoolToStr(PvP) + #13#10, Path);
          end;
        Writeln('Parsed Worlds Page into Worlds.INI. Took ' + IntToStr(GetTimeRunning - Time) + ' ms.');
      except
        Result := False;
        SRL_Warn('UpdateWorlds', ExceptionToString(ExceptionType, ExceptionParam), Warn_AllVersions);
      end;
    end;

    {*******************************************************************************
    procedure LoadWorldArrays;
    by: Narcle; Edits by Nava2
    Description: Loads the world array into WorldArray from Worlds.ini
    *******************************************************************************}

    // Edit: Changed to use Members as a boolean to go w/ the previous Parser function.. Also added StrToBool; As well as try..except
    procedure LoadWorldArrays;
    var
      i, H, Hw: integer;
    begin
      try
        H := StrToInt(ReadINI('Worlds', 'High', AppPath + 'includes\SRL\SCSS\worlds.ini'));
      except
        Writeln('LoadWorldArrays: Could not load world arrays, attempting to rewrite Worlds.INI');
        if not UpdateWorlds then
        begin
          SRL_Warn('LoadWorldArrays', 'Could not Load World arrays, please download mixster''s world parser, and replace Worlds.ini', Warn_AllVersions);
          Exit;
        end;
      end;
      for i := 1 to H do
      begin
        if not (ReadINI('World' + IntToStr(i), 'Prefix', AppPath + 'includes\SRL\SCSS\worlds.ini') = '') then
        begin
          SetArrayLength(WorldArray, Length(WorldArray)+1);
          Hw := High(WorldArray);
          WorldArray[Hw].Number := i;
          WorldArray[Hw].Prefix := ReadINI('World' + IntToStr(i), 'Prefix', AppPath + 'includes\SRL\SCSS\worlds.ini');
          WorldArray[Hw].Members := StrToBool(ReadINI('World' + IntToStr(i), 'Members', AppPath + 'includes\SRL\SCSS\worlds.ini'));
          WorldArray[Hw].LootShare := StrToBool(ReadINI('World' + IntToStr(i), 'Lootshare', AppPath + 'includes\SRL\SCSS\worlds.ini'));
          WorldArray[Hw].QuickChat := StrToBool(ReadINI('World' + IntToStr(i), 'Quickchat', AppPath + 'includes\SRL\SCSS\worlds.ini'));
          WorldArray[Hw].PVP := StrToBool(ReadINI('World' + IntToStr(i), 'PvP', AppPath + 'includes\SRL\SCSS\worlds.ini'));
        end;
      end;
    end;
    Last edited by Nava2; 03-23-2009 at 09:48 PM.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  2. #2
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    looking good.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  3. #3
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    No procedure to actually switch worlds?
    I do visit every 2-6 months

  4. #4
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Nah, the current ones work absolutely fine
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  5. #5
    Join Date
    Jul 2008
    Location
    Canada
    Posts
    1,612
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Lol, i could use this, is this being added to SRL?

  6. #6
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Nice, added. Thanks nava.

  7. #7
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Yay there are issues with the rest of the functions.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  8. #8
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    Yay there are issues with the rest of the functions.
    Such as...?

  9. #9
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    Yay there are issues with the rest of the functions.
    Well the one I know of should be fixed... but its in the dev svn and it hasn't been released for awhile now.
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  10. #10
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    It doesn't always select the world. Says its not there kinda thing, when it is.

    Try this:
    SCAR Code:
    if not LoggedIn then
      begin
        if not SelectWorld(44) then
          if not SelectWorld(143) then
            if not SelectWorld(145) then
            begin
              Writeln('Could not select worlds 44, 143, or 145. Terminating.');
              TerminateScript;
            end;
        //LoginPlayer;
      end;
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  11. #11
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    It doesn't always select the world. Says its not there kinda thing, when it is.

    Try this:
    SCAR Code:
    if not LoggedIn then
      begin
        if not SelectWorld(44) then
          if not SelectWorld(143) then
            if not SelectWorld(145) then
            begin
              Writeln('Could not select worlds 44, 143, or 145. Terminating.');
              TerminateScript;
            end;
        //LoginPlayer;
      end;
    I think thats the error that Narcle fixed.

  12. #12
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by ZephyrsFury View Post
    I think thats the error that Narcle fixed.
    Awesome
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  13. #13
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Sorry for double, but added more stuff.

    E: Thanks to mixster, added new flag types.
    Last edited by Nava2; 03-23-2009 at 09:48 PM.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  14. #14
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Well I would of done this myself. But I was under the impression that using online resources in the actually SRL svn was against one of the "rules/guidelines." But times have changes and I personally would love to have this in SRL. /shrug
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  15. #15
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Same, I just did it because I wasn't sure anyone had thought of it. I think its a good idea, but I guess my opinion doesn't matter
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  16. #16
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    You could just use FAWG Online.

  17. #17
    Join Date
    Mar 2007
    Posts
    1,700
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    SCAR Code:
    {*******************************************************************************
    procedure LowestWorld;
    by: lordsaturn
    Description: Chooses the f2p world with the least amount of players
    *******************************************************************************}

    procedure LowestWorld;
    var
      a, c, i, x, y: integer;
    begin
      if LoggedIn then
        Logout;
      OpenWorldScreen;
      c := CountColor(16777215, 57, 148, 691, 456);
      Mouse(195, 121, 3, 3, True);
      a := GetSystemTime;
      while c = CountColor(16777215, 57, 148, 691, 456) do
      begin
        Wait(100);
        if GetSystemTime - a > 5000 then
          Break;
      end;
      Wait(50+Random(50));
      for i := 0 to 16 do
        if Trim(GetTextAtEx(631, 149+i*8, 0, SmallChars, False, False, 0, 2, clWhite, 8,
          False, tr_AllChars)) = 'Free' then
          if not FindColor(x, y, 4027205, 582, 148+i*8, 602, 155+i*8) then
          begin
            Mouse(85, 148+i*8, 600, 7, True);
            while WorldScreen do
              Wait(100);
            Exit;
          end;
      TypeByte(VK_ESCAPE);
    end;

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. (Usable) WorldSwitcher.scar !
    By Floor66 in forum Research & Development Lounge
    Replies: 5
    Last Post: 12-08-2008, 02:12 AM
  2. Replies: 28
    Last Post: 06-22-2006, 04:27 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
  •