SRL Archive - SRL Suggestions

WithdrawEx


NCDS

2010-09-30 23:28:11

Made it so it will wait until the 'Enter amount' screen pops up in Chat box to avoid mis-typing. Also made it actually search for the Withdraw-'amount', before just typing in the number.

Thread: http://villavu.com/forum/showthread.php?p=740278#post740278


{*******************************************************************************
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;

Do with it what you will.

Narcle

2010-10-01 03:48:47

The original one should have the wait for the screen anyways (its not there, will be added). My concern is the fact its not finding the 'Withdraw-14' when its there. Hopefully its a small spacing problem, if its text reading then ugg.

I don't like (CountColor(0, 250, 396, 307, 410) <> 161), its too precise. For longevity purposes I think a InRange would work better.

InRange(CountColor(0, 250, 396, 307, 410), 150, 170)

NCDS

2010-10-01 15:59:41

The one I posted on that other thread will search for the 'Withdraw-14' first, I just didn't think that's what you were talking about.

Here:

{*******************************************************************************
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;

It might be a little cleaner to just use a couple if..then's, but this was tested and worked.

NCDS

2010-10-04 14:11:48

Narcle, if you wouldn't mind looking at this again..?

Narcle

2010-10-04 16:42:46

From: NCDS
Narcle, if you wouldn't mind looking at this again..?


Sorry been busy this weekend. I'll check it out tonight / tomorrow properly.

NCDS

2010-10-04 16:48:55

From: Narcle
Sorry been busy this weekend. I'll check it out tonight / tomorrow properly.


Alright, it would certainly be shorter to turn the case into an if..then, because that way:

Result := WaitOptionMulti(['Withdraw-' + IntToStr(Amount), 'w-' + IntToStr(Amount)] , 300);
would only be called once as opposed to once in a case, and once after.

I can go ahead and change that if you agree with it.

Narcle

2010-10-04 22:31:51

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;