Well, when you're in combat your character should be moving, right? So why don't you use pixelshift? Here's an excellent tutorial on pixelshift: http://villavu.com/forum/showthread.php?t=74090.
So you could call that pixelshift function "InCombat". Then in your code you'd do something like:
Simba Code:
procedure ######;
begin
repeat
DoStuff
OtherStuff;
Antiban;
until(insertsomethinghere);
if not (InCombat) then
begin
WriteLn('Out of combat for 60 seconds. Logging out.');
TerminateScript;
end;
end;
Please excuse that horrid excuse of an example.
I hope you get the point, though. If you need too, you can look through other people's scripts for examples!