SRL Archive - OSR Help

Free DTM.


Failure

2011-12-04 09:24:25

For some reason my DTM's are not freeing correctly I'm not sure what's wrong…


Begin
Repeat
Wait(50);
Until FindDTM(TalkBob, x, y, MSX1, MSY1, MSX2, MSY2) or
(TimeFromMark(LoopBegin) >= 15000)
End;

FreeDTM(TalkBob);



Begin
Repeat
Wait(50);
Until FindDTM(TradeBob, x, y, MSX1, MSY1, MSX2, MSY2) or
(TimeFromMark(LoopBegin) >= 15000)
End;

FreeDTM(TradeBob);

Begin
Repeat
Wait(50);
Until FindDTM(TalkTo, x, y, MSX1, MSY1, MSX2, MSY2) or
(TimeFromMark(LoopBegin) >= 15000)
End;

FreeDTM(TalkTo);

Still I get this
Successfully executed.
The following DTMs were not freed: [3, 4, 5]

They are free'd properly right? Cause after it's used, I free it?…

Bobzilla69

2011-12-04 09:35:17

try this

Begin
Repeat
Wait(50);
Until FindDTM(TalkBob, x, y, MSX1, MSY1, MSX2, MSY2) or (TimeFromMark(LoopBegin) >= 15000)
FreeDTM(TalkBob); //have them inside not outside, we can free them now because we have used it
End;

Begin
Repeat
Wait(50);
Until FindDTM(TradeBob, x, y, MSX1, MSY1, MSX2, MSY2) or (TimeFromMark(LoopBegin) >= 15000)
FreeDTM(TradeBob);
End;

Begin
Repeat
Wait(50);
Until FindDTM(TalkTo, x, y, MSX1, MSY1, MSX2, MSY2) or (TimeFromMark(LoopBegin) >= 15000)
FreeDTM(TalkTo);
End;

Failure

2011-12-04 09:38:04

Tried that, still the same. =/

Bobzilla69

2011-12-04 09:39:52

can you post whole procedure? will be easier to find out whats wrong

Failure

2011-12-04 09:41:35

The procedures

Procedure TradingBob;
Begin
MarkTime(LoopBegin);

TalkBob := DTMFromString('mwQAAAHic42RgYDABYjMgtgNiNyD2gtIgMQcg1gJiLiDmBWIeKA3CHEDMBsT8UPH//xmoAhiJwHAAAJYUBJU=');
TradeBob := DTMFromString('maQEAAHicE2RgYNAGYlYo5gRiISA2AWIbIHaA0qZArAPFykAsDcQyQMwDlWcDYmYg5gBibjQMMpMFqoYJyofJMUHF2YH4/3+GQQEYqYAxAABg4AUM');
Repeat



//Login check
If(LoggedOut = True) then
Begin
Login;
End;

//Trading Bob
BobShop;
MMouse(x, y, 0, 0);
GetMousePos(x, y);
Wait(50);
Mouse(x, y, 0, 0, False);
Wait(50);
//Getting Bob interface
Begin
Repeat
Wait(50);
Until FindDTM(TalkBob, x, y, MSX1, MSY1, MSX2, MSY2) or
(TimeFromMark(LoopBegin) >= 15000)
End;

FreeDTM(TalkBob);

//Found Talk-Bob
MMouse(x, y, 0, 0);
Wait(50);
Mouse(x, y, 0, 0, True);

//Waiting till Bob shop is open.
Begin
Repeat
Wait(50);
Until FindColorTolerance(x, y, DragonLeather1, 226, 132, 247, 149, 2) or
FindColorTolerance(x, y, DragonLeather2, 226, 132, 247, 149, 2) or
(TimeFromMark(LoopBegin) >= 30000);
End;
//Making sure we're going in the Shop!

If(InBobShop = False) then
Begin

//Trading Bob
ExtraBobShop;
MMouse(x, y, 0, 0);
GetMousePos(x, y);
Wait(50);
Mouse(x, y, 0, 0, False);
Wait(50);
//Getting Bob interface
Begin
Repeat
Wait(50);
Until FindDTM(TradeBob, x, y, MSX1, MSY1, MSX2, MSY2) or
(TimeFromMark(LoopBegin) >= 15000)
End;

FreeDTM(TradeBob);


