SRL Archive - Help and Support

Help with a function.. :(


Nava2

2008-09-29 08:32:12

This is from my newest script, but I won't post all the source as its well, going to be semi-closed I think! :D

ANYWAYS, here is the function that is giving me troubles I think:

{*******************************************************************************
procedure ClickPouchEx(Pouch, Option: String; Tol: Integer);
By: Psychor, Wizzup?, & Nava2
Description: Click Pouch
*******************************************************************************}

function ClickPouchEx(Pouch, Option: string) : Boolean;
var
x, y, i, PouchMark, Current, dtm: Integer;
b: Boolean;
begin
MarkTime(PouchMark);
Current := InvCount;
case LowerCase(Pouch) of
'1', 'small' : dtm := DTMFromString('78DA639CC0C0C050CB00068C108AA13A37844' +
'18711C2FF0F048C5D40460DAA1A180BC6679C0D24EA08A8E90512' +
'4D04D4CC2042CD242091875F0D0001860BD2');
'2', 'medium': dtm := DTMFromString('78DA63DCC3C0C050CB00068C108AA120D9874' +
'18711C2FF0F048C5B808C6A543530168CCF78940835DB81440B01' +
'35078950B31748E4E257030066E70CB2');
'3', 'large' : DTM := DTMFromString('78DA63EC666660B8CDC8800CAA728219D8813' +
'448F43F10303603D5DC425503918591401A64CE63026A6600D53C' +
'24A0661611764D06AAB944404D1750CD19026ADA806A2E40784C5' +
'031676B4306112435006BA81167');
'4', 'giant' : dtm := DTMFromString('78DA6314636060906140011971EE0C5C409A1' +
'188FF030123279021CD800618914820AD46841A0920A146408D24' +
'90E0C2AF060060CF061A');
else Exit;
end;
if FindDTM(dtm, x, y, MIX1, MIY1, MIX2, MIY2)then
begin
i := coordstoitem(x, y);
b := True;
case LowerCase(Option) of
'fill': MouseItem(i, True); //Mouse(x, y, 2, 2, True);
'empty': begin
MouseItem(i, False); //Mouse(x, y, 2, 2, False);
Wait(RandomRange(120, 150));
ChooseOption('mpty');
end;
'check': begin
MouseItem(i, False); //Mouse(x, y, 2, 2, False);
Wait(RandomRange(120, 150));
ChooseOption('heck');
end;
else b := False;
end;
end else
begin
SRL_Warn('FindPouch', 'Could not find Pouch ' + Pouch + ' in Inventory.', Warn_AllVersions);
Exit;
end;
FreeDTM(dtm);
if (not b) then Exit;
while (Current = InvCount) do
begin
Wait(100 + Random(50));
if (TimeFromMark(PouchMark) > 2500) then
Exit;
end;
Result := True;
end;

Here is its calling:

if Players[CurrentPlayer].Booleans[0] then
begin
Wait(RandomRange(50, 110));
if PouchArray[3] then
y := 3
else
y := 2;
for x := 0 to y do
begin
if x = 3 then
if OpenBankRef('eb') then
begin
Wait(RandomRange(100, 200));
WithdrawItem(RuneEssDTM, 'dtm', REIndex, 0, ['ure'], []);
Wait(RandomRange(200, 250));
CloseBank;
end;
if PouchArray[x] then
begin
if not ClickPouchEx(IntToStr(x), 'fill') then
Writeln('couldnt find pouch.');
if not FixPouches then
begin
Wait(RandomRange(80, 100));
FixPouches := FindBlackChatMessage('use');
end;
end;
end;
WithdrawItem(RuneEssDTM, 'dtm', REIndex, 0, ['ure'], []);
end;

So, yeah… It never finds the large pouch. Any questions, ask..

Narcle

2008-09-29 09:53:27

for x := 0 to y

if not ClickPouchEx(IntToStr(x), 'fill') then

That means x is 0, 1, 2, 3 I think you know where I'm going with this… x is never 4.
Try IntToStr(x+1) perhaps? ;)

Nava2

2008-09-29 15:11:31

Omg, thank you narcle. <3