Results 1 to 5 of 5

Thread: Shorter code?

  1. #1
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Shorter code?

    I feel something fishy about this proc in my fishing bot (no pun intended) I know it can be shortened but don't know any way to shorten it anymore! Can somebody look at this and just tell me what to do to make it smaller?
    SCAR Code:
    {Setting 1 = Stay offline   Setting 2 = Log back on Setting 3 = nothing}
    procedure WaitR(reason: string; time, randomness, setting: integer; myantiban, randoms, mylogout, error: boolean);
    var
      waittime: integer;
    begin
      waittime := time + randomness;

      if (error) then Writeln('INFO: **Error** ' + reason + ': ' + IntToStr(waittime)) else
                                    Writeln('INFO: ' + reason + ': ' + IntToStr(waittime));
      if (myantiban) then AntiBan;
      if (randoms) then FindNormalRandoms;
      if (mylogout) then
      begin
        if (LoggedIn) then
        begin
          if (LogOut) then Writeln('INFO: WaitR/ Logged out.');
        end else
        begin Writeln('INFO: **Error** Was already logged out!'); Exit; end;
      end;

      Wait(time+random(randomness));
      case (setting) of
      1: if (LoggedIn) then
         begin
           LogOut;
           TerminateScript;
         end else
         begin
          Writeln('INFO: WaitR/ Staying offline. Terminating.');
          LogOut;
          TerminateScript;
         end;
      2: begin LogInPlayer; Writeln('INFO: Logged back on.'); end;
      3: exit;
      end;
    end;

  2. #2
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    you can remove the 3 in the setting case,

    also, less lines doesnt make it faster.. standardized:
    SCAR Code:
    procedure WaitR(reason: string; time, randomness, setting: integer; myantiban, randoms, mylogout, error: boolean);
    var
      waittime: integer;
    begin
      waittime := time + randomness;
      if (error) then
        Writeln('INFO: **Error** ' + reason + ': ' + IntToStr(waittime))
      else
        Writeln('INFO: ' + reason + ': ' + IntToStr(waittime));
      if (myantiban) then
        AntiBan;
      if (randoms) then
        FindNormalRandoms;
      if (mylogout) then
      begin
        if (LoggedIn) then
        begin
          if (LogOut) then
            Writeln('INFO: WaitR/ Logged out.');
        end else
        begin
          Writeln('INFO: **Error** Was already logged out!');
          Exit;
        end;
      end;
      Wait(time+random(randomness));
      case (setting) of
        1: if (LoggedIn) then
             LogOut
           else
           begin
             Writeln('INFO: WaitR/ Staying offline. Terminating.');
             LogOut;
             TerminateScript;
           end;
        2:
        begin
          LogInPlayer;
          Writeln('INFO: Logged back on.');
        end;
      end;
    end;
    Last edited by Awkwardsaw; 05-16-2010 at 05:15 PM.
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  3. #3
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Awkwardsaw View Post
    you can remove the 3 in the setting case,

    also, less lines doesnt make it faster.. standardized:
    SCAR Code:
    procedure WaitR(reason: string; time, randomness, setting: integer; myantiban, randoms, mylogout, error: boolean);
    var
      waittime: integer;
    begin
      waittime := time + randomness;
      if (error) then
        Writeln('INFO: **Error** ' + reason + ': ' + IntToStr(waittime))
      else
        Writeln('INFO: ' + reason + ': ' + IntToStr(waittime));
      if (myantiban) then
        AntiBan;
      if (randoms) then
        FindNormalRandoms;
      if (mylogout) then
      begin
        if (LoggedIn) then
        begin
          if (LogOut) then
            Writeln('INFO: WaitR/ Logged out.');
        end else
        begin
          Writeln('INFO: **Error** Was already logged out!');
          Exit;
        end;
      end;
      Wait(time+random(randomness));
      case (setting) of
        1: if (LoggedIn) then
             LogOut
           else
           begin
             Writeln('INFO: WaitR/ Staying offline. Terminating.');
             LogOut;
             TerminateScript;
           end;
        2:
        begin
          LogInPlayer;
          Writeln('INFO: Logged back on.');
        end;
      end;
    end;
    It's not that i want to make it faster, i want to make it "neater"

  4. #4
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    It doesn't get much shorter than:

    SCAR Code:
    procedure WaitR(reason: string; time, randomness, setting: integer; myantiban, randoms, mylogout, error: boolean);
    begin
      if error then
        reason := reason + '**Error** ';
      Writeln('INFO: ' + reason + ': ' + IntToStr(time + randomness));
     
      if myantiban then
         AntiBan;
      if randoms then
        FindNormalRandoms;
      if mylogout then
        if (not LoggedIn) then
        begin
          Writeln('INFO: **Error** Was already logged out!');
          Exit;
        end
        else if LogOut then
          Writeln('INFO: WaitR/ Logged out.');

      Wait(time+random(randomness));
      case setting of
        1:  //Stay offline
          begin
            if (not LoggedIn) then
              Writeln('INFO: WaitR/ Staying offline. Terminating.');
            LogOut;
            TerminateScript;
          end;
        2:  //Log back on
          begin
            LogInPlayer;
            Writeln('INFO: Logged back on.');
          end;
        3: Exit; //nothing
      end;
    end;

  5. #5
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    ty even better!

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
  •