This isn't my code but is looks very simalar:
First we to make need sure that we run even the bot stucks in the moveTo loop.
We doing that by:
bot.lua line 662
Code: Select all
while(true) do
if isClientCrashed() then
error("Client crash detected in main bot loop.")
end
Code: Select all
-- 10 sec but you can use less if wanted
registerTimer("ClientDetection", secondsToTimer(10), checkclient);
while(true) do
Code: Select all
function checkclient()
local crashflag, cpid = isClientCrashed();
if crashflag then
error("Client crash detected .")
end
end
http://solarstrike.net/phpBB3/viewtopic ... &start=540
Then you must know that the error callback call also isClientCrashed() if memory readings goes wrong, so you need to do that there:
function.lua
Code: Select all
function isClientCrashed()
local crashwins = findWindowList("Crash Report", "#32770");
local numcrashs = #crashwins;
local crashflag = false;
local pid = 0;
if( #crashwins == 0 ) then
return false
end
printf("Found "..numcrashs.." crashed clients \n");
local crashparent
for i = 1, #crashwins, 1 do
crashparent = getWindowParent(crashwins[i])
if crashparent and crashparent == getWin() then
-- Looks like the paired game client crashed.
pid = findProcessByWindow(crashwins[i]);
crashflag = true;
end
end
if(RestartChar ~= nil and crashflag == true)then
RestartChar();
return false, pid;
end
return crashflag , pid
end
Code: Select all
function RestartChar( client)
if(client == nil) then
client = "Client"
end
char = getChar();
acc = getAcc();
ChangeCharRestart(char,acc,client);
player:update()
loadProfile()
if( char ~= getChar() or acc ~= getAcc())then
ChangeCharRestart(char,acc,"Client")
end
showWindow(getWin(),sw.minimize)
end