//Found Talk-Bob
MMouse(x, y, 0, 0);
Wait(50);
Mouse(x, y, 0, 0, True);
Wait(2000);

//Waiting till Bob shop is open.
Begin
Repeat
Wait(50);
Until FindColorTolerance(x, y, DragonLeather1, 226, 132, 247, 149, 2) or
FindColorTolerance(x, y, DragonLeather2, 226, 132, 247, 149, 2) or
(TimeFromMark(LoopBegin) >= 30000);
End;
End;

//End of


If FindColorTolerance(x, y, DragonLeather1, 226, 132, 247, 149, 2) or
FindColorTolerance(x, y, DragonLeather2, 226, 132, 247, 149, 2) then
//Buying Dragon Leather
MMouse(234, 141, 0, 0);
Wait(50);
Mouse(235, 141, 0, 0, False);
Wait(50);
//Buying X Amount
MMouse(235, 141+89, 0, 0);
GetMousePos(x, y);
Wait(50);
Mouse(x, y, 0, 0, True);
//Waiting till chat opens
Begin
Repeat
Wait(50);
Until FindColorTolerance(x, y, 8388608, 259, 412, 259, 412, 2) or
(TimeFromMark(LoopBegin) >= 30000);
End;

//We can enter X Amount
Wait(300);
TypeSend('26');
Wait(100);
KeyDown(13);
KeyUp(13);
Wait(20);

Begin
Repeat
Wait(50);
Until FindColorTolerance(x, y, DragonLeather1, 658, 222, 670, 238, 2) or
FindColorTolerance(x, y, DragonLeather2, 658, 222, 670, 238, 2) or
(TimeFromMark(LoopBegin) >= 30000)
End;
//Bought DragonLeather closing shop
MMouse(483,33, 0, 0);
Wait(50);
Mouse(483, 33, 0, 0, True);
Wait(100);



Until FindColorTolerance(x, y, DragonLeather1, 647, 211, 682, 243, 2) or
FindColorTolerance(x, y, DragonLeather2, 647, 211, 682, 243, 2)

End;




Procedure Selling;
Begin
MarkTime(LoopBegin);

TalkTo := DTMFromString('mKgEAAHic42NgYPAFYhYo5gRiCSDWAuJaIK4D4jAg9gfiOCA2B2I3IM6FqmUGYi4gZgdiHiDmQOIzQcV4oOpANB8Q///PgBdoq8vgV0AiYCQTowIAvykGig==');

Repeat


//Login check
If(LoggedOut = True) then
Begin
Login;
End;

SellingShop;
MMouse(x, y+10, 0, 0);
GetMousePos(x, y);
Wait(50);
Mouse(x, y, 0, 0, False);
Begin
Repeat
Wait(50);
Until FindDTM(TalkTo, x, y, MSX1, MSY1, MSX2, MSY2) or
(TimeFromMark(LoopBegin) >= 15000)
End;

FreeDTM(TalkTo);

MMouse(x, y, 0, 0);
Wait(50);
Mouse(x, y, 0, 0, True);

//Waiting till shop is open
Begin
Repeat
Wait(50);
Until FindColorTolerance(x, y, 7243684, 50, 137, 50, 137, 2) or
FindColorTolerance(x, y, 4085101, 48, 139, 48, 139, 2) or
(TimeFromMark(LoopBegin) >= 30000)
End;

//Selling items
MMouse(663, 229, 0, 0);
Wait(50);
Mouse(663, 229, 0, 0, False);
Wait(50);
MMouse(663, 229+90, 0, 0);
GetMousePos(x, y);
Wait(50);
Mouse(x, y, 0, 0, True);
Wait(50);
MMouse(483,33, 0, 0);
Wait(50);
Mouse(483, 33, 0, 0, True);
Wait(100);

Until FindColorTolerance(x, y, 3292228, 662, 233, 662, 233, 2)
End;

Bobzilla69

2011-12-04 09:54:10

fixed your standards and hopefully it will work better

Procedure TradingBob;
Begin
try wait(50);

