SRL Archive - OSR Help

Help me discover the mystery of the messed up withdrawing from bank


Wardancer

2012-12-03 20:42:23

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:

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.

neeger

2012-12-03 21:22:05

NVM,
Just describe what it should do, I'll try to fix it


EDIT: Or maybe if it banks all after withdrawing then maybe WaitInvMinCount(28, 5000) doesn't work well, try replacing that line:
 if not WaitInvMinCount(28, 5000) then
To:
 if (not(WaitFunc(@InvFull, 50, 5000))) then 

Wardancer

2012-12-03 21:45:36

I've been using WaitInvCount in other scripts and had no issue with it. Also, if the problem was that, it'd start the function all over again, triggering the CloseBank (which doesn't happen).

Explaining what it does can be tricky but I'll try to:
1- Check if you're in the banking area and moving there if you aren't.
2- Searches for bankers once you're in the bank area.
3- Gets out of the loop once the bankscreen is open.
4- Depending on your energy level, it either withdraws only hides or 1 energy pot and hides.
5- Wait to see if your inventory is full.
6- Exit.

neeger

2012-12-03 22:36:32

Only problem I see is that WaitInvMinCount(28, 5000), because it starts it all over again(deposite, banking etc.).
It fails on chacking inv, just use invfull if it withdraws 28 itmes.

Sin

2012-12-03 23:08:07

Can you do a debug?

writeln('1');
sdfsdfnsdfn
writeln('2');

So we know where exactly it gets stuck.

Wardancer

2012-12-03 23:34:42

It's a very random problem. I tried a lot of writeln but it was a pain to figure out where it went wrong because of the randomness of it. I ended up rewriting the withdraw function to find out if it wasn't the include and I -think- that solved the problem. I was getting, somehow and randomly, some false negative. I'll post again later to tell if that definitely solved the issue or not.