SRL Archive - SRL Suggestions

Little edit to LoggedIn


NCDS

2011-01-03 19:13:43

Forgot about this for a few days :redface:

Discussion: http://villavu.com/forum/showthread.php?p=763818#post763818

Lazy Note: This will essentially compensate for black screen causing problems for people at login.

From: NCDS
It seems that the screen loads in sort of 4 boxes that fill the main screen. Either way, if the center of the MS is loaded, the game probably is too.

This little bit here just checks a 40x40px box around MSCx, MSCy, and checks if there are more than 20 occurrences of color '0' (The black of the unloaded RS client). If so, it continues to wait up to 5 seconds.

As you can see it still sets the final Result depending on the original color check.

Side note: I know the explanation probably wasn't necessary, but I felt like I should.


function LoggedIn: Boolean;
var
cx, cy, t: Integer;
begin
t := GetSystemTime + 5000;
while (not (Result)) and (t > GetSystemTime) do
begin
Result := (CountColor(0, MSCx - 20, MSCy - 20, MSCx + 20, MSCy + 20) < 20);
Wait(3);
end;

Result := FindColor(cx, cy, 16777215, 439, 491, 440, 492);
end;

Tested and it worked perfectly fine, though I wasn't really having the problem before, only sometimes.

There may be other ways you would find to be 'better' than this, but I don't see why it wouldn't work.

anyway, let me know your thoughts.


I've had this as my LoggedIn function since I originally posted it, no problems.

Also, if this is to be used, someone may want to add an Exit; depending on how you want it to Result, figured I would leave that up to dev's though.

lordsaturn

2011-01-04 00:53:22

Do you know how many times LoggedIn is called in every person's script?

This, no. bad idea. do not have a 5 second timeout in loggedin. why can't you export the while loop to another function? add this at the beginning of loginplayer if you don't want to make a new function.

3Garrett3

2011-01-04 01:00:29

From: lordsaturn
Do you know how many times LoggedIn is called in every person's script?

This, no. bad idea. do not have a 5 second timeout in loggedin. why can't you export the while loop to another function? add this at the beginning of loginplayer if you don't want to make a new function.


If it's logged in then the result will be instantly true and it wont waste any time. What is the big deal? The wait is to account for the lag when logging in during Safe Mode, iirc. Maybe you don't auto much anymore, but there are a lot of scripts that say "not logged in" because of the large wait time during loading screens and logging in. It happens a lot that I get a player who has been quit because they weren't logged in during loading while walking, etc. It's not just in LoginPlayer for me.

So to sum it up, current LoggedIn, no. Bad idea ;)

Coh3n

2011-01-04 01:25:03

From: lordsaturn
Do you know how many times LoggedIn is called in every person's script?

This, no. bad idea. do not have a 5 second timeout in loggedin. why can't you export the while loop to another function? add this at the beginning of loginplayer if you don't want to make a new function.

What? Like Garrett said, it breaks as soon as the result is found; therefore, no 5 second wait.

I don't really see a problem with adding this.

E: Lordsaturn is right actually, add the wait to LoginPlayer, since LoggedIn is called several times in every script.

i luffs yeww

2011-01-04 02:10:40

And LoggedIn is called in every single SRL function.

I'd say it should be in RSReady..

Wizzup?

2011-01-04 02:39:46

AFAIK even FindNormalRandoms calls it.

i luffs yeww

2011-01-04 02:51:03

Afaik,


if not LoggedIn then
Exit;

is called in every single function in SRL (nearly).

:p So yeah, something that wouldn't be called constantly would be better.

NCDS

2011-01-05 20:46:05

From: lordsaturn
Do you know how many times LoggedIn is called in every person's script?

This, no. bad idea. do not have a 5 second timeout in loggedin. why can't you export the while loop to another function? add this at the beginning of loginplayer if you don't want to make a new function.


Yes, That's why I didn't just say "here commit this it works!!".


