Log in

View Full Version : Selgius7 Question's about Scripting.



selgius7
02-21-2012, 10:01 AM
When im running this script. i get error:

The following DTMs were not freed: [2]
but im not even using dtm 2 ?


Program MouseKeySimulator;

//{$DEFINE SMART}
//{$i srl/srl/misc/smart.simba} // This is how we include SMART; it HAS to be included BEFORE SRL!
{$i srl/srl.simba}


procedure DeclarePlayers;
begin
HowManyPlayers := 1; // This is set to the total amount of players (more on multiplayer later ;)), for now, just keep it set as 1
NumberOfPlayers(HowManyPlayers); // This is a procedure in SRL which sets up player arrays (also, more on that later), this will always be the same
CurrentPlayer := 0; // This is the player to start with; the first player will always be 0 (you'll find out when you learn all about arrays)

stats_UserName := '';
stats_UserPass := '';

Players[0].Name := ''; // Username
Players[0].Pass := ''; // Password
Players[0].Nick := 'o'; // 3-4 lowercase letters from username; used for random event detection
Players[0].Active := True; // Set to true if you want to use Player 0


end;


Procedure StatsGuise(wat:String);
Begin
Status(wat);
Disguise(wat);
End;

Function InvMMouse(InvSlot:Integer) : boolean;
Var
TB: TBox;
CurrPT : TPoint;
Begin
result := false;
GameTab(tab_inv);
Result := true;
Writeln('InvMousing:' + IntToStr(InvSlot));
TB := InvBox(InvSlot);
GetMousePos(CurrPT.x,CurrPT.y);
If PointInBox(CurrPT,TB) Then
MouseBox(Max(CurrPT.x-random(2),TB.x1),Max(CurrPT.y-random(2),TB.y1),
Min(CurrPT.x+random(2),TB.x2),Min(CurrPT.y+random( 2),TB.y2),3) //LOL Pro-human much!
Else
MouseBoxEx(TB.X1, TB.Y1, TB.X2, TB.Y2,14, 3);
End;

Procedure MouseKeyDrop;
var
I, v, z, Ore: Integer;
SlotBox:TBox;
RockPattern: TIntegerArray;
Begin
RockPattern:=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ,21,22,23,24];
Ore:= DTMFromString('mrAAAAHic42BgYMhlYmCoBuIqIC4D4nwgTg DiDCDOAuInQDV3gPgREL8B4htA/AyIP0HZJnJiQJIJD8YPGAlgGAAAuBULJg==');
For I:=0 to 23 Do
Begin
StatsGuise('Dropping Ores: ' + IntToStr(I));
SlotBox:=InvBox(RockPattern[I]);
If FindDTM(Ore, v, z, SlotBox.x1, SlotBox.y1, SlotBox.x2, SlotBox.y2) Then //error here
Begin
Writeln('dtm found');
Writeln('I is:' + IntToStr(I));
If InIntArray([0,6,12,18], I) Then
Begin
Writeln('TopBox');
InvMMouse(RockPattern[I]);
MMouse(v, z, 5, 3);
End;
GetMousePos(v, z);
Mouse(v, z, 0, 0, False);
WaitOptionMultiEx(['Us'], 'item', Nothing, 5000);
MoveMouse(v, z+40);
GetMousePos(v, z);
ClickMouse(v, z, mouse_Left);
Wait(50+Random(20));
FreeDTM(Ore);
End;
End;
End;

function IronRockColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.04, 0.60);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 2634578, MSX1, MSY1, MSX2, MSY2, 10);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 1.95) and (X <= 10.44) and (Y >= 1.67) and (Y <= 8.57) and (Z >= 0.96) and (Z <= 4.37) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;

Function MineIron: boolean;
var
ix, iy:Integer;

begin
If FindObjCustom(ix, iy, ['Mine I', 'Iron o', 'ore rock'], [IronRockColor], 10) Then
Begin
WriteLn('We Found a Rock');
Mouse(ix, iy, 4, 4, True);

end;
end;

Begin
SetUpSRL;
DeclarePlayers;
MineIron;
Wait(1800+random(100)); //i want 2 make it do it twice but dunno how to do it till invCount will be 2 or a little more...
MineIron;
Wait(1800+random(100));
MouseKeyDrop;
end.

maybe someone can fix it and explain whats wrong ? thanks.

YoHoJo
02-21-2012, 10:05 AM
It really doesn't matter.

When a script is stop prematurely there may be DTMs or Bitmaps that were not freed, that is just a hint/warning but not a big deal really.

Also, I'd move the FreeDTM(Ore) OUTSIDE of the loop.

selgius7
02-21-2012, 10:11 AM
other problem is that when i try to use it, it mines 2 but wont drop.. maybe something wrong ?

YoHoJo
02-21-2012, 10:16 AM
As in what?
Mines only 2 ores? But doesn't drop?
Explain better please.

selgius7
02-21-2012, 10:19 AM
new Problem


MouseItem(IronPattern[I],False);

[Error] (109:40): Type mismatch at line 108
Compiling failed.

help !

Edit:
Procedure:

Procedure DropIron;
var
x, y, IronDtm, I: integer;
SlotBox:TBox;
IronPattern: TIntegerArray;
Begin
IronDTM := DTMFromString('mrAAAAHic42BgYFjMxMCwAog3AfF6IF4IxF OAeAMQLwNiUSDmBGJ+IJYGYhUgloCKywCxsZwY0BQmPBg/YCSAYQAAvvcGkg==');
IronPattern:=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ,21,22,23,24];
StatsGuise('Dropping');
For i:=0 to 23 Do
Begin
SlotBox:=InvBox(IronPattern[I]);
If FindDtm(IronDTM, x, y, SlotBox.X1, SlotBox.Y1, SlotBox.X2, SlotBox.Y2) Then
Begin
MouseItem(IronPattern[I],False);
ChooseOption('rop');
End;
end;
end;