SRL Archive - SRL Archives

Connection


Rich

2008-12-07 14:06:52

//function Connection : Boolean;
//By: R1ch
//Description: Checks to see if you have connection or not.
//Example: if Connection then...

function Connection : Boolean;
begin
result:= not(FindText(x, y 'ost onnection', CHARS, MSX1, MSY1, MSX2, MSY2));
end;

I've noticed that when running scripts, lately I've been losing connection quite a bit, so I came up with this very simple function. Simple, but it does the job.

Used like:

procedure CheckConnection;
var
Timer : Integer;;

begin
if Connection then
//code
else
begin
MarkTime(Timer);
While(not(Connection) do
Wait(10);
if (TimeFromMark(Timer) = 20000) then Exit;
end;
end;
Any comments?

EDIT: What font/chars would this be?

A G E N T

2008-12-07 14:22:49

You have the right idea, but are missing a few parameters in FindText…

function FindText(var cx, cy:LongInt; txt:string;font,xs,ys,xe,ye:LongInt):Boolean;

Baked0420

2008-12-07 14:24:19

maybe do

if not connection then
begin
repeat
wait(1000 + random(500))
until(connection)
end;

because you don't know how long it'd take for other people to get connection back, so it'll just keep waiting until it does get the connection back.

Naum

2008-12-07 16:19:15

Make it run a SetTimeOut that way it checks continuously :)

Rich

2008-12-07 16:37:35

What Chars would the text in the black box be? I'm thinking that it would be SmallChars…Am I right?

XcanadamanX

2008-12-07 16:54:51

i wouldnt search the whole MS just the area where it would be