I have had an issue with a procedure for a few days now. The more I think about it and the less I understand what goes wrong. Maybe one of you can help me see more clearly. The issue is that my banking procedure has a tendency to withdraw and then deposit all before withdrawing once more, at random. It proceeds to the next functions and procedures of the script after that usually. Sometimes, it gets into an endless loop of withdraws and deposit all. Other time, it just happens once in 10 minutes with everything else working fine. Either way, I'm clueless about what might cause it. I added a "CloseBank" at the beginning of the procedure to find out if it's caused by the procedure being called twice and I found out that it isn't so I know it's a problem within the procedure, but I just can't see what could cause it.
Here is the procedure:
Simba Code:
procedure BankEr;
var
x, y : Integer;
s : String;
begin
if BankScreen then
CloseBank;
repeat
if not InBankArea then
begin
MiddleToBank;
WalkToBank;
LowPlaceToBank;
end;
if (FindObject(x, y, AK_Bank, MSX1, MSY1, MSX2, MSY2)) then
begin
Clickmouse2(false);
if not WaitOption('Bank B', 500) then
BankEr;
WaitFunc(@BankScreen, 10, 5000);
end;
until BankScreen;
DepositAll;
if GetMMLevels('run', s) < 60 then
begin
Withdraw(0, 0, 1);
Withdraw(1, 0, 28);
end else
begin
Withdraw(1,0,28);
end;
if not WaitInvMinCount(28, 5000) then
BankEr;
end;
Thank you for your time.