I have recently been having some trouble with SPS where it would sometime click the map button while trying to click on a point. I found that it occurs fairly rarely but when it happened my bot would stop as there is no built in function in the SRL Include to exit the map (at least there was none that I could find).
This is why I put together this guy:
Simba Code:
function isMapOpen(): boolean;
var
mapOpenDTM, x, y: integer;
begin
mapOpenDTM := DTMFromString('mrAAAAHic42BgYLBkZWAwhGI3KDZhhYiDcDtQzSQgroViEBsk1gPETUB8czkvA4eoDAMbvwgYg9gv9xozHF9mzLCpQ4SBiQETMCFhRgIYBgCeYw1g');
result := false;
if (findDTM(mapOpenDTM, x, y, getClientBounds())) then
begin
writeln('Map Is Open.');
result := true;
end else
writeln('Map is not open.');
freeDTM(mapOpenDTM);
end;
This function will let you know if the map is opened on the screen.
I have gone further and wrote an override of the TSPSArea.walkPath function where you can implement the above function to use if the script accidentally clicks on the map while walking.
Simba Code:
function TSPSArea.walkPath(path: TPointArray; waitMoving: Boolean = True; shiftInterval: Integer = 500): boolean; override
var
p, lastPos, mmPoint: TPoint;
t, fails, h, l, i, dx, dy, mapOpenDTM: integer;
dtmTimer: TTimeMarker;
begin
mapOpenDTM := DTMFromString('mrAAAAHic42BgYLBkZWAwhGI3KDZhhYiDcDtQzSQgroViEBsk1gPETUB8czkvA4eoDAMbvwgYg9gv9xozHF9mzLCpQ4SBiQETMCFhRgIYBgCeYw1g');
result := false;
h := high(path);
l := low(path);
t := (getSystemTime() + randomRange(15000, 20000));
repeat
if (not isLoggedIn()) then
exit(false);
p := self.getPlayerPos();
for i := h downto l do
if (SPS_PosToMM(path[i], p, mmPoint)) then
begin
if (distance(minimap.getCenterPoint(), mmPoint) >= 10) then
begin
if (spsMultiMouse) then
multiClick(mmPoint, 25, 3)
else
mouse(mmPoint, MOUSE_LEFT);
if (minimap.isFlagPresent(2500 + random(500))) then
minimap.waitFlag(10 + random(25));
end;
t := (getSystemTime() + randomRange(15000, 20000));
result := (i = h) or (distance(path[i], path[h]) < 10);
if (result) then
break(2)
else
break();
end;
if (p.x = lastPos.x) and (p.y = lastPos.y) then
inc(fails);
lastPos := p;
dtmTimer.start;
if (findDTM(mapOpenDTM, dx, dy, getClientBounds())) then
begin
repeat
writeln('Map Is Open. We will try to close it.');
wait(randomrange(250, 750));
moveMouse(dx, dy);
fastClick(MOUSE_LEFT);
until(not (findDTM(mapOpenDTM, dx, dy, getClientBounds())) or dtmTimer.getTime > 15000);
end;
until (getSystemTime() > t) or (fails > 5);
if waitMoving then
if (minimap.isFlagPresent() or minimap.isPlayerMoving()) then
minimap.waitPlayerMoving(shiftInterval);
print(self.getName()+'.walkPath(): result = '+boolToStr(result));
freeDTM(mapOpenDTM);
end;
I know that you could make is simpler by having that little section as its own procedure, but this is just something I quickly whipped up.
I seemed to notice that this problem could be seen as human error, which I find kind of useful in making sure you dont get banned.