Results 1 to 9 of 9

Thread: ChangeWorld bug

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

    Default ChangeWorld bug

    Well I have SRL do ChangeWorld(RandomWorld(Members, false));. Usually it works fine, but this has happened twice now

    Failed to find World 127!
    Both times with world 127. It scrolls as far as 126 then says that it failed to find 127.

    I'm not sure what's wrong (To be honest I just cbf to wrap my brain around this ub3r complex dev code ), here's the code:

    Code:
    {*******************************************************************************
    Function SelectWorld(W: Integer): Boolean;
    by: Narcle & ZephyrsFury
    Description: Switches to the specified world. Returns true if successful.
    *******************************************************************************}
    function SelectWorld(W: integer): boolean;
    var
      x, y, xx, yy, T: integer;
      WRec: TWorld;
    begin
      SRL_Warn('WorldSwitcher.scar', 'WorldSwitcher.scar has been moved from Misc to Core. Scripters please un-include /misc/WorldSwitcher.scar', 34);
      if OpenWorldScreen then
      begin
        wait(400+random(200));
        if FindWorld(W) then
        begin
          wait(100+random(100));
          if GetWorldInfo(W, WRec) then
          begin
            Writeln('World: '+inttostr(WRec.Number)+', Players: '+inttostr(WRec.PlayerNo)+', Members: '+Booltostr(WRec.Members)+', PvP: '+Booltostr(WRec.PVP));
            If FindTextTpaEx(16777215, 0, 57, 130, 162, 458, x, y, 'orld '+inttostr(W)+' ', SmallChars, nothing) then
            begin
              MMouse(x, y, 500, 4);
              GetMousePos(x, y);
              wait(300);
              if FindColor(xx, yy, 4351095, x-20, y-2, x+20, y+2) then
              begin
                Mouse(x, y, 0, 0, true);//Final click
                T := GetSystemTime;
                while (WorldScreen) and (GetSystemTime - T < 10000) do
                  Wait(100);
                Result := (not(WorldScreen));
              end;
            end;
          end else
            WriteLn('World ' + IntToStr(W) + ' is either OFFLINE or FULL.');
        end else
          WriteLn('Failed to find World ' + IntToStr(W) + '!');
        if (not(Result)) then TypeByte(vk_Escape);
      end;
    end;
    
    {*******************************************************************************
    function RandomWorld(Members, PvP: Boolean): Integer;
    by: Narcle & mixster
    Description: Returns a random world by paramaters.
    *******************************************************************************}
    function RandomWorld(Members, PvP: Boolean): Integer;
    var
      i, H, l: integer;
      wArray: TWorldArray;
    begin
      if Length(WorldArray) < 1 then
       LoadWorldArrays;
      H := High(WorldArray);
      SetLength(wArray, H + 1);
      for i := 0 to H do
        if (WorldArray[i].Members = Members) and (WorldArray[i].PvP = PvP) then
        begin
          wArray[l] := WorldArray[i];
          Inc(l);
        end;
      Result := wArray[random(l)].Number;
    end;
    
    {*******************************************************************************
    function ChangeWorld(W: Integer): Boolean;
    by: Nava2
    Description: Changes to world W. Returns True if successful.
    *******************************************************************************}
    
    function ChangeWorld(W: Integer): Boolean;
    begin
      while LoggedIn do LogOut;
      Result := SelectWorld(W);
      LoginPlayer;
    end;

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

    Default

    Actually the problem isn't in either of those. Its in the scrolling system. Which is based on the number of worlds. I use the World number and Divide it by the High count of worlds. This then gives a percent that I use to determine the correct scroll bar location. But it isn't perfect because some worlds are skipped, and it just happens to make world 127 one of those "odd" worlds.
    (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.

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

    Default

    Could that be replaced with a hold mouse and a Repeat, Until loop; until it finds the text??

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

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    Could that be replaced with a hold mouse and a Repeat, Until loop; until it finds the text??
    We tried that before and its PAINFULLY slow. This could be easily fixed with a more precise percentage calculator for the scroll bar.
    (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.

  5. #5
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    Function N_OpenWorldScreen: Boolean;
    var
      X, Y, iTime: Integer;
    begin
      Result := WorldScreen;
      if Result then
        Exit;
      if not RSReady then
      begin
        srl_Warn('OpenWorldScreen', 'not start screen', -2);
        exit;
      end;
      If FindColor(x, y, 13158, 342, 235, 425, 262) or
         FindColor(x, y, 16777215, 342, 235, 425, 262)then
      begin
        MouseBox(348, 239, 415, 245, 1);
        iTime := GetTimeRunning + 10000;
        while (not Result) do
        begin
          if GetTimeRunning > iTime then Exit;
          Wait(RandomRange(75, 300));
          Result := WorldScreen;
        end;
      end;
    end;

    Procedure WorldSwitch;
    var
      TW, I, Count: Integer;
      C: Boolean;
      x, y, xx, yy, T: integer;
      WRec: TWorld;
    begin
      Logout;
      Wait(100+Random(4000));

      For I:=0 to 3 do
      begin
        C := N_OpenWorldScreen;
        If Not C then Wait(400+Random(900)) Else Break;
      end;
      If Not C then Exit;

      C := False;
      Repeat
        Inc(Count);

        Repeat
          TW := RandomWorld(True, False);
        Until(Not InIntArray(WorldVisit, TW));

        if FindWorld(TW) then
        begin
          wait(100+random(100));
          if GetWorldInfo(TW, WRec) then
          begin
            If DebugMode then
              Writeln('World: '+inttostr(WRec.Number)+', Players: '+inttostr(WRec.PlayerNo)+', Members: '+Booltostr(WRec.Members)+', PvP: '+Booltostr(WRec.PVP));
            If FindTextTpaEx(16777215, 0, 57, 130, 162, 458, x, y, 'orld '+inttostr(TW)+' ', SmallChars, nothing) then
            begin
              MMouse(x, y, 500, 4);
              GetMousePos(x, y);
              wait(170+Random(200));
              if FindColor(xx, yy, 4351095, x-20, y-2, x+20, y+2) then
              begin
                Mouse(x, y, 0, 0, true);//Final click
                T := GetSystemTime;
                while (WorldScreen) and (GetSystemTime - T < 10000) do
                  Wait(100);
                C := (not(WorldScreen));
              end;
            end;
          end else
           If DebugMode then WriteLn('World ' + IntToStr(TW) + ' is either OFFLINE or FULL.');
        end else
        WriteLn('Failed to find World ' + IntToStr(TW) + '!');
      Until(C)or(Count > 10);
      If Not C then
      begin
        Writeln('** Failed finding any new world, player is now inactive. **');
        Exit;
      end;
      Writeln('New world is: ' + IntToStr(TW));


      For I:=0 to 9 do
      If I = 9 then Break else
        WorldVisit[I] := WorldVisit[I+1];

      WorldVisit[9] := TW;

      Case Random(5)of
        0..2:Wait(100+Random(20000));
      end;
      LoginPlayer;
    end;

    ^ From one of my private scripts, will need some modification but it always picks a world.

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

    Default

    /facepalm

    The thing he is talking about is IN FindWorld(); ...

    Edit: Replace FindWorld with this, let me know if it works.

    SCAR Code:
    {*******************************************************************************
    function FindWorld(W: integer): Boolean;
    by: Narcle
    Description: Scrolls to area and returns true if world was found
    *******************************************************************************}

    function FindWorld(W: integer): Boolean;
    Var
      i, x, y, H: integer;
      WPos, SPos: Extended;
    begin
      if not WorldScreen then
       Exit;
      Result := FindTextTpaEx(16777215, 0, 57, 130, 162, 458, x, y, 'orld '+inttostr(W)+' ', SmallChars, Nothing);
      if Result then
       Exit;
      if Length(WorldArray) < 1 then
       LoadWorldArrays;
      H := High(WorldArray);
      for i := 0 to H do
       if (WorldArray[i].Number = W) then
       begin
         WPos := i+1;
         Break;
       end;
      SPos := (WPos / (H+1));
      if not WorldsOrdered then
      begin
        Mouse(121, 119, 6, 6, true);//makes them drop down
        WorldsOrdered := true;
        wait(500+random(500));
      end;
      if (W < 11) then SPos := 0.0;
      if (W > H-9) then SPos := 1.01;//101 compensate for randomness
      Mouse(698, Round(SPos*262.0+162), 3, 3, true);
     
      wait(500+Random(100));
     
      Result := FindTextTpaEx(16777215, 0, 57, 130, 162, 458, x, y, 'orld '+inttostr(W)+' ', SmallChars, Nothing);
    end;
    Last edited by Narcle; 06-20-2009 at 06:46 AM.
    (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.

  7. #7
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    If you looked at my code, a bit, you would see that it opens
    the world menu and repeats FindWorld until it works

    In other words, makes it work.

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

    Default

    Here's what I got:

    SCAR Code:
    World 1 is either OFFLINE or FULL.
    World 2 is either OFFLINE or FULL.
    World: 3, Players: 1973, Members: False, PvP: False
    World: 4, Players: 1615, Members: False, PvP: False
    World: 5, Players: 696, Members: False, PvP: False
    World 6 is either OFFLINE or FULL.
    World: 7, Players: 1078, Members: True, PvP: False
    World: 8, Players: 705, Members: False, PvP: False
    World: 9, Players: 1680, Members: True, PvP: False
    World: 10, Players: 426, Members: False, PvP: False
    World: 11, Players: 440, Members: False, PvP: False
    World: 12, Players: 795, Members: True, PvP: False
    World: 13, Players: 716, Members: False, PvP: False
    World: 14, Players: 698, Members: False, PvP: False
    World: 15, Players: 820, Members: True, PvP: False
    World: 16, Players: 467, Members: False, PvP: False
    World: 17, Players: 1086, Members: False, PvP: True
    World: 18, Players: 1151, Members: True, PvP: True
    World: 19, Players: 703, Members: False, PvP: False
    World: 20, Players: 974, Members: False, PvP: False
    World: 21, Players: 1073, Members: False, PvP: True
    World: 22, Players: 1082, Members: True, PvP: False
    World: 23, Players: 758, Members: True, PvP: False
    World: 24, Players: 962, Members: True, PvP: False
    World: 25, Players: 1019, Members: False, PvP: False
    World: 26, Players: 1901, Members: True, PvP: True
    World: 27, Players: 811, Members: True, PvP: False
    World: 28, Players: 1070, Members: True, PvP: False
    World: 29, Players: 694, Members: False, PvP: False
    World: 30, Players: 700, Members: False, PvP: False
    World: 31, Players: 1873, Members: True, PvP: False
    World: 32, Players: 1286, Members: False, PvP: True
    World: 33, Players: 699, Members: False, PvP: False
    World: 34, Players: 715, Members: False, PvP: False
    World: 35, Players: 705, Members: False, PvP: False
    World: 36, Players: 1092, Members: True, PvP: False
    World: 37, Players: 497, Members: False, PvP: False
    World: 38, Players: 695, Members: False, PvP: False
    World: 39, Players: 1068, Members: True, PvP: False
    World: 40, Players: 699, Members: False, PvP: False
    World: 41, Players: 693, Members: False, PvP: False
    World: 42, Players: 1063, Members: True, PvP: False
    World: 43, Players: 713, Members: False, PvP: False
    World: 44, Players: 1751, Members: True, PvP: False
    World: 45, Players: 1064, Members: True, PvP: False
    World: 46, Players: 1065, Members: True, PvP: False
    World: 47, Players: 706, Members: False, PvP: False
    World: 48, Players: 1076, Members: True, PvP: False
    World: 49, Players: 413, Members: False, PvP: False
    World: 50, Players: 999, Members: False, PvP: False
    World: 51, Players: 609, Members: True, PvP: False
    World: 52, Players: 608, Members: True, PvP: False
    World: 53, Players: 672, Members: True, PvP: False
    World: 54, Players: 601, Members: True, PvP: False
    World: 55, Players: 724, Members: False, PvP: False
    World: 56, Players: 1061, Members: True, PvP: False
    World: 57, Players: 853, Members: False, PvP: True
    World: 58, Players: 1064, Members: True, PvP: False
    World: 59, Players: 1084, Members: True, PvP: False
    World: 60, Players: 1072, Members: True, PvP: False
    World: 61, Players: 692, Members: False, PvP: False
    World: 62, Players: 700, Members: False, PvP: False
    Failed to find World 63!
    World: 64, Players: 1060, Members: True, PvP: False
    World: 65, Players: 1091, Members: True, PvP: True
    World: 66, Players: 1057, Members: True, PvP: False
    World: 67, Players: 612, Members: True, PvP: False
    World: 68, Players: 745, Members: True, PvP: False
    World: 69, Players: 618, Members: True, PvP: False
    World: 70, Players: 1082, Members: True, PvP: False
    Failed to find World 71!
    Failed to find World 72!
    World: 73, Players: 688, Members: False, PvP: False
    World: 74, Players: 712, Members: False, PvP: False
    World: 75, Players: 703, Members: False, PvP: False
    World: 76, Players: 1074, Members: True, PvP: False
    Failed to find World 77!
    World: 78, Players: 1071, Members: True, PvP: False
    World: 79, Players: 1061, Members: True, PvP: False
    World: 80, Players: 376, Members: False, PvP: False
    Failed to find World 81!
    Failed to find World 82!
    World: 83, Players: 731, Members: True, PvP: False
    World: 84, Players: 738, Members: True, PvP: False
    World: 85, Players: 698, Members: False, PvP: False
    World: 86, Players: 1870, Members: True, PvP: True
    World: 87, Players: 699, Members: False, PvP: False
    World: 88, Players: 1050, Members: True, PvP: False
    Failed to find World 89!
    Failed to find World 90!
    Failed to find World 91!
    World: 92, Players: 734, Members: True, PvP: False
    World: 93, Players: 712, Members: False, PvP: False
    World: 94, Players: 693, Members: False, PvP: False
    World: 95, Players: 695, Members: False, PvP: False
    World: 96, Players: 859, Members: False, PvP: False
    World: 97, Players: 1064, Members: True, PvP: False
    Failed to find World 98!
    Failed to find World 99!
    Failed to find World 100!
    Failed to find World 101!
    World: 102, Players: 701, Members: False, PvP: False
    World: 103, Players: 1149, Members: True, PvP: False
    World: 104, Players: 1076, Members: True, PvP: False
    Failed to find World 105!
    Failed to find World 106!
    Failed to find World 107!
    Failed to find World 108!
    World: 109, Players: 375, Members: False, PvP: False
    World: 110, Players: 609, Members: True, PvP: False
    World: 111, Players: 619, Members: True, PvP: False
    Failed to find World 112!
    Failed to find World 113!
    Failed to find World 114!
    Failed to find World 115!
    Failed to find World 116!
    World: 117, Players: 605, Members: True, PvP: False
    Failed to find World 118!
    Failed to find World 119!
    Failed to find World 120!
    Failed to find World 121!
    Failed to find World 122!
    World: 123, Players: 371, Members: False, PvP: False
    World: 124, Players: 1090, Members: True, PvP: True
    Failed to find World 125!
    Failed to find World 126!
    Failed to find World 127!
    Failed to find World 128!
    Failed to find World 129!
    Failed to find World 130!
    World: 131, Players: 709, Members: True, PvP: False
    World: 132, Players: 708, Members: True, PvP: False
    Failed to find World 133!
    Failed to find World 134!
    Failed to find World 135!
    Failed to find World 136!
    Failed to find World 137!
    World: 138, Players: 596, Members: True, PvP: False
    Failed to find World 139!
    Failed to find World 140!
    Failed to find World 141!
    Failed to find World 142!
    Failed to find World 143!
    Failed to find World 144!
    Failed to find World 145!
    Failed to find World 146!
    Failed to find World 147!
    World: 148, Players: 714, Members: True, PvP: False
    Failed to find World 149!
    Failed to find World 150!
    Failed to find World 151!
    Failed to find World 152!
    Failed to find World 153!
    World: 154, Players: 491, Members: False, PvP: False
    World: 155, Players: 490, Members: False, PvP: False
    World: 156, Players: 695, Members: True, PvP: False
    World: 157, Players: 712, Members: True, PvP: False
    World: 158, Players: 1412, Members: True, PvP: False
    World: 159, Players: 704, Members: True, PvP: False
    World: 160, Players: 659, Members: True, PvP: False
    World: 161, Players: 828, Members: False, PvP: False
    Failed to find World 162!
    Failed to find World 163!
    World: 164, Players: 1059, Members: True, PvP: False
    World: 165, Players: 383, Members: False, PvP: False
    World: 166, Players: 620, Members: True, PvP: False
    World: 167, Players: 387, Members: False, PvP: False
    Failed to find World 168!
    World: 169, Players: 379, Members: False, PvP: False
    World: 170, Players: 596, Members: True, PvP: False
    World: 171, Players: 386, Members: False, PvP: False

    I didn't watch it the whole time, but two things I did notice:

    1) If you have a world or two on Favorites (in my case, 77), it might confuse it with others (for example, it opened 77 instead of 7). Or, like it did, it might miss the world if told to switch to it

    2) The majority of the ones missed at the bottom appeared to have been missed because it was clicking on the Scroll Bar (and not moving it) instead of clicking on the area outside the scroll bar. Not sure if this would be a problem if I wasn't testing them all in order?

    Not sure why it missed a couple before 77...

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

    Default

    Quote Originally Posted by Runescapian View Post
    1) If you have a world or two on Favorites (in my case, 77), it might confuse it with others (for example, it opened 77 instead of 7).
    That's why its not working correctly for you. I have it calculated to use without favorites.
    (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.

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
  •