From: mobb
im working on a bot and i want it to exit to lobby every 5-10 min. I am having trouble with the syntax as i am new (rs3 script)
basically,
if (5-10 mins have passed) then
players[currentPlayer].exitToLobby();
any help is appreciated.
You should create a global TTimeMarker and place it in your main loop like so:
var //Global
timer: TTimeMarker;
procedure mainLoop;
begin
if (timer.getTime > random(600000, 900000)) then //10-15 minutes converted to milliseconds
begin
players[currentPlayer].exitToLobby;
wait(whateverTimeToWait);
players[currentPlayer].login;
timer.reset;
timer.start; //reset and restart timer after break has occurred
end;
doStuff;
doMoreStuff;
doMoreMoreStuff;
end;
begin
timer.start; //start the timer at the beginning of your script
end.
If your procedures within your main loop take awhile (so that 10-15 min might elapse before the main loop has happened once), then create a separate procedure like "takeBreak;" and insert the "if timer.getTime > 10-15 min" part at the beginning of every procedure. That would look like:
procedure takeBreak;
begin
players[currentPlayer].exitToLobby;
wait(whateverTimeToWait);
players[currentPlayer].login;
timer.reset;
timer.start;
end;
procedure doStuff;
begin
if (timer.getTime > random(600000, 900000)) then
takeBreak;
{...}
end;
procedure doMoreStuff;
begin
if (timer.getTime > random(600000, 900000)) then
takeBreak;
{...}
end;
procedure doMoreMoreStuff;
begin
if (timer.getTime > random(600000, 900000)) then
takeBreak;
{...}
end;
procedure mainLoop;
begin
doStuff;
doMoreStuff;
doMoreMoreStuff;
end;
begin
timer.start;
end.
Best of luck with your script! Feel free to ask any more questions. :)