SRL Archive - SRL Archives

Procedure TerminateWhy;


Pmh1000

2007-04-13 23:38:02

I use this function to stop the script whenever i have an error. For instance if you set a time mark [MarkTime(Mark)] and then you set a maximum time the script can run though a repeat until statement. You can put a failsafe in it where when it reaches a certain amount of time waited it will terminate the script Or Logout and login the next active player. I also love to use this in my script. so heres an example of what i was describing:

Procedure SampleWithdrawingProcedure;
var TimeMark :integer;
begin
MarkTime(TimeMark)
Repeat
Mouse(87+2,70,6,8,false)
wait(300+random(300))
ClickOption('Withdraw X',1)
WaitUntill(213, 392, 0, 8000, 500, 1)
TypeSend('14')
repeat
Wait(300+Random(300))
If (TimeFromMark(TimeMark)>30000)) Then TerminateWhy('Spent To Much Time Trying To Withdraw Item',False,False)
If (not(InvCount=14)) Then Depositall;
Until(InvCount=14)
end;

This procedure is a sample to withdraw something from the bank. If it spends too long trying to withdraw it (30 secs) then it terminates it. So if your in a random and srl didnt pick it up and it thinks your in the bank booth. you wont infinitely try to withdraw an item thats not there. after 30 secs the script will die since multiplayer=false.

Procedure:

{******************************************************************************
///////////////////////////TerminateWhy////////////////////////////////
*******************************************************************************}
{******************************************************************************
Procedure TerminateWhy(TheReason :string; DoLogout:Boolean; MultiPlayers :Boolean);
Original code by: Pmh1000
Description: Terminates The Script Due To 'TheReason' Can Log Out Or Jsut Let It
Sit And Rs Naturally Log You Out By Setting DoLogout To True Or False
Also Can Login The Next Player Or TErminate The Script Accourding To
The Setting Of MultiPlayers, True = Loging Next Player, False= Terminate Script
Description Of Vars:
TheReason: The Reason Why You Are Terminating/Loging Out And In A New Player
DoLogout: True To Logout, False To Let Rs Kick You Out
MultiPlayers: True To Login Next Active Player, False To Have The Script Terminated.
*******************************************************************************}

Procedure TerminateWhy(TheReason :string; DoLogout:Boolean; MultiPlayers :Boolean);
var YourScriptsName :String;
begin
YourScriptsName:='Pmh1000''s Auto_Alcher'
Writeln('********** ATTENTION **********')
Writeln('The Script Was Terminated Due To The Following Error:')
Writeln(' *'+TheReason+'*')
writeln('Please Check For Errors And Thank You For Using '+YourScriptsName+'')
If (DoLogout=True) Then Logout;
If (MultiPlayers=True) Then
begin
Writeln('Continuing Script With active Players')
RandomNextPlayer(True)
end else TerminateScript;
end;