Mark
2013-09-13 09:01:01
Hi guys been Playing with Brandons GLX again this time with getting the nearest model using the following code
Code Seems to work well it finds the nearest model successfully moves mouse then right clicks as it should but then simba crashes and i get this error in the debug any info to why this is happening would be very much appreciated.
Here is the error message in the from the console.

thanks in advance guys…
program new;
{$X+}
{$DEFINE SMART}
{$I GLX/Setup.Simba}
Function glGetNearestModelPos(ModelID:Cardinal):TPoint;
var
T: glModelArray; I,BestPick:Integer; DistArr:TIntegerArray; Points:TPointArray;
begin
T:= glGetModels(ModelID);
SetLength(T, High(T));
if Length(T) > 0 then
begin
SetLength(Points, High(T));
SetLength(DistArr, High(T));
for I := 0 to High(T) do Points[I]:=Point(T[I].X, T[I].Y);
for I := 0 to High(T) do DistArr[I]:=Distance(Points[I].x,Points[I].y,678,343);
for I := 0 to High(T) do if (DistArr[I] < DistArr[BestPick]) then BestPick := I;
Result:=Points[BestPick];
end else writeln('Cant Find Model:' + ToStr(ModelID) + ' On Screen Please Check ID is Correct');
end;
var
Smart: TSmart;
TP:TPoint;
begin
SetupGLX(Smart, 1360, 670);
//glDebug(2, 0, 0, 0, Smart.Height, Smart.Width);
TP:=glGetNearestModelPos(3910352186);
Mouse(TP.x, TP.y, 1, 1, Mouse_Right);
end.Code Seems to work well it finds the nearest model successfully moves mouse then right clicks as it should but then simba crashes and i get this error in the debug any info to why this is happening would be very much appreciated.
Here is the error message in the from the console.

thanks in advance guys…