SRL Archive - General

MSI_HandleBreaking;


NCDS

2010-07-20 15:07:49

Current:

{******************************************************************************}
{ procedure MSI_HandleBreaking; }
{ By: Coh3n }
{ Date: 10 June 2010 }
{ Description: Simple procedure for breaking }
{******************************************************************************}
procedure MSI_HandleBreaking;
begin
if (not LoggedIn) then
Exit;

if (BankScreen) then
CloseBank;

if (HowManyPlayers = 1) or (PlayersActive = 1) then
begin
MSI_Debug('MSI_HandleBreaking', 'Taking a short break', DEBUG_PLAYER_ACTIONS);
ExitToLobby;
Wait((BreakTime * 60000) + RandomRange(-300000, 300000));
MSI_Debug('MSI_HandleBreaking', 'Break over, continuing to play', DEBUG_PLAYER_ACTIONS);
if (LobbyScreen) then
MouseBox(80, 450, 560, 470, 1);
end else
begin
MSI_Debug('MSI_HandleBreaking', 'Switching players', DEBUG_PLAYER_ACTIONS);
NextPlayer(True);
end;

Inc(Stats_CustomVars[STATS_LOGINS]);
MSI_SendStats;
end;

After a few tweaks:

{******************************************************************************}
{ procedure MSI_HandleBreaking; }
{ By: Coh3n }
{ Date: 10 June 2010 }
{ Description: Simple procedure for breaking }
{******************************************************************************}
procedure MSI_HandleBreaking;
var
t: Integer;
begin
if (not LoggedIn) then
Exit;

if (BankScreen) then
CloseBank;

if (HowManyPlayers = 1) or (PlayersActive = 1) then
begin
MSI_Debug('MSI_HandleBreaking', 'Taking a short break', DEBUG_PLAYER_ACTIONS);
if InRange(Random(10), 2, 9) then
ExitToLobby;
t := (GetSystemTime + ((BreakTime * 60000) + RandomRange(-300000, 300000)));
while GetSystemTime < t do
begin
Status('BreakTime remaining: '+IntToStr(t - GetSystemTime)+';');
Wait(60);
if LoggedIn then
FindNormalRandoms;
end;
MSI_Debug('MSI_HandleBreaking', 'Break over, continuing to play', DEBUG_PLAYER_ACTIONS);
if (LobbyScreen) then
MouseBox(80, 450, 560, 470, 1);
end else
begin
MSI_Debug('MSI_HandleBreaking', 'Switching players', DEBUG_PLAYER_ACTIONS);
NextPlayer(True);
end;

Inc(Stats_CustomVars[STATS_LOGINS]);
MSI_SendStats;
end;

I changed it to randomly idle out or ExitToLobby, and the other part is more so just because I find it convenient to know how much longer the breaks will last.

Comments?

Coh3n

2010-07-20 18:42:50

Did you commit it?

You should add a Wait(RandomRange(2000, 3000)) inbetween searching for randoms. Searching every 60ms will cause massive lag on some machines. I've had that happen with my other woodcutting scripts.

And wow, I forgot about this forum. :p I really need to make threads for when I make major updates. My apologies, guys.

I like it btw. Oh, make sure to update the date in the header. ;)

NCDS

2010-07-20 19:55:26

From: Coh3n
Did you commit it?

You should add a Wait(RandomRange(2000, 3000)) inbetween searching for randoms. Searching every 60ms will cause massive lag on some machines. I've had that happen with my other woodcutting scripts.

And wow, I forgot about this forum. :p I really need to make threads for when I make major updates. My apologies, guys.

I like it btw. Oh, make sure to update the date in the header. ;)


Added, Ok, It's alright, and DONE! :p