Log in

View Full Version : Broken Waitfunction? Or am I using it incorrectly?



Hazzah
04-01-2012, 03:27 AM
Error: Exception: The given DTM Index[146] doesn't exist at line 819
The following DTMs were not freed: [SRL - Lamp bitmap, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]


I get this when using the following code, and I do have the DTM defined withing the procedure so Im not thinking that's the error.

If (FindNPCChatText('cert', Nothing)) Then
Begin
TypeSendEx('1',False);
Wait(RandomRange(1005,1050));
TypeSendEx('26',True);
WaitFindDTM(LogToBurnDTM,x,y,RandomRange(9000,1000 0));
End;

Brandon
04-01-2012, 03:44 AM
Waiting has nothing to do with it.. I don't see you freeing the DTM anywhere in the above code.. You declare a DTM, then you have to free it when it's not going to be used.



var
Meh: Integer;
begin
Meh:= DtmFromString('fdsgadsgsdgwsgsdhgsdghsdfhgsd');

if (WaitFindDTM(Meh, X, Y, 1000)) then
//do whatever with X, Y..

FreeDTM(Meh);
end;

Hazzah
04-01-2012, 12:26 PM
Function FindButler:Boolean;
Var
NotedLogDTM,DButlerDTM,LogToBurnDTM,X,Y,T: Integer;
Begin
LogToBurnDTM:= DTMFromString('m1gAAAHic42JgYHBiYmDwAWI/IA6Ess2B2BGIzYDYGohdgZiTkYHhH1A9E5DmAmIBIBYCYhEgZg diBqi8ux4XSBUGNlBQQOH/ZyAOMBKJEQAARvoHJA==');
NotedLogDTM := DTMFromString('mAAEAAHic42FgYOAFYhYgZmaAABDNBsTcQM wPxCJALArEwlDMClUH0sMJVccLxTxQPgdUnhGInbRBqpiIxv8Z SAOMJGJkAACCbgKF');
DButlerDTM := DTMFromString('mQwAAAHicY2ZgYNBkhGAtIJ4O5C8E4pVAbC LGz7B6yWKG8qIiBn4gH4YZkTAQAADyswY6');
if FindDTM(NotedLogDTM,x,y,MIX1,MIY1,MIX2,MIY2) then
begin
Mouse(x,y,0,0,true);
Wait(RandomRange(800,1000));
end;
If FindDTMRotated(DButlerDTM,X,Y,MSX1,MSY1,MSX2,MSY2,-Pi,Pi,Pi/30,aFound) Then
Begin
Mouse(X,Y,2,4,true);
Begin
MarkTime(T);
Repeat
Wait(Random(200));
Until ((FindNPCChatText('coins',Nothing)) Or (FindNPCChatText('cert', Nothing)) Or (TimeFromMark(T) > 8000));
If (FindNPCChatText('coins',Nothing)) Then
Begin
ClickContinue(True, True);
TypeSendEx('1',False);
Wait(RandomRange(800,1000));
TypeSendEx('0', False);
Wait(randomRange(900, 1100));
End;
If (FindNPCChatText('cert', Nothing)) Then
Begin
TypeSendEx('1',False);
Wait(RandomRange(1005,1050));
TypeSendEx('26',True);
WaitFindDTM(LogToBurnDTM,x,y,RandomRange(9000,1000 0));
End;
End;
End;
FreeDTM(DButlerDtm);
FreeDTM(NotedLogDTM);
FreeDTM(LogToBurnDTM);
End;
The DTM is being freed so I dont think that is the case.

Error: Exception: The given DTM Index[152] doesn't exist at line 819
The following DTMs were not freed: [SRL - Lamp bitmap, 1, 2, 3, 4]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]

and it pops open the timing code and says there is an error
(*
WaitColorGoneIn
~~~~~~~~~~~~~~~

.. code-block:: pascal

function WaitColorGoneIn(Colour, x1, y1, x2, y2, Tol, MaxTime: integer): Boolean;

Waits until a colour is gone in an area with tolerance and a timeout.
Results true if the colour disappeared in the area within the time cap.

.. note::

by TRiLeZ

Example:

.. code-block:: pascal

*)
function WaitColorGoneIn(Colour, x1, y1, x2, y2, Tol, MaxTime: integer): Boolean;
var
Time, CX, CY: Integer;
begin
Result := False;
if Tol = 0 then Tol := 1;
Time := GetSystemTime + MaxTime;
while (Time > GetSystemTime) do
begin
if (not FindColorTolerance(cx, cy, Colour, x1, y1, x2, y2, Tol)) then
begin
Result := True;
Exit;
end;
Wait(10);
end;
end;

Brandon
04-01-2012, 12:37 PM
Your probably terminating the script before the function even frees it then.. OR you have other DTM's overlapping and not being freed.. Those are the only explanations.

bigbutts5
04-01-2012, 02:04 PM
Wait(1050+random(1050));<--This is how I use the wait function, but that error does not have to do with the wait.