Pascal Code:
Function MSI_Deposit(Items, Amount: TIntegerArray) : Boolean;
Var ATPA2 : Array Of TPointArray; //The length is the same as items.colors
ATPA : T2DPointArray;
I, BX, BY, II, DX, DY, XX, YY, Tol : Integer;
BitmapCheck, TextCheck, DTMCheck : Boolean;
TB : TBox;
Begin
if (not LoggedIn) then
Exit;
if (Length(Amount) <= 0) then
begin
SetLength(Amount, Length(Items));
for i := 0 to High(Amount) do
Amount[i] := 28;
end;
If Not WaitFunc(@BankScreen, 70, 1300) Then //Just in case
Exit
Else begin
MSI_LoadItems(Items);
For I := 0 To High(Items) Do
Begin
Tol := 0;
Repeat
BitmapCheck := FindBitmapToleranceIn(MSI_Item[Items[I]].BMP, BX, BY, MIX1, MIY1, MIX2, MIY2, Tol);
IncEx(Tol, INC_TOL);
Until(BitmapCheck) Or (Tol >= MAX_TOL);
If Not BitmapCheck Then
Begin
SetArrayLength(ATPA2, High(MSI_Item[Items[I]].Colors)+1)
For II := 0 To High(MSI_Item[Items[I]].Colors) Do
FindColorsTolerance(ATPA2[II], MSI_Item[Items[I]].Colors[II], MIX1, MIY1, MIX2, MIY2, 15);
ATPA2[0] := MergeATPA(ATPA2);
ATPA := SplitTPA(ATPA2[0], 5);
For II := 0 To High(ATPA) Do
Begin
TB := IntToBox(ATPA[II][0].x - 50, ATPA[II][0].y - 50,
ATPA[II][0].x + 43, ATPA[II][0].y + 44);
DTMCheck := DTMRotated(MSI_Item[Items[I]].DTM, DX, DY, TB.x1, TB.y1, TB.x2, TB.y2);
MMouse(DX, DY, 2, 3);
TextCheck := WaitUpTextMulti(MSI_Item[Items[I]].UpText, 150+Random(30));
If TextCheck Then Break;
End;
End;
If BitmapCheck Or TextCheck Then
Begin
If BX + BY > 0 Then
MMouse(BX, BY, 2, 3);
TextCheck := WaitUpTextMulti(MSI_Item[Items[I]].UpText, 1200);
GetMousePos(XX, YY);
Result := TextCheck;
If Result Then
Begin
Mouse(XX, YY, 0, 0, False);
If Amount[I] >= 28 Then
Result := WaitOption('-All', 1200);
If InIntArray([1, 5, 10], Amount[I]) Then
Result := WaitOption('-'+IntToStr(Amount[I]), 1200)
Else
Begin
If WaitOption('-X', 900) Then
If WaitColor(254, 401, ClBlack, 0, 1200) Then
TypeSend(IntToStr(Amount[I]));
Result := True;
End;
If Result Then
MSI_Debug('MSI_Deposit', 'Deposited Amount '+IntToStr(Amount[I])+
' Of Item : ''' +MSI_Item[Items[I]].Name+'''', DEBUG_SMALL_DETAILS);
End;
End;
End;
MSI_FreeItemArray(Items); //if you comment out this line, the error no longer occurs.
end;
End;
Notice the comment on the MSI_FreeItemArray line. Since the item was loaded, deposited and the function returned true, I don't see why there would be an error.