NOW WITH MULTIPLAYER SUPPORT
I had this idea for writing an SRL break handler, so here is what I came up with.
Simba Code:
{*******************************************************************************
function BreakHandler(BreakIn, BreakFor, randBreakIn, randBreakFor: Integer): Boolean;
By: Echo_
Description: Takes brakes according to the minute values entered
*******************************************************************************}
function BreakHandler(BreakIn, BreakFor, randBreakIn, randBreakFor: Integer): Boolean;
var
w, x, y, z: Integer;
begin
if not LoggedIn then Exit;
w := (BreakIn * 60000);
x := (BreakFor * 60000);
y := RandomRange(-randBreakIn * 60000, randBreakIn * 60000);
z := RandomRange(-randBreakFor * 60000, randBreakFor * 60000);
if (HowManyPlayers = 1) then
begin
if (GetTimeRunning < ((w) + (y) + BreakRounds)) then Exit
else
if (GetTimeRunning > ((w) + (y) + BreakRounds)) then
begin
Writeln('Taking a break for about ' + IntToStr(BreakFor) + ' minutes.');
Logout;
Wait((x) + (z));
Writeln('Logging in.');
LoginPlayer;
Result := LoggedIn;
FindNormalRandoms;
IncEx(BreakRounds, (w) + (x));
IncEx(TotalBreaks, 1);
Writeln('The next break will occur in about ' + IntToStr(BreakIn) + ' minutes.');
end;
end;
if (HowManyPlayers > 1) then
begin
if (GetTimeRunning < ((w) + (y) + BreakRounds)) then Exit
else
if (GetTimeRunning > ((w) + (y) + BreakRounds)) then
begin
Writeln('Taking a break for about ' + IntToStr(BreakFor) + ' minutes.');
Logout;
IncEx(BreakRounds, (w));
IncEx(TotalBreaks, 1);
NextPlayer(True);
Exit;
while (LoggedIn) do Wait((x) + (z));
NextPlayer(True);
end;
end;
end;
It's pretty self explanatory.
BreakIn - The amount of time the procedure will wait before taking a break
BreakFor - The amount of time the procedure will take a break for
randBreakIn - Randomness added to the value of BreakIn
randBreakFor - Randomness added to the value of BreakFor
You have to declare a global variable in your script named "BreakRounds" so that the procedure will know when to break next after already taking a break.
Simba Code:
var
BreakRounds, TotalBreaks: Integer;
As you can see, the parameter values are converted to run on minutes rather than milliseconds. So lets say I want my script to take a break after botting for about an hour. I want the break to be a half hour long. I want to have a random amount of time added to those values in the 10 minutes range. Here is what I would add to the beginning of my main loop.
Simba Code:
BreakHandler(60, 30, 10, 10);
Thoughts? Suggestions? I still have to add a debug box timer.
Credits: Coh3n - tweaked the timers to be more randomized