MarkTime(LoopBegin);
TalkBob := DTMFromString('mwQAAAHic42RgYDABYjMgtgNiNyD2gtIgMQcg1gJiLiDmBWIeKA3CHEDMBsT8UPH//xmoAhiJwHAAAJYUBJU=');
TradeBob := DTMFromString('maQEAAHicE2RgYNAGYlYo5gRiISA2AWIbIHaA0qZArAPFykAsDcQyQMwDlWcDYmYg5gBibjQMMpMFqoYJyofJMUHF2YH4/3+GQQEYqYAxAABg4AUM');
Repeat
//Login check
If(LoggedOut = True) then
Begin
Login;
End;

//Trading Bob
BobShop;
MMouse(x, y, 0, 0);
GetMousePos(x, y);
Wait(50);
Mouse(x, y, 0, 0, False);
Wait(50);
//Getting Bob interface
Begin
Repeat
Wait(50);
Until FindDTM(TalkBob, x, y, MSX1, MSY1, MSX2, MSY2) or
(TimeFromMark(LoopBegin) >= 15000)
End;

//Found Talk-Bob
MMouse(x, y, 0, 0);
Wait(50);
Mouse(x, y, 0, 0, True);

//Waiting till Bob shop is open.
Begin
Repeat
Wait(50);
Until FindColorTolerance(x, y, DragonLeather1, 226, 132, 247, 149, 2) or
FindColorTolerance(x, y, DragonLeather2, 226, 132, 247, 149, 2) or
(TimeFromMark(LoopBegin) >= 30000);
End;
//Making sure we're going in the Shop!

If(InBobShop = False) then
Begin

//Trading Bob
ExtraBobShop;
MMouse(x, y, 0, 0);
GetMousePos(x, y);
Wait(50);
Mouse(x, y, 0, 0, False);
Wait(50);
//Getting Bob interface
Begin
Repeat
Wait(50);
Until FindDTM(TradeBob, x, y, MSX1, MSY1, MSX2, MSY2) or
(TimeFromMark(LoopBegin) >= 15000)
End;

//Found Talk-Bob
MMouse(x, y, 0, 0);
Wait(50);
Mouse(x, y, 0, 0, True);
Wait(2000);

//Waiting till Bob shop is open.
Begin
Repeat
Wait(50);
Until FindColorTolerance(x, y, DragonLeather1, 226, 132, 247, 149, 2) or
FindColorTolerance(x, y, DragonLeather2, 226, 132, 247, 149, 2) or
(TimeFromMark(LoopBegin) >= 30000);
End;
End;
//End of


If FindColorTolerance(x, y, DragonLeather1, 226, 132, 247, 149, 2) or
FindColorTolerance(x, y, DragonLeather2, 226, 132, 247, 149, 2) then
//Buying Dragon Leather
MMouse(234, 141, 0, 0);
Wait(50);
Mouse(235, 141, 0, 0, False);
Wait(50);
//Buying X Amount
MMouse(235, 141+89, 0, 0);
GetMousePos(x, y);
Wait(50);
Mouse(x, y, 0, 0, True);
//Waiting till chat opens
Begin
Repeat
Wait(50);
Until FindColorTolerance(x, y, 8388608, 259, 412, 259, 412, 2) or
(TimeFromMark(LoopBegin) >= 30000);
End;

//We can enter X Amount
Wait(300);
TypeSend('26');
Wait(100);
KeyDown(13);
KeyUp(13);
Wait(20);

Begin
Repeat
Wait(50);
Until FindColorTolerance(x, y, DragonLeather1, 658, 222, 670, 238, 2) or
FindColorTolerance(x, y, DragonLeather2, 658, 222, 670, 238, 2) or
(TimeFromMark(LoopBegin) >= 30000)
End;
//Bought DragonLeather closing shop
MMouse(483,33, 0, 0);
Wait(50);
Mouse(483, 33, 0, 0, True);
Wait(100);



Until FindColorTolerance(x, y, DragonLeather1, 647, 211, 682, 243, 2) or FindColorTolerance(x, y, DragonLeather2, 647, 211, 682, 243, 2)

Finally
FreeDTM(TalkBob);
FreeDTM(TradeBob);
end;
End;




Procedure Selling;
Begin
try Wait(50);
MarkTime(LoopBegin);

TalkTo := DTMFromString('mKgEAAHic42NgYPAFYhYo5gRiCSDWAuJaIK4D4jAg9gfiOCA2B2I3IM6FqmUGYi4gZgdiHiDmQOIzQcV4oOpANB8Q///PgBdoq8vgV0AiYCQTowIAvykGig==');

