SRL Archive - SRL Archives

function LoggedInFailsafe: Boolean;


BobboHobbo

2009-08-13 13:39:28

Its mainly made for SMART uses and sometimes when you lag SMART flashes and sometimes scripts say your logged out even if your not, this was just made to reduce the risk of it happening.


function LoggedInFailsafe: Boolean;
var
Tries: Integer;
begin
while not (GetColor(532, 74) = 3951443) do
begin
wait(500);
Inc(Tries);
if (Tries >= 5) then
begin
Result := False;
srl_Warn('LoggedInFailsafe', 'Player is believed to be logged out', warn_Debug);
exit;
end;
end;
Result := True;
end;

Evilchickens posted one:

function LoggedInFailsafe: Boolean;
begin
Result := WaitColor(532, 74, 3951443, 0, 2500);
if (not Result) then
srl_Warn('LoggedInFailsafe', 'Player is believed to be logged out', warn_Debug);
end;

ShowerThoughts

2009-08-13 13:40:28

Does this thing mess up like the one did in your tutorial islander script?

BobboHobbo

2009-08-13 13:43:29

From: Hermen
Does this thing mess up like the one did in your tutorial islander script?


Well no, that problem was from a loop which didn't break, fixed though. This one was remade :).

spicynachos2

2009-08-13 19:07:43

I am going to try this out, Good idea and thankyou.

tarajunky

2009-08-13 19:45:55

It works great, and I've borrowed it for my scripts (with credit of course). Well done.

You should probably reduce the Writeln spamming, though.

You don't really need 5+ consecutive Writelns every time you log out or get logged out.

EvilChicken!

2009-08-14 05:22:56

function LoggedInFailsafe: Boolean;
begin
Result := WaitColor(532, 74, 3951443, 0, 2500);
if (not Result) then
srl_Warn('LoggedInFailsafe', 'Player is believed to be logged out', warn_Debug);
end;

Would this be doing the same thing?

BobboHobbo

2009-08-14 11:36:09

I guess but why, is SRL always going for the shortest procedures?

Naum

2009-08-14 11:56:40

From: BobboHobbo
I guess but why, is SRL always going for the shortest procedures?


Well, Short = Efficient, in most cases.

ian.

2009-08-14 11:57:40

From: BobboHobbo
I guess but why, is SRL always going for the shortest procedures?


Why shouldn't they? The function EC! posted is potentially faster (will find the color faster, right?), and less characters = less things to compile = faster start up, I think. And it's easier to read than yours (no offence <3 :)).

… I really need to post faster. :p

BobboHobbo

2009-08-14 13:21:45

From: ian.
Why shouldn't they? The function EC! posted is potentially faster (will find the color faster, right?), and less characters = less things to compile = faster start up, I think. And it's easier to read than yours (no offence <3 :)).

… I really need to post faster. :p


True, but since did waitcolor exist?

ian.

2009-08-14 13:53:39

When WaitMouse and other Wait___ functions were made. :)

(Within the last month or two, I think.

bugger0001

2009-08-14 14:32:19

That's good. Because of the lightning storm here I am experiencing A LOT of lag and my scripts usually get stopped because of it. But seems to me as this one's going to solve my problems :p

BobboHobbo

2009-08-14 14:55:35

Evilchicken, I tested yours and it does not work.

n3ss3s

2009-08-14 16:20:51

Just put that shit in directives for SRL_SMART into LoggedIn, done :)

EvilChicken!

2009-08-14 21:31:38

BH, I took the coords and color from your function.
If yours works, mine should too.

And, by the way, it's not a matter of "shortening"; it's more a matter of using available resources instead of making your own.