SRL Archive - Bugs

Withdraw in Bank.scar can't find number, types too soon


ForgotMyName

2010-09-30 20:52:05

I have a script I originally wrote for SCAR/SRL and am currently running it in Simba/SRL. A new error has popped up in the transition. When I withdraw 14 items, it fails to recognize the selection option for withdraw-14 and instead goes straight to withdraw-x. (I don't know why.) Then it enters the number 14 very quickly, so that maybe 10% of the time the 1 or maybe the whole 14 will end up in the chat line before the dialog has even popped up. My computer is a bit weak, for sure, but I think this is still a bug. Maybe these sorts of functions should check for the window before they start typing into it.

Thanks.

i luffs yeww

2010-09-30 22:49:22

Usually it's up to the user to implement these things.

NCDS

2010-09-30 23:04:17

Like i luffs yeww said, SRL is not meant to be a 'high level' include. Meaning it's there more so to act as a 'base' for you to build off of and customize for your own needs.

Remember, you can always copy/paste the function into your script, change the name, and edit it to fit your needs. Just don't forget to give credit where it's due ;)

Narcle

2010-09-30 23:08:28

From: i luffs yeww
Usually it's up to the user to implement these things.


He is actually talking about the function itself, WithDraw in bank.scar does this. Take a look.

I've had reports about this bug in my Smelter thread, just haven't gotten to testing it.

NCDS

2010-09-30 23:16:56

I apologize, I misunderstood what you were saying at first as well.

{*******************************************************************************
function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;
By: Starblaster100, Town, Wizzup? and Narcle, small fixes by r!ch!e & EvilChicken!
Description: Withdraws Amount at Column/Row.
*******************************************************************************}
function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;
var
BBox: TBox;
X, Y: Integer;
begin
Result := False;
FixBank;
FixBankTab;

BBox := BankIndexToMSBox(BankPointToBankIndex(Point(Col, Row)));
GetMousePos(X, Y);
if (not PointInBox(Point(X, Y), BBox)) then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, 3);

if (Length(Uptexts) > 0) then
if (not WaitUptextMulti(Uptexts, 500)) then
Exit;

ClickMouse2(Amount = 1);
if (Amount = 1) then
begin
Result := True;
Wait(RandomRange(250, 550));
Exit;
end;

case (Amount) of
0: Result := WaitOptionMulti(['Withdraw-All', 'w-A'], 300);
5, 10: Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);
else
Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);
end;

if (not (Result)) then
Result := WaitOptionMulti(['Withdraw-X', 'w-X'], 300);

if (Result) and (not InIntArray([0, 1, 5, 10], Amount)) then
begin
x := GetSystemTime + 5000;
while (x >= GetSystemTime) and (not (InRange(CountColor(0, 250, 396, 307, 410), 155, 165))) do
Wait(50);
Wait(RandomRange(500, 1250));
TypeSend(IntToStr(Amount));
end;
end;
Includes a wait until the 'amount' screen has popped up and also will search for the custom amount before typing in an amount.

Could be just as easily done by finding the text if you wanted to do that instead.

Bad Boy JH

2010-10-03 06:16:39

Only issue I see is if it fails to Choose "withdraw All", then it will use Withdraw-X and then enter 0, which a person wouldn't do….

NCDS

2010-10-03 17:16:32

There :)

{*******************************************************************************
function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;
By: Starblaster100, Town, Wizzup? and Narcle, small fixes by r!ch!e & EvilChicken!
Description: Withdraws Amount at Column/Row.
*******************************************************************************}
function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;
var
BBox: TBox;
X, Y: Integer;
begin
Result := False;
FixBank;
FixBankTab;

BBox := BankIndexToMSBox(BankPointToBankIndex(Point(Col, Row)));
GetMousePos(X, Y);
if (not PointInBox(Point(X, Y), BBox)) then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, 3);

if (Length(Uptexts) > 0) then
if (not WaitUptextMulti(Uptexts, 500)) then
Exit;

ClickMouse2(Amount = 1);
if (Amount = 1) then
begin
Result := True;
Wait(RandomRange(250, 550));
Exit;
end;

case (Amount) of
0: Result := WaitOptionMulti(['Withdraw-All', 'w-A'], 300);
5, 10: Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);
else
Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);
end;

if (not (Result)) and (Amount > 0) then
Result := WaitOptionMulti(['Withdraw-X', 'w-X'], 300);

