Results 1 to 4 of 4

Thread: Resetting a variable...

  1. #1
    Join Date
    Dec 2011
    Posts
    170
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default Resetting a variable...

    Lets just start off by including the code:

    PHP Code:
    procedure Bank;
      var
      
    BankingAttemptsItemsinteger;

        
    begin
          MarkTime
    (Banking);
          
    Attempts := 0;
            if 
    not BankScreen then
              begin
                repeat
                  inc
    (Attempts);
                  
    Writeln('Attempting to open bank... Attempt: ' IntToStr(Attempts) + '...');
                  
    OpenBankChestEdge(SRL_BANK_SW);
                  
    Wait(randomRange(9001000));
                
    until ((BankScreen) or (Attempts>=3) or (TimeFromMark(Banking)>6000))
              
    end else
                  if 
    not (BankScreen) and (Attempts>=3then
                    begin
                      Writeln
    ('Failed opening bank after ' IntToStr(Attempts) + 'attempts... Closing...');
                      
    LogOut;
                      
    TerminateScript;
                    
    end else
    // Set attempts back to 0 for depositing
                
    Attempts := 0;
                  if (
    InvCount>1) or (InvFullthen
                    begin
                      repeat
                        Inc
    (Attempts);
                        
    Writeln('Depositing items... Attempt: ' IntToStr(Attempts) + '...');
                        
    Deposit(228False);
                        
    Wait(randomRange(9001000));
                      
    until ((InvCount<=1) or (Attempts>=3) or (TimeFromMark(Banking)>12000))
                      if (
    InvCount=0) or (Attempts>=3then
                        Writeln
    ('Failed depositing items after ' IntToStr(Attempts) + ' attempts (runes might have ran out/are missing)... Closing...');
                        
    LogOut;
                        
    TerminateScript;
                    
    end else
    // Set attempts back to 0 for withdrawing
                
    Attempts := 0;
                
    CheckTarget;
                  if (
    GetBankItemAmount(09)>=27then
                    begin
                      repeat
                        Inc
    (Attempts);
                        
    Items := (GetBankItemAmount(09));
                        
    Writeln(IntToStr(Items) + ' rings left... Last load... Attempt: ' IntToStr(Items) + '.');
                        
    Withdraw(,9Items);
                        
    Wait(randomRange(9001000));
                      
    until ((InvCount=Items) or (Attempts>=3) or (TimeFromMark(Banking)>20000))
                    
    end else
                      
    repeat
                        Inc
    (Attempts);
                        
    Writeln('Withdrawing items... Attempt: ' IntToStr(Attempts) + '...');
                        
    Withdraw(0927);
                        
    Wait(randomRange(9001000));
                      
    until ((InvCount=28) or (Attempts>=3) or (TimeFromMark(Banking)>20000))

        
    end
    It's heavily under construction and any ideas to make it simpler are welcome but I'm pretty sure the problem is that my Attempts := 0; in between loops won't reset the variable.
    This is why I suspect this:
    PHP Code:
    Attempting to open bank... Attempt1...
    Depositing items... Attempt2...
    Successfully executed
    As you see my repeats go until attempts>=3 so it just stops.
    It should correctly say Depositing items... Attempt: 1... obviously since it's the first attempt duh.

    Any help?

  2. #2
    Join Date
    Dec 2011
    Posts
    170
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    No help?
    Still haven't figured it out.

  3. #3
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Put the Attempts := 0; under the 'begin' but above 'repeat'

    Forum account issues? Please send me a PM

  4. #4
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by Justin View Post
    Put the Attempts := 0; under the 'begin' but above 'repeat'
    Just use this to reset a variable at any point in a script btw :P

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
  •