Results 1 to 8 of 8

Thread: Slimming my code.. Help please.

  1. #1
    Join Date
    Apr 2009
    Location
    California!
    Posts
    280
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Slimming my code.. Help please.

    Hey everyone, i wrote this script.. and i was wondering if there was a shorter, less-confusing way to write it. This script is basically saying, if you open the bank then end else, but if you can't open bank log out and log in and try again and if you still can't find it then login the next player.
    I don't know how to slim down this code. Any and all help is appreciated and you will get a nice little rep++ .

    Here's the script:
    SCAR Code:
    procedure BankOpen;
    begin
      if OpenBankQuiet(Bank) then
        Writeln('Found Bank.');
        Wait(500+random(300));
        end else
         if not OpenBankQuiet(Bank) then
           Writeln('Could not find bank, trying again');
           wait(200+random(200));
           Logout;
           wait(5000+random(2000));
           LoginPlayer;
           Setup;
         if OpenBankQuiet(Bank) then
           Writeln('Found Bank! :)');
           wait(500+random(300));
        if not OpenBankQuiet(Bank) then
           Writeln('Could not find bank... Exiting :(');
           wait(200+random(200));
           Logout;
           wait(300+random(200));
           NextPlayer(False);
    end;

    Thanks everyone. Once I get this done I can learn how to do the rest myself,
    ~Penguin
    Semi-active
    http://i44.tinypic.com/33vk9aq.jpg
    SELL AUTOED GOODS AT MID-MAX! DON'T LET PRICES FALL AND GIVE US LESS PROFIT. (Put this in your sig)

  2. #2
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Continue;

  3. #3
    Join Date
    Apr 2009
    Location
    California!
    Posts
    280
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Continue; ?
    Edit: Where would i put it in the sxript.
    ~Penguin
    Semi-active
    http://i44.tinypic.com/33vk9aq.jpg
    SELL AUTOED GOODS AT MID-MAX! DON'T LET PRICES FALL AND GIVE US LESS PROFIT. (Put this in your sig)

  4. #4
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yes it can be used to go to the top of a loop but you have no loop, didn't see that. You can make a label however.

  5. #5
    Join Date
    Apr 2009
    Location
    California!
    Posts
    280
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Still confused, can you show me how it would slim the script?
    Thanks
    Edit: Got it!! Thanks Da 0wner repped++
    Last edited by Mystic; 05-10-2009 at 10:22 AM.
    ~Penguin
    Semi-active
    http://i44.tinypic.com/33vk9aq.jpg
    SELL AUTOED GOODS AT MID-MAX! DON'T LET PRICES FALL AND GIVE US LESS PROFIT. (Put this in your sig)

  6. #6
    Join Date
    Dec 2008
    Location
    In a galaxy far, far away...
    Posts
    584
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Labels = Bad according to Wizzup? (Though you should only use when you NEED to skip a block of code in between destination, Your situation only needs a loop).

    Then again, Da 0wner pointed you in a very easy and quick direction

    You can do it like this to make it look good, and work pretty OK:

    SCAR Code:
    procedure BankOpen;
    var
      i, t: Integer;
    begin
      MarkTime(t);
      while(not(OpenBankQuiet(Bank))) do
      begin
        Writeln('Could not find bank, trying again');
        wait(200 + Random(200));
        Logout;
        Wait(5000 + Random(2000));
        Inc(i);
        if (i > 1) then
        begin
          Writeln('Could not find bank... Exiting :(');
          NextPlayer(False);
          i := 0;
        end else
        begin
          Writeln('Could not find bank, trying again');
          LoginPlayer;
        end;
        Setup;
        if (TimeFromMark(t) > 20000) then Break;
      end;
      if OpenBankQuiet(Bank) then
        Writeln('Found Bank.');
      Wait(500+random(300));
    end;



    ~NS

  7. #7
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    *You should never use labels in a high level language. Bad, bad, bad.

    If you want to have good multiplayer in your script (ie, quality multiplayer that won't get you any no's on your member poll), don't go to the next player quite yet. Just log out if you can't find the bank, and leave the next player until later.

    Here's a quick example:

    SCAR Code:
    procedure MainLoop;
    begin
      repeat
        WalkSomewhere;
        DoSomething;
        WalkToBank;
        BankEverything;
        if(not(LoggedIn)) then
          NextPlayer(false);
      until(NoPlayersActive);
    end;
    Interested in C# and Electrical Engineering? This might interest you.

  8. #8
    Join Date
    Apr 2009
    Location
    California!
    Posts
    280
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Alright Thanks for your help everyone!
    ~Penguin
    Semi-active
    http://i44.tinypic.com/33vk9aq.jpg
    SELL AUTOED GOODS AT MID-MAX! DON'T LET PRICES FALL AND GIVE US LESS PROFIT. (Put this in your sig)

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
  •