Results 1 to 15 of 15

Thread: Fix for the use of WorldInfo

  1. #1
    Join Date
    Jul 2011
    Location
    /home/litoris
    Posts
    2,226
    Mentioned
    0 Post(s)
    Quoted
    159 Post(s)

    Thumbs up Fix for the use of WorldInfo

    Simba Code:
    WorldInfo: TVariantArray;       // * [Members {Boolean}, World {Integer}, PVP {Boolean}]
    This is a piece of the players record that is rarely used, but is very useful and should be actually a regular option in every script. I added it to my miner in its last update, but my script wouldn't log into the specified world even though I had set up the array correctly. Then, I decided to check out the code, only to see the following:
    Simba Code:
    case Length(Players[CurrentPlayer].WorldInfo) of
        2: SelectWorld(Players[CurrentPlayer].WorldInfo[1]);
        3: begin
             if (Players[CurrentPlayer].WorldInfo[0]) then
               B := True
             else
               B := False;
             if (Players[CurrentPlayer].WorldInfo[2]) then
               BB := True
             else
               BB := False;
               SelectWorld(RandomWorld(B, BB));
    Here, you can see that if there is no specified info for PVP in WorldInfo, it automatically logs into the world as it should. BUT, if the array is complete, it just logs into a random world with the given properties! So, I came up with a fix for it:
    Simba Code:
    case Length(Players[CurrentPlayer].WorldInfo) of
        2: SelectWorld(Players[CurrentPlayer].WorldInfo[1]);
        3: begin
           {  if (Players[CurrentPlayer].WorldInfo[0]) then
               B := True
             else
               B := False;
             if (Players[CurrentPlayer].WorldInfo[2]) then
               BB := True
             else
               BB := False;}
    //i moved this part of the code somewhere up there
             if (WorldArray[BBB].PVP = BB) and  (WorldArray[BBB].Members = B) then  
    //BBB is an integer, it is equal to Players[CurrentPlayer].WorldInfo[1]
               SelectWorld(BBB)
             else
               SelectWorld(RandomWorld(B, BB));
    With my edits, now it checks whether the world we want fits our description, and if it does, it logs into the world properly. If the user falsely stated that a world is P2P, when it is actually F2P, it will login to a random P2P world, and it will do the same sort of fix for the PVP situation.
    I sent a pull request, see it here.

    Would be nice if someone could test it. I only tested whether it compiles, it should work in theory.
    Miner & Urn Crafter & 07 Chicken Killer
    SPS BlindWalk Tutorial

    Working on: Nothing

    teacher in every art, brought the fire that hath proved to mortals a means to mighty ends

  2. #2
    Join Date
    Dec 2011
    Location
    Nj
    Posts
    2,341
    Mentioned
    1 Post(s)
    Quoted
    18 Post(s)

    Default

    Very Nice!

    Looks very nice, Il try this one out later.

    For the basics of the basics of pascal, try my TuT. ||Photoshop Editing ||MapleResourceDung Script || Book a flight! BuySellTrip

  3. #3
    Join Date
    Jul 2011
    Location
    /home/litoris
    Posts
    2,226
    Mentioned
    0 Post(s)
    Quoted
    159 Post(s)

    Default

    Bump! Coh3n commented on the code, asking about the weird way in which B and BB are defined. They are like that because some dev thought it was a good idea back then, possibly to avoid any errors? I don't know, but the code works as it is.
    Miner & Urn Crafter & 07 Chicken Killer
    SPS BlindWalk Tutorial

    Working on: Nothing

    teacher in every art, brought the fire that hath proved to mortals a means to mighty ends

  4. #4
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    You should check for Length of WorldInfo before continuing with the if..then check.
    If WorldInfo isn't assigned (most scripts don't) it will result in out of ranged error.

    http://villavu.com/forum/showthread.php?t=91532
    http://villavu.com/forum/showthread.php?t=91531

    For people looking for a quick fix:
    http://villavu.com/forum/showpost.ph...36&postcount=3

    OR

    https://github.com/SRL/SRL-5/pull/95

  5. #5
    Join Date
    Nov 2008
    Location
    Norway, Alesund
    Posts
    924
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    You should check for Length of WorldInfo before continuing with the if..then check.
    If WorldInfo isn't declared (most scripts don't) it will result in out of ranged error.
    Can you be more specific with that?

    Like you probably noticed. I learning things. it's quite complicated for now and I'm not satisfied with quick fix only i need to know how to

  6. #6
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    if (Players[CurrentPlayer].WorldInfo[0]) then

    Is asking for the first value out of the array WorldInfo, but what if there isn't such an array? Cause SetLength was never run nor did some code pushed an other array in it.
    Working on: Tithe Farmer

  7. #7
    Join Date
    Nov 2008
    Location
    Norway, Alesund
    Posts
    924
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    if (Players[CurrentPlayer].WorldInfo[0]) then

    Is asking for the first value out of the array WorldInfo, but what if there isn't such an array? Cause SetLength was never run nor did some code pushed an other array in it.
    so if i understand correctly it check or is set world array at DeclarePlayers
    like that
    Simba Code:
    Procedure DeclarePlayers;
    Begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
      With Players[CurrentPlayer] Do
      Begin
        Name        := '';
        Pass        := '';
        Pin         := '';
        WorldInfo   := [64,79];// like here
        BoxRewards  := ['Coins', 'oins'];
        Active      := True;
      End;
    End;
    '

    and your example simply checks or here is 1 array item for worldinfo of current player
    Simba Code:
    if (Players[CurrentPlayer].WorldInfo[0]) then

    but again, if i use it only at DeclarePlayersm where should i put that if sentence?

    Or it will be included at second/new srl update login.simba? and I should not be worried about it?

  8. #8
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    You don't have to put that if sentence in your script, it is handled in LoginPlayer (within the SRL include), which is why when it comes across the Boolean check an out of range error is thrown off in that file.

    Also you shouldn't assign 2 integers:
    [Members {Boolean}, World {Integer}, PVP {Boolean}]
    if you want it to select a specific world, just do
    [true, 64].
    With my new fix it can be even easier, just [64].
    Refer to https://github.com/SRL/SRL-5/pull/95 for explanation.

  9. #9
    Join Date
    Jul 2011
    Location
    /home/litoris
    Posts
    2,226
    Mentioned
    0 Post(s)
    Quoted
    159 Post(s)

    Default

    Oh I see, thanks for the fix.
    Miner & Urn Crafter & 07 Chicken Killer
    SPS BlindWalk Tutorial

    Working on: Nothing

    teacher in every art, brought the fire that hath proved to mortals a means to mighty ends

  10. #10
    Join Date
    Jan 2012
    Posts
    369
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default

    Players[0].WorldInfo := [True, -1, False]; - Is currently not working with the current fix.

    -1 Should make the script look for a random world- It would be nice if -1 compatibility could be put back in.

    I for now implemented the old version of LoginPlayer.

  11. #11
    Join Date
    Jul 2011
    Location
    /home/litoris
    Posts
    2,226
    Mentioned
    0 Post(s)
    Quoted
    159 Post(s)

    Default

    Quote Originally Posted by speedster View Post
    Players[0].WorldInfo := [True, -1, False]; - Is currently not working with the current fix.

    -1 Should make the script look for a random world- It would be nice if -1 compatibility could be put back in.

    I for now implemented the old version of LoginPlayer.
    There was never a such functionality- it was jsut that when you had an array length of 3, it automatically gave you a random world, whether you ahd specified a world or not.
    Not having the WorldInfo there should do the same, just set Players.Members to True.
    Miner & Urn Crafter & 07 Chicken Killer
    SPS BlindWalk Tutorial

    Working on: Nothing

    teacher in every art, brought the fire that hath proved to mortals a means to mighty ends

  12. #12
    Join Date
    Jan 2012
    Posts
    369
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default

    Are you kidding me, yes there was. I have been using -1 since for ever.

    Let me paste the old function which supports -1 and works.

    Code:
    (*
    LoginPLayer
    ~~~~~~~~~~~
    
    .. code-block:: pascal
    
        function LoginPlayer: Boolean;
    
    Logs in the Player[CurrentPlayer]. Detects most Client Login Errors
    
    .. note::
    
        by SRL Dev Team
    
    Example:
    
    .. code-block:: pascal
    
        if (not LoggedIn()) then
        begin
          WriteLn('Error: Not Logged In! Fixing');
          LoginPlayer();
        end;
    
    *)
    function LoginPlayer: Boolean;
    var
      RetryLogin, B, BB: Boolean;
      Actions: TVariantArray;
      T, Attempts: LongInt;
    label
      ProcStart;
    begin
      ProcStart:
      //Writeln('1');
      if (not (Result)) then    {Check if Logged in}
        Result := LoggedIn;
      //Writeln('2');
      if (Result) then
      begin
        Result := True;
        AddToSRLLog('Current player: ' + Capitalize(Players[CurrentPlayer].Name));
        SRL_ExitedSquealOfFortune := false;
        PlayerStartTime := GetSystemTime; // PlayerStartTime
        if (SRL_Procs[srl_OnLogIn] <> nil) then
          SRL_Procs[srl_OnLogIn]();
    
        Exit;
      end;
      //Writeln('4');
      if (not (LoginPlayerToLob)) then    {Get to lobby screen}
        Exit;
        //Writeln('5');
      Wait(500 + Random(500));
                               {World switching}
      if (Length(Players[CurrentPlayer].WorldInfo) > 0) then
        if (Players[CurrentPlayer].WorldInfo[0]) then
          Players[CurrentPlayer].Member := True
        else
          Players[CurrentPlayer].Member := False;
    
      if (WorldSwitcherEnabled) then
        if (Length(Players[CurrentPlayer].WorldInfo) < 1) then
          Players[CurrentPlayer].WorldInfo := [Players[CurrentPlayer].Member, 0, AllowPVP];
    
      case Length(Players[CurrentPlayer].WorldInfo) of
        2: SelectWorld(Players[CurrentPlayer].WorldInfo[1]);
        3: begin
             if (Players[CurrentPlayer].WorldInfo[0]) then
               B := True
             else
               B := False;
             if (Players[CurrentPlayer].WorldInfo[2]) then
               BB := True
             else
               BB := False;
             SelectWorld(RandomWorld(B, BB));
           end;
      end;
                              {Click Here to Play}
    
      if (LobbyScreen) then
        MouseBox(270, 450, 490, 470, mouse_left);
    
                                {Check responses}
    
      T := GetSystemTime;
      repeat
    
        SetLength(Actions, 0);
        if ((GetSystemTime - T) > 60000) then
          Actions :=       ['One minute has passed...  Debug: ' + ToStr(CountColor(LOGIN_TEXTCOLOUR, 260, 140, 510, 400)),                    0,     0,  'NextPlayer',   'Login Failed']
        else
        case (CountColor(LOGIN_TEXTCOLOUR, 260, 140, 510, 400)) of //text colour points
                            // WriteLn Error                          Wait for   Retrys  Action     Player[CurrentPlayer].Loc
           364: Actions := ['Error Connecting.',                       20000,     9,  'Terminate',    'Error Connecting'];
           850: Actions := ['You need skill total of 1000.',               0,     9,  'PlayerTrue',   '1000 skill club'];
          1028: Actions := ['You are standing in a members-only area.',    0,     1,  'PlayerFalse',  'In Mems-Only Area'];
          1239: Actions := ['Not a Members Account',                       0,     1,  'PlayerFalse',  'Non-member'];
    	     777: Actions := ['Login limit exceeded.',                       0,     10, '',             'Waiting for login.'];
           951: Actions := ['Your account is already logged in',        5000,     5,  'PlayerTrue',   'Already logged in'];
           591: Actions := ['Client token changed.',                       0,     0,    'RSUpdate',   'Client Token Changed'];
          1606: Actions := ['Game session expired.',                       0,     0,    'RSUpdate',   'Session Expired'];
            -1: Actions := ['You need skill total of 1500.',               0,     9,  'PlayerTrue',   '1500 skill club'];
            -1: Actions := ['You need 20 combat for PvP',                  0,     1,  'PlayerFalse',  'PvP warning'];
        end;
    
        if (CountColor(clWhite, 415, 336, 476, 356) = 82) then // HRW login button white colour points
        begin
          Wait(RandomRange(500, 1000));
          if (Length(Players[CurrentPlayer].WorldInfo) > 2) then
          begin
            if (Players[CurrentPlayer].WorldInfo[2]) then
              MouseBox(391, 361, 498, 383, mouse_left)
            else begin
              MouseBox(263, 362, 372, 383, mouse_left);
              Players[CurrentPlayer].WorldInfo := [False, 0, AllowPVP];
              RetryLogin := True;
              Break;
            end;
          end
          else
            if (AllowPVP) then
              MouseBox(391, 361, 498, 383, mouse_left)
            else
              MouseBox(263, 362, 372, 383, mouse_left);
          Wait(3000 + Random(2000));
          RetryLogin := true;
        end;
    
                                 {Respond}
    
        if (Length(Actions) > 0) then
        begin
          WriteLn(Actions[0]);
          Wait(Actions[1] + Random(100));
          if (Actions[2] <> 0) then
            if (Attempts < Actions[2]) or (Actions[2] = -1) then
            begin
              case Actions[0] of
                'You are standing in a members-only area.': begin
                                                              Players[CurrentPlayer].Member := True;
                                                              Players[CurrentPlayer].WorldInfo := [True, 0, AllowPVP];
                                                            end;
                'You need 20 combat for PvP': Players[CurrentPlayer].WorldInfo := [Players[CurrentPlayer].Member, 0, False];
                'Not a Members Account': begin
                                           Players[CurrentPlayer].Member := False;
                                           Players[CurrentPlayer].WorldInfo := [False, 0, AllowPVP];
                                         end;
    		       	'Login limit exceeded.': begin
    											                 Writeln('Runescape is lagging or we''re logged in too many times.  Keep trying!');
                                           Players[CurrentPlayer].WorldInfo := [players[currentPlayer].member, 0, AllowPVP];
                                           Wait(5000+Random(10000));
    											               end;
                'You need skill total of 1000.': players[currentPlayer].worldInfo := [players[currentPlayer].member, 0, allowPVP];
              end;
              RetryLogin := True;
              Wait(2000 + Random(1000));
              Break;
            end;
          if (Actions[4] <> '') then
            Players[CurrentPlayer].Loc := Actions[4];
          case Actions[3] of
            'PlayerFalse': NextPlayer(False);
            'PlayerTrue':
              begin
                LeaveLobby();
                NextPlayer(True);
              end;
            'Terminate': TerminateScript;
            'RSUpdate':
              begin
                wait(randomRange(1000, 1500));
                typeByte(VK_ESCAPE);
                leaveLobby();
    
                if (SRL_Procs[srl_OnRSUpdate] <> nil) then
                begin
                  SRL_Procs[srl_OnRSUpdate]();
                  Exit;
                end;
                Writeln('Runescape has been updated! Please restart Simba.');
                TerminateScript;
              end;
          end;
          Exit;
        end;
        Wait(100);
        Result := (LoggedIn);
      until (Result);
    
                         {Back to lobby screen if needed}
    
      if (RetryLogin) then
      begin
        RetryLogin := False;
        Inc(Attempts);
        goto ProcStart;
      end;
    
                          {Set player start time ect...}
    
      if (Result) then
        goto ProcStart;
    
    end;
    Last edited by speedster; 10-27-2012 at 07:34 PM.

  13. #13
    Join Date
    Jul 2011
    Location
    /home/litoris
    Posts
    2,226
    Mentioned
    0 Post(s)
    Quoted
    159 Post(s)

    Default

    Quote Originally Posted by speedster View Post
    Are you kidding me, yes there was. I have been using -1 since for ever.
    You could put -45 or 3 there and would work the same. Check the code up there, nothing specific for -1.

    This version isn'T live anyway, riwu made a different version that solved the other problems.
    Miner & Urn Crafter & 07 Chicken Killer
    SPS BlindWalk Tutorial

    Working on: Nothing

    teacher in every art, brought the fire that hath proved to mortals a means to mighty ends

  14. #14
    Join Date
    Jan 2012
    Posts
    369
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default

    Putting 3 there logs me in world 3 and putting -45 would search for the world -45.

    I still didn't identify which part sees the negative and looks for a random world.

  15. #15
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by speedster View Post
    Putting 3 there logs me in world 3 and putting -45 would search for the world -45.

    I still didn't identify which part sees the negative and looks for a random world.
    Ok, if you want a random world, why don't just leave the WorldInfo array empty? It will just press Log in which will be a random world.

    Also like litoris mentioned the previous code is not right. If you read the code, when the Length of array is 3, all it does is to select a random world (which is pointless as mentioned above) based on WorldInfo[0] and [2], which means it ignores the world you provided completely. You can try key in something like [True, 1337, false], and it will still get you to a random world. In that case, what's the point of it being there then?

    Thanks for the suggestion though, i'll send a fix to check for [1] to ensure that the world provided is within sensible range, otherwise it will just log in directly (which should get you to a random world)

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
  •