SRL Archive - OSR Help

After X ammount of time, break and logout?


humeruzz

2013-09-23 15:57:54

Is there a little snippet for this somewhere??

So after for instance 1Hour+random(~30mins)
It will log out, and then back in because i can tell it to after maybe 30 minutes of being logged out? :)

Itankbots

2013-09-23 16:01:19

http://villavu.com/forum/showthread.php?t=74999

Not exactly what you're looking for, but the MiniBreaker is similar, could pretty easily be edited to only activate ever 1hr or so

humeruzz

2013-09-23 16:05:58

From: Itankbots
http://villavu.com/forum/showthread.php?t=74999

Not exactly what you're looking for, but the MiniBreaker is similar, could pretty easily be edited to only activate ever 1hr or so


Thank you for this :) i'll look into it ASAP :D

EngageTheRage

2013-09-23 17:20:29

heres one that i used a while back. playRange is just what the user enters, for example between 200 and 300 minutes … same with breakRange, eg 10 to 15 minutes.

this bit goes in my main bit, inside the repeat loop …

nextBreak := GetTimeRunning + RandomRange(playRange[0], playRange[1]);
breakLength := RandomRange(breakRange[0], breakRange[1]);

repeat

if (nextbreak < GetTimeRunning) and (playRange[1] > 0) then // playerRange[1] >0 is just to check it has a value
begin
MyDebug('starting to break');
breakLoop(breakLength);
nextBreak := GetTimeRunning + RandomRange(playRange[0], playRange[1]); // get a new time for nextBreak and breakLength
breakLength := RandomRange(breakRange[0], breakRange[1]); // so it changes every break.
end;

if not LoggedIn then
begin
if attempts >3 then
begin
terminatescript;
end;
LogInPlayer;
inc(attempts);
end;

attempts := 0;
MainLoop;
until(false)

and then the actual breakLoop procedure:

procedure breakLoop(length: Integer);
var
timeLeft: integer;
begin
timeLeft := length;
MyDebug('starting break for: ' + inttostr(timeLeft));

while(Incombat) do // made for a combat script so what this does is ensure that it is able to logout before trying
begin // to log out, there are other ways that you could do this,
while(Incombat) do // but for some reason i chose this way :)
begin
eat;
ProduceProgressReport;
wait(500);
end;

wait(13000);
end;

Logout;
SMART_DrawTextEx(false, 50, 50, 'UpChars07', 'Breaking For:', 62207); // when logged out i had a little countdown
SMART_DrawTextEx(false, 50, 75, 'UpChars07', MyGetTimeRunning(timeLeft), 62207); // timer thing on the go so if you user looks
SMART_DrawTextEx(false, 50, 125, 'UpChars07', 'Break Time Left:', 62207); // they can see how long is left

while (timeLeft > 0) do
begin
SMART_ClearCanvasArea(IntToBox(45,145,250,175));
SMART_DrawTextEx(false, 50, 150, 'UpChars07', MyGetTimeRunning(timeLeft) , 62207);
timeLeft := timeLeft - 1000;
wait(1000);
end;
end;

well thats how i implemented a break function into a script of mine before, if i came at it again i might go a slightly different way, but this still works pretty well :D

humeruzz

2013-09-24 07:53:27

From: EngageTheRage
heres one that i used a while back. playRange is just what the user enters, for example between 200 and 300 minutes … same with breakRange, eg 10 to 15 minutes.

this bit goes in my main bit, inside the repeat loop …

nextBreak := GetTimeRunning + RandomRange(playRange[0], playRange[1]);
breakLength := RandomRange(breakRange[0], breakRange[1]);

repeat

if (nextbreak < GetTimeRunning) and (playRange[1] > 0) then // playerRange[1] >0 is just to check it has a value
begin
MyDebug('starting to break');
breakLoop(breakLength);
nextBreak := GetTimeRunning + RandomRange(playRange[0], playRange[1]); // get a new time for nextBreak and breakLength
breakLength := RandomRange(breakRange[0], breakRange[1]); // so it changes every break.
end;

if not LoggedIn then
begin
if attempts >3 then
begin
terminatescript;
end;
LogInPlayer;
inc(attempts);
end;

attempts := 0;
MainLoop;
until(false)

and then the actual breakLoop procedure:

procedure breakLoop(length: Integer);
var
timeLeft: integer;
begin
timeLeft := length;
MyDebug('starting break for: ' + inttostr(timeLeft));

while(Incombat) do // made for a combat script so what this does is ensure that it is able to logout before trying
begin // to log out, there are other ways that you could do this,
while(Incombat) do // but for some reason i chose this way :)
begin
eat;
ProduceProgressReport;
wait(500);
end;

wait(13000);
end;

Logout;
SMART_DrawTextEx(false, 50, 50, 'UpChars07', 'Breaking For:', 62207); // when logged out i had a little countdown
SMART_DrawTextEx(false, 50, 75, 'UpChars07', MyGetTimeRunning(timeLeft), 62207); // timer thing on the go so if you user looks
SMART_DrawTextEx(false, 50, 125, 'UpChars07', 'Break Time Left:', 62207); // they can see how long is left

while (timeLeft > 0) do
begin
SMART_ClearCanvasArea(IntToBox(45,145,250,175));
SMART_DrawTextEx(false, 50, 150, 'UpChars07', MyGetTimeRunning(timeLeft) , 62207);
timeLeft := timeLeft - 1000;
wait(1000);
end;
end;

well thats how i implemented a break function into a script of mine before, if i came at it again i might go a slightly different way, but this still works pretty well :D


Thanks for the HQ post!
But this I can't seem to find anything making the other Procedures stopping while this starts.
Because when I breaks and logs, I don't want the other procedures to keep on going :)

EngageTheRage

2013-09-24 08:24:20

From: humeruzz
Thanks for the HQ post!
But this I can't seem to find anything making the other Procedures stopping while this starts.
Because when I breaks and logs, I don't want the other procedures to keep on going :)


this will make the others stop … you see in the procedure breakLoop there is a while loop at the bottom … it will stay in that until it has counted down from breaktime to zero, so no other methods will be called during that time, just the on screen text updated :)

humeruzz

2013-09-24 08:25:51

From: EngageTheRage
this will make the others stop … you see in the procedure breakLoop there is a while loop at the bottom … it will stay in that until it has counted down from breaktime to zero, so no other methods will be called during that time, just the on screen text updated :)


Oh thanks!
Didn't catch that part :)