if (Result) and (not InIntArray([0, 1, 5, 10], Amount)) then
begin
x := GetSystemTime + 5000;
while (x >= GetSystemTime) and (not (InRange(CountColor(0, 250, 396, 307, 410), 155, 165))) do
Wait(50);
Wait(RandomRange(500, 1250));
TypeSend(IntToStr(Amount));
end;
end;

Bad Boy JH

2010-10-04 18:58:10

Lets just run a desk check of this parrt of the code, with the amount value "9" (just an amount thats not 0, 1, 5, or 10
  case (Amount) of
0: Result := WaitOptionMulti(['Withdraw-All', 'w-A'], 300);
5, 10: Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);
else
Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);
end;

//lets assum at this point, that it picked withdraw-9, so result is true

if (not (Result)) and (Amount > 0) then // result is true, this won't run
Result := WaitOptionMulti(['Withdraw-X', 'w-X'], 300);

if (Result) and (not InIntArray([0, 1, 5, 10], Amount)) then //result IS true, and therefore this WILL RUN, sending the keys, to a box that doesn't exist...
begin
x := GetSystemTime + 5000;
while (x >= GetSystemTime) and (not (InRange(CountColor(0, 250, 396, 307, 410), 155, 165))) do
Wait(50);
Wait(RandomRange(500, 1250));
TypeSend(IntToStr(Amount));
end;
end;

here is a fix for it…

function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;
var
BBox: TBox;
X, Y: Integer;
begin
Result := False;
FixBank;
FixBankTab;

BBox := BankIndexToMSBox(BankPointToBankIndex(Point(Col, Row)));
GetMousePos(X, Y);
if (not PointInBox(Point(X, Y), BBox)) then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, 3);

if (Length(Uptexts) > 0) then
if (not WaitUptextMulti(Uptexts, 500)) then
Exit;

ClickMouse2(Amount = 1);
if (Amount = 1) then
begin
Result := True;
Wait(RandomRange(250, 550));
Exit;
end;

case (Amount) of
0: Result := WaitOptionMulti(['Withdraw-All', 'w-A'], 300);
5, 10: Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);
else
Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);
end;

if (not (Result)) and (Amount > 0) then
begin
if WaitOptionMulti(['Withdraw-X', 'w-X'], 300) then
begin
Result := True;
x := GetSystemTime + 5000;
while (x >= GetSystemTime) and (not (InRange(CountColor(0, 250, 396, 307, 410), 155, 165))) do
Wait(50);
Wait(RandomRange(500, 1250));
TypeSend(IntToStr(Amount));
end;
end;
end;
(pardon if I have messed standards up there, but I did that in the textbox)

NCDS

2010-10-04 19:07:48

Or you could just do this:

if (not (Result)) and (Amount > 0) then
Result := WaitOptionMulti(['Withdraw-X', 'w-X'], 300)
else
Exit;

But I don't see anything wrong with what you did. Wierd that it didn't do that when I tested, or perhaps I just didn't notice.

Narcle

2010-10-04 22:27:19

This is what I committed. If the number isn't in ChooseOption it'll click again and Withdraw-X. This is how it was working before. This way on repeating scripts Withdraw-14 will be listed and it'll click this instead of X.

function WithdrawEx(Col, Row, Amount: Integer; Uptexts: TStringArray): Boolean;
var
BBox: TBox;
X, Y: Integer;
begin
Result := False;
FixBank;
FixBankTab;

BBox := BankIndexToMSBox(BankPointToBankIndex(Point(Col, Row)));
GetMousePos(X, Y);
if (not PointInBox(Point(X, Y), BBox)) then
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, 3);

if (Length(Uptexts) > 0) then
if (not WaitUptextMulti(Uptexts, 500)) then
Exit;

ClickMouse2(Amount = 1);
if (Amount = 1) then
begin
Result := True;
Wait(RandomRange(250, 550));
Exit;
end;

if (Amount = 0) then
Result := WaitOptionMulti(['Withdraw-All', 'w-A'], 300)
else
Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);

if (not (Result)) and (Amount > 0) then
begin
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, 2);
if WaitOptionMulti(['Withdraw-X', 'w-X'], 500) then
begin
X := GetSystemTime + 10000;
while (X >= GetSystemTime) and (not (InRange(CountColor(0, 250, 396, 307, 410), 155, 165))) do
Wait(50);
Wait(RandomRange(75, 400));
TypeSend(IntToStr(Amount));
Result := True;
end;
end;
end;