Seems to me it would fit better in RSReady than LoginPlayer.

Edit: So is this worth adding to a different SRL function or shall I just implement it into MSI?

Coh3n

2011-01-05 21:03:02

From: NCDS

Edit: So is this worth adding to a different SRL function or shall I just implement it into MSI?

I think it makes the most sense to have it in RSReady. :)

NCDS

2011-01-06 17:42:33

From: Coh3n
I think it makes the most sense to have it in RSReady. :)



function RSReady: Boolean;
var
t: Integer;
begin
t := GetSystemTime + 5000;
while (not (Result)) and (t > GetSystemTime) do
begin
Result := (CountColor(0, MSCx - 20, MSCy - 20, MSCx + 20, MSCy + 20) < 20);
Wait(3);
end;
if (not (Result)) then
Exit;
Result := (LoggedIn)or (LobbyScreen) or (GetColor(745, 17) = 12312554); //X button in top right
end;

Compiles and works.

Coh3n

2011-01-07 15:16:03

Anyone have any objections to that?

Coh3n

2011-01-11 21:51:50

From: NCDS
Compiles and works.

I just looked in LoginPlayerToLob (where RSReady is called) and it's already in a 3 minute waiting loop, so I don't think this would really do anything. It's just an extra wait. LoginPlayerToLob calls RSReady every couple seconds for minutes.

NCDS

2011-01-11 22:04:37

From: Coh3n
I just looked in LoginPlayerToLob (where RSReady is called) and it's already in a 3 minute waiting loop, so I don't think this would really do anything. It's just an extra wait. LoginPlayerToLob calls RSReady every couple seconds for minutes.


I don't see how it's really a negative effect?
From LoginPlayerToLob:

repeat
if (RSReady) then
Break;
if ((GetSystemTime - T) > 180000) then
begin
WriteLn('It has been 3 minutes and Runescape is not yet ready... Terminating.');
TerminateScript;
end;
Wait(RandomRange(1000, 2000));
until (False);

All it does it waits 3 minutes or until RSReady returns true. The change to RSReady isn't going to make it wait any longer. I guess it may be beneficial to lower the wait in RSReady, but either way it wouldn't make much of a difference.

Either it's included and the problem is fixed and you may end up waiting 3 minutes plus a couple seconds to realize you failed to login (worste case scenario). Or, it's not included and people continue to have the problem.

Ultimately it's not up to me though.

p.s. That repeat..until should really just be a while..do

Just for a little bit more explanation, previously RSReady would have returned true if LoggedIn returned true, but LoggedIn doesn't make sure the client itself is loaded, just checks to see if the things around the RS screen to see if they are loaded (report abuse button, etc.).

Coh3n

2011-01-11 22:15:02

My question is how does this fix it? (Which I'm assuming you've tested with the unsigned client delay?) Because, to me, the extra wait shouldn't make a difference.

NCDS

2011-01-11 22:29:42

From: Coh3n
My question is how does this fix it? (Which I'm assuming you've tested with the unsigned client delay?) Because, to me, the extra wait shouldn't make a difference.


It waits 5 seconds or until the RS screen is no longer black.

Honestly, if that's the only time RSReady is called (assuming it is never used independently), then RSReady doesn't need to call LoggedIn as it wouldn't result true in the lobby anyways. However, if it is used independently at all or in another spot (which I'm assuming it is otherwise it wouldn't call LoggedIn), then this is very beneficial.

Either way, if your at the LobbyScreen which I don't think ever really lags when it's loaded (I could be wrong, in which case this is just more useful), then the only extra wait is the amount of time CountColor takes to be called. So really, it doesn't add any extra wait time unless the screen is black, in which case RS is clearly not loaded.

Like I mentioned before (I think?) I've had this as my RSReady since I posted it and have not had any problems or extra delays.

Coh3n

2011-01-11 22:47:45

Okay, committed. :)