Two functions which would come in handy for someone with a poor internet connection.
What they do are check if you are connected to Runescape, via the Lost Connection box in the top left of your screen.
Connected just returns true or false depending on whether you are connected or not.
WaitForConnection again returns true if you are connected. If you are not connected though, it will wait MaxWaitMS to become connected. If it does not become connected after waiting, it returns false.
Please do not hassle me about using a DTM; it is the first method which popped into my mind. Anyway, when I tested it, it only took
Code:
Successfully compiled (234 ms)
to compile.
SCAR Code:
{*******************************************************************************
function LostConnection : Boolean;
By: R1ch
Description: Checks if you are not connected to RS. Returns true if you are NOT connected.
*******************************************************************************}
function LostConnection : Boolean;
var
X, Y , Con : Integer;
begin
Con := DTMFromString('78DA63D4606060E061C00A1861B4079060439' +
'5FBFFFF3FAA9A4820C145408D1390E025A0460D48F01150234F84' +
'39224498C341841A90BF3908A81125C2EF2A408293801A7DC2E10' +
'C0098072353');
Result:= FindDTM(Con, X, Y , 0, 0, 250, 75)
FreeDTM(Con);
end;
{*******************************************************************************
function WaitForConnection(MaxWaitMS : Integer) : Boolean;
By: R1ch
Description: Checks if you are connected to RS. Returns true if you are.
If you are not, waits MaxWaitMS to become connected.
*******************************************************************************}
function WaitForConnection(MaxWaitMS : Integer) : Boolean;
var
I : Integer;
begin
I := GetSystemTime;
while (GetSystemTime - I) < MaxWaitMS do
begin
Result:= not(LostConnection);
if Result then
Exit;
Wait(Random(15));
end;
end;
Comments?