Repeat
//Login check
If(LoggedOut = True) then
Begin
Login;
End;

SellingShop;
MMouse(x, y+10, 0, 0);
GetMousePos(x, y);
Wait(50);
Mouse(x, y, 0, 0, False);
Begin
Repeat
Wait(50);
Until FindDTM(TalkTo, x, y, MSX1, MSY1, MSX2, MSY2) or (TimeFromMark(LoopBegin) >= 15000)
End;
MMouse(x, y, 0, 0);
Wait(50);
Mouse(x, y, 0, 0, True);

//Waiting till shop is open
Begin
Repeat
Wait(50);
Until FindColorTolerance(x, y, 7243684, 50, 137, 50, 137, 2) or
FindColorTolerance(x, y, 4085101, 48, 139, 48, 139, 2) or
(TimeFromMark(LoopBegin) >= 30000)
End;

//Selling items
MMouse(663, 229, 0, 0);
Wait(50);
Mouse(663, 229, 0, 0, False);
Wait(50);
MMouse(663, 229+90, 0, 0);
GetMousePos(x, y);
Wait(50);
Mouse(x, y, 0, 0, True);
Wait(50);
MMouse(483,33, 0, 0);
Wait(50);
Mouse(483, 33, 0, 0, True);
Wait(100);

Until FindColorTolerance(x, y, 3292228, 662, 233, 662, 233, 2)

finally
FreeDTM(TalkTo);
end;
End;

Failure

2011-12-04 09:58:45

Thanks looks good it works though, but now this appears

Exception in Script: Out Of Range

It continue's though only get it when I stop, doesn't seem to harm.

Nevermind tried again…

Exception in Script: Out Of Range
The following DTMs were not freed: [2, 3]

Bobzilla69

2011-12-04 10:00:53

what line is it showing as causing problems?

Failure

2011-12-04 10:03:42

From: Bobzilla69
what line is it showing as causing problems?


I only get that, so I don't know…

Bobzilla69

2011-12-04 10:06:52

it should highlight part of the code in simba

Failure

2011-12-04 10:12:34

From: Bobzilla69
it should highlight part of the code in simba


But it doesn't highlight anything.. I'm so confused :|

Bobzilla69

2011-12-04 10:13:42

post whole script and i will take a look for you, if you want it private just PM me and i will check it out for you

Failure

2011-12-04 10:17:09

From: Bobzilla69
post whole script and i will take a look for you, if you want it private just PM me and i will check it out for you


PM has been sent, thanks for helping though :)

Nava2

2011-12-04 11:48:01

Just a tip, you really should name your DTMs. It will help you to know which ones are actually causing the issues.

http://docs.wizzup.org/simba/scriptref/dtm.html#setdtmname

DemiseScythe

2011-12-18 11:54:17

You load the DTMs at the beginning of your script so they are loaded, then you place the DTM in if..then statements. What does that mean?
If the if..then statement is false because the DTM was not found, it does not free the DTM because it only frees the DTM if it is found and the part inside the if..then statement is activated.
I suggest you make global procesure to Free all your DTMs at once at place it at the end of your script, it should work fine then, you only loading 2 DTMs so I don't see the need to free them right after they are used, I load about 24 DTMs and free the 24 DTMs at the same time. Let me know if this helped, if not I'll try to figure out what is giving you the error.

From my script:
//This is what FreeDTM procedure would look like:
procedure FrDTM;
begin
FreeDTM(P1);
....//More DTMs here
FreeDTM(P21);
end;

//This procedure tells my script what to do before it ends:
procedure Ending;
begin
Writeln('We have exited the loop!');
Writeln('We are logging out!');
Logout;//Logs the account out of course, the Writeln are just for logging.
Writeln('We are freeing stored DTMs!');
FrDTM;// Here I tell the client to free all DTMs to prevent Memory Leaks.
Writeln('We are terminating the script!');
Terminatescript;
end;

//I call it on the main loop at the end like this
until (Laps > 10) or (Errors > 10) or (not(LoggedIn))//Last part of one of my loops.
Ending;//Exited loop so I make client run this before ending the script, it frees DTMs in this step.
end.