SRL Archive - SRL Archives

Login.scar


Dgby714

2010-03-03 22:40:38

Changes -
  • Renamed Logout to ExitToLobby and fixed it!
  • Created new Logout to do ExitToLobby and click X!
  • Added AtLobbyScreen;
  • LoginPlayer now logs people in O.o
  • Fixed RSReady
  • Added Member to Players (for logging in)

Index: SRL/core/Login.scar
===================================================================
--- SRL/core/Login.scar (revision 405)
+++ SRL/core/Login.scar (working copy)
@@ -7,7 +7,9 @@
// * procedure Login_SetAudio(Volume, SFX, Area: Integer; SMSetting: (Stereo, Mono, NoChange) ); // * by ZephyrsFury
// * procedure Login_SetGraphics(Brightness: Integer; vl, rr, gd, td, ia, fl, gt, cs: string); // * by ZephyrsFury
// * procedure SetAutoingDefaults; // * by ZephyrsFury
-// * procedure Logout; // * by Starblaster100 and Raymond
+// * function AtLobbyScreen: Boolean; // * by Dgby714
+// * function ExitToLobby; // * by Starblaster100 and Raymond
+// * function Logout; // * by Dgby714
// * procedure LoginPlayer; // * by SRL Developers
// * function NextPlayerIndex: Integer; // * by Dankness, Ron, Raymond & ZephyrsFury
// * function RandomPlayerIndex: Integer; // * by Dankness, Ron, Raymond & ZephyrsFury
@@ -36,10 +38,9 @@
Description: Returns true if we are ready to auto (on loginscreen or logged in).
Useful for waiting until RS has fully loaded.
*******************************************************************************}
-
function RSReady: Boolean;
begin
- Result := (LoggedIn) or (GetColor(748, 488) = 455491); //settings thingy button
+ Result := (LoggedIn) or (GetColor(381, 35) = 3302545); //Sword Handle (In RuneScape)
end;

{*******************************************************************************
@@ -50,14 +51,11 @@
1 2 3 4 5
<-o---o---o---o---o->
*******************************************************************************}
-
-Procedure LoginScreenMusic(State: Variant);
-
-Var
+procedure LoginScreenMusic(State: Variant);
+{var
RealState: Variant;
- x: Extended;
-
-Begin
+ x: Extended;}
+begin
{if (LoggedIn) then Exit;
TypeByte(vk_Escape);
Wait(500);
@@ -72,10 +70,9 @@
x := (421.0 - 333.0) * RealState / 4.0 + 333.0;
If CountColorTolerance(1647966, Round(x) - 5, 375, Round(x) + 5, 385, 20) < 5 Then
If CountColorTolerance(991349, Round(x) - 5, 375, Round(x) + 5, 385, 20) < 5 Then
- Mouse(Round(x), RandomRange(375, 385), 0, 0, True);
- }
+ Mouse(Round(x), RandomRange(375, 385), 0, 0, True); }
srl_Warn('LoginScreenMusic', 'Uhm yea, looks like this one is useless now.', warn_AllVersions);
-End;
+end;

{*******************************************************************************
procedure Login_SetAudio(Volume, SFX, Area: Integer; SMSetting: (Stereo, Mono, NoChange) );
@@ -87,7 +84,6 @@
1 2 3 4 5
Volume, SFX, Area: <-o---o---o---o---o->
*******************************************************************************}
-
procedure Login_SetAudio(Volume, SFX, Area: Integer; SMSetting: TSMSetting);
var
II, Tx, Ty, T, AudioMask,x,y: Integer;
@@ -215,7 +211,6 @@
By: ZephyrsFury
Description: Sets the Audio to off (1 for each bar). Works logged in and out.
*******************************************************************************}
-
procedure SetAudioOff;
begin
if (LoggedIn) then
@@ -229,7 +224,6 @@
By: ZephyrsFury
Description: Sets the graphic options for best SRL compatibility. Works both logged in and out.
*******************************************************************************}
-
procedure SetAutoingDefaults;
begin
if (LoggedIn) then
@@ -239,16 +233,25 @@
end;

{*******************************************************************************
-procedure Logout;
+function AtLobbyScreen: Boolean;
+By: Dgby714
+Description: Returns true if we are at the Lobby Screen
+*******************************************************************************}
+function AtLobbyScreen: Boolean;
+begin
+ Result := (GetColor(360, 463) = 2272229); //Click to Play Button (Inside o in to)
+end;
+
+{*******************************************************************************
+function ExitToLobby: Boolean;
By: Starblaster100 / Raymond
-Description: Logs you out.
+Description: Exits to the Lobby (for breaks?)
*******************************************************************************}
-
-function Logout: Boolean;
+function ExitToLobby: Boolean;
var
c, i: Integer;
begin
- Result := (not (LoggedIn));
+ Result := (AtLobbyScreen);
if Result = True then
Exit;
if (SRL_Procs[srl_OnLogOut] <> nil) then
@@ -259,11 +262,11 @@
while (LoggedIn) and (c < 10) do
begin
Inc(c);
- if(ClickText('here', UpChars, MIX1, MIY1, MIX2, MIY2, True))then
+ if(ClickText('xit to', UpChars, MIX1, MIY1, MIX2, MIY2, True))then
for i := 0 to 10 do
begin
Wait(1000);
- if not(LoggedIn)then
+ if AtLobbyScreen then
begin
Result := True;
Exit;
@@ -273,11 +276,54 @@
end;

{*******************************************************************************
+function Logout: Boolean;
+By: Dgby714
+Description: Logs you out.
+*******************************************************************************}
+function Logout: Boolean;
+var
+ c, i, x, y, bmpExitLobby, bmpExitLobbyHlt: Integer;
+begin
+ if (SRL_Procs[srl_OnLogOut] <> nil) then
+ SRL_Procs[srl_OnLogOut]();
+ if ExitToLobby then
+ begin
+ bmpExitLobby := BitmapFromString(2, 2, 'beNprCFWUk2ZgYASifgANeQHB');
+ bmpExitLobbyHlt := BitmapFromString(2, 2, 'beNrbUmVjacTAwAhExwEUcQKf');
+ while (AtLobbyScreen) and (c < 10) do
+ begin
+ Inc(c);
+ if FindBitmap(bmpExitLobby, x, y) then
+ begin
+ Mouse(x, y, 20, 20, true);
+ for i := 0 to 10 do
+ begin
+ Wait(1000);
+ if not(AtLobbyScreen)then
+ Result := True;
+ end;
+ end;
+ if FindBitmap(bmpExitLobbyHlt, x, y) then
+ begin
+ Mouse(x, y, 20, 20, true);
+ for i := 0 to 10 do
+ begin
+ Wait(1000);
+ if not(AtLobbyScreen)then
+ Result := True;
+ end;
+ end;
+ end;
+ FreeBitmap(bmpExitLobby);
+ FreeBitmap(bmpExitLobbyHlt);
+ end;
+end;
+
+{*******************************************************************************
procedure LoginPlayer;
By: SRL Developers
Description: Logs in the Player[CurrentPlayer]. Detects most Client Login Errors
*******************************************************************************}
-
procedure LoginPlayer;
var
Mark, Attempts: Integer;
@@ -290,13 +336,21 @@
Wait(100);
TypeByte(vk_Escape);

- if (GetColor(207, 409) = 238044) then //At Welcome Screen
+ if (AtLobbyScreen) then
begin
Wait(500 + Random(1000));
- MouseBox(249, 419, 521, 445, 1);
+ MouseBox(80, 450, 560, 470, 1);
MarkTime(Mark);
while (TimeFromMark(Mark) < 30000) and (not(LoggedIn)) do
Wait(1000 + Random(1000));
+ if (GetColor(510, 225) = 11189701) then //Checks for Right Skull in PvP Warning
+ if AllowPVP then
+ MouseBox(400, 335, 500, 355, 1)
+ else
+ begin
+ SRL_Warn('LoginPlayer', 'Attempted to log into PVP World when AllowPVP was false. Terminating.', Warn_AllVersions);
+ TerminateScript;
+ end;
end;
if (not(RSReady)) then
begin
@@ -312,13 +366,6 @@
end;
WriteLn('Welcome to Runescape.');
end;
-
- LoginScreenMusic(True);
- if (not(GraphicsSet)) then
- begin
- SetAutoingDefaults;
- GraphicsSet := True;
- end;
ProcStart:

if (not(LoggedIn)) then
@@ -329,47 +376,40 @@
NextPlayer(False);
Exit;
end;
- Wait(900 + random(60));
+ Wait(900+random(60));

//Click 'Log In' on main menu
- while (GetColor(343, 175) <> 7750) do
+ while (GetColor(380, 310) <> 6865381) do
begin
- MouseBox(360, 184, 400, 190, 1);
- Wait(100 + Random(100));
+ if (Players[CurrentPlayer].Member <> true) then
+ MouseBox(225, 405, 365, 425, 1); //Free Login button
+ else
+ MouseBox(405, 405, 550, 425, 1) //Member Login button
+ Wait(100+Random(100));
end;

//Type Username
- Mouse(315, 272, 10, 5, True);
- while (CountColor(7750, 311, 269, 452, 284) > 0) do
+ Mouse(300, 225, 10, 5, True);
+ while (CountColor(16777215, 255, 215, 385, 230) > 0) do
begin
TypeByte(VK_BACK);
- Wait(50 + Random(50));
+ Wait(50+Random(50));
end;
- Wait(100 + Random(200));
+ Wait(100+Random(200));
WriteLn(Capitalize(Players[CurrentPlayer].Name));
TypeSend(Players[CurrentPlayer].Name);
- Wait(100+random(50));
+ Wait(100+Random(50));

//Type Password
- while (CountColor(7750, 311, 337, 452, 352) > 0) do
+ while (CountColor(16777215, 255, 270, 240, 285) > 0) do
begin
TypeByte(VK_BACK);
- Wait(50 + Random(50));
+ Wait(50+Random(50));
end;
- Wait(100 + Random(200));
+ Wait(100+Random(200));
TypeSend(Players[CurrentPlayer].Pass);
- Wait(500 + Random(300));
+ Wait(500+Random(300));

- if (GetColor(315, 239) = 197552) then //Check for pvp warning and click
- if AllowPVP then
- MouseBox(434, 416, 481, 425, 1)
- else
- begin
- SRL_Warn('LoginPlayer', 'Attempted to log into PVP World when AllowPVP was false. Terminating.', Warn_AllVersions);
- TerminateScript;
- end;
-
-
MarkTime(Mark);
repeat
SetLength(Actions, 0);
@@ -377,23 +417,25 @@
if (TimeFromMark(Mark) > 60000) then
Actions := ['One minute has passed...', 0, 2, 'NextPlayer', 'Login Failed']
else
- case (CountColor(12509695, 288, 205, 475, 247)) of //Number of text colour points
+ case (CountColor(16777215, 253, 170, 510, 290)) of //Number of text colour points
// Actions := ['WriteLn Text', TimeToWait, NumberOfRetries, 'FinalAction', 'PlayerStatus'];
- 760: Actions := ['Too many incorrect logins.', 5 * 60000, 2, 'NextPlayer', ''];
- 536: Actions := ['Login limit exceeded. Please wait 1 minute and try again.', 60000, 2, 'NextPlayer', ''];
- 711: If (CountColor(16711680, 341, 219, 391, 233) = 128) then
- Actions := ['Your account has been disabled', 0, 0, 'NextPlayer', 'Acc Disabled'];
- 598: Actions := ['Invalid Username / Password', 0, 2, 'NextPlayer', 'Wrong User/Pass'];
- 787: Actions := ['Not a Members Account', 0, 0, 'NextPlayer', 'Non-member'];
- 408: Actions := ['World is full.', 5000, 20, 'RandomNextPlayer', ''];
- 669: Actions := ['Your account is already logged in', 5000, 0, 'RandomNextPlayer', ''];
- 555: Actions := ['The Server is being updated.', 60000, 4, 'Terminate', 'Server Updating'];
- 218: Actions := ['Error Connecting.', 20000, 9, 'Terminate', 'Error Connecting'];
- 335: Actions := ['Unable to connect Login Server offline.',(20000) + Random(6000), 4, 'Terminate', 'Login Server Offline'];
- 512: Actions := ['RuneScape has been updated. Script Terminated.', 0, 0, 'Terminate', 'RS Updated'];
- 489: Actions := ['Connection timed out.', 0, 4, 'Terminate', 'Connection Timed Out'];
- 737: Actions := ['You are standing in a members-only area.', 0, 0, 'NextPlayer', 'In Mems-Only Area'];
- 620: Actions := ['Not high enough total level, need 1000 or higher', 0, 2, 'NextPlayer', 'Total Level to Low'];
+ 949: Actions := ['Invalid Username / Password', 0, 2, 'NextPlayer', 'Wrong User/Pass'];
+ 1549: Actions := ['Your account is already logged in', 5000, 0, 'RandomNextPlayer', ''];
+ 1608: Actions := ['Not a Members Account', 0, 0, 'NextPlayer', 'Non-member'];
+ 1610: Actions := ['Too many incorrect logins.', 5 * 60000, 2, 'NextPlayer', ''];
+ 2106: Actions := ['You are standing in a members-only area.', 0, 0, 'NextPlayer', 'In Mems-Only Area'];
+
+ {Havnt been updated yet =)}
+ //711: If (CountColor(16711680, 341, 219, 391, 233) = 128) then
+ // Actions := ['Your account has been disabled', 0, 0, 'NextPlayer', 'Acc Disabled'];
+ //555: Actions := ['The Server is being updated.', 60000, 4, 'Terminate', 'Server Updating'];
+ //218: Actions := ['Error Connecting.', 20000, 9, 'Terminate', 'Error Connecting'];
+ //335: Actions := ['Unable to connect Login Server offline.',(20000) + Random(6000), 4, 'Terminate', 'Login Server Offline'];
+ //512: Actions := ['RuneScape has been updated. Script Terminated.', 0, 0, 'Terminate', 'RS Updated'];
+ //489: Actions := ['Connection timed out.', 0, 4, 'Terminate', 'Connection Timed Out'];
+
+ {Not needed anymore}
+ //536: Actions := ['Login limit exceeded. Please wait 1 minute and try again.', 60000, 2, 'NextPlayer', ''];
end;

if (Length(Actions) > 0) then
@@ -416,7 +458,7 @@
Exit;
end;
Wait(100);
- until (GetColor(207, 409) = 238044) or (LoggedIn);
+ until (AtLobbyScreen) or (LoggedIn);

if (RetryLogin) then
begin
@@ -425,11 +467,20 @@
goto ProcStart;
end;

- if (GetColor(207, 409) = 238044) then
+ if (AtLobbyScreen) then
begin
Wait(500 + Random(1000));
- MouseBox(249, 419, 521, 445, 1);
+ MouseBox(80, 450, 560, 470, 1);
end;
+ Wait(500+Random(1000));
+ if (GetColor(510, 225) = 11189701) then //Checks for Right Skull in PvP Warning
+ if AllowPVP then
+ MouseBox(400, 335, 500, 355, 1)
+ else
+ begin
+ SRL_Warn('LoginPlayer', 'Attempted to log into PVP World when AllowPVP was false. Terminating.', Warn_AllVersions);
+ TerminateScript;
+ end;
MarkTime(Mark);
while (TimeFromMark(Mark) < 30000) and (not(LoggedIn)) do
Wait(1000 + Random(1000));
@@ -457,7 +508,6 @@
By: Dankness, Ron, Raymond & ZephyrsFury
Description: Returns the player number of the next active player.
*******************************************************************************}
-
function NextPlayerIndex: Integer;
begin
if (AllPlayersInactive) then
@@ -475,7 +525,6 @@
By: Dankness, Ron, Raymond & ZephyrsFury
Description: Returns the Player number of a random active player.
*******************************************************************************}
-
function RandomPlayerIndex: Integer;
var
N: Integer;
@@ -493,13 +542,13 @@
end;
Result := N;
end;
+
{*******************************************************************************
function SwitchToPlayer(PlayerNo: Integer; Active: Boolean): Boolean;
By: Dankness, Ron, Raymond & ZephyrsFury
Description: Switches to a specific player, setting the current player's
activity to True or False.
*******************************************************************************}
-
function SwitchToPlayer(PlayerNo: Integer; Active: Boolean): Boolean;
begin
WriteLn('SwitchToPlayer(PlayerNo: ' + IntToStr(PlayerNo) + ', Active: ' + BoolToStr(Active)+ ');');
@@ -521,7 +570,6 @@
Description: Logs in the next player that isn't inactive.
Boolean: True - Current player is ok. False - Current player is false.
*******************************************************************************}
-
procedure NextPlayer(Active: Boolean);
var
srl_PlayerIndexFunc: function: Integer;
@@ -552,7 +600,6 @@
Description: Logs in a random player that isn't inactive.
Boolean: True - Current player is ok. False - Current player is false.
*******************************************************************************}
-
procedure RandomNextPlayer(Active: Boolean);
var
tmpBool: Boolean;
@@ -568,7 +615,6 @@
By: Sumilion, Raymond, and Nava2
Description: Checks if all nicks are set correct.
*******************************************************************************}
-
procedure CheckUserNicks;
var
I, II: Integer;
Index: SRL/core/Players.scar
===================================================================
--- SRL/core/Players.scar (revision 405)
+++ SRL/core/Players.scar (working copy)
@@ -16,6 +16,7 @@
Name: string; // * User Name
Pass: string; // * User Pass
Pin: string; // * Current Users Pin Number
+ Member: boolean; // * For Login
Nick: string; // * Screen Name for random detection
NickTPA: TPointArray; // * TPA Of Player Name
Level: array[0..24] of Word; // * Levels of all skills.

i luffs yeww

2010-03-03 22:44:33

Use a much smaller bitmap. ;)

Dgby714

2010-03-03 22:48:40

From: i luffs yeww
Use a much smaller bitmap. ;)


15x15?

i luffs yeww

2010-03-03 22:52:34

small as you can with it still being 100% accurate. And usually you don't need a square bitmap. a 7 x 2 will usually suffice. :)

Dgby714

2010-03-03 23:00:31

From: i luffs yeww
small as you can with it still being 100% accurate. And usually you don't need a square bitmap. a 7 x 2 will usually suffice. :)


lol well before you said that i made a 5x5 and one when the mouse is over it and it changes color =)

i luffs yeww

2010-03-03 23:04:06

Uhh.. so then does it work? :p If not (due to the alternating colors), then you should just make another bitmap to look for when your mouse is on it. :) This one can be very small. And to test it, look for it without the mouse over, then again with the mouse over. If it finds it without the mouse over, try again. ^^

Dgby714

2010-03-03 23:07:28

Ok made 2x2 for it normal and highlighted they work (for me) on all the tabs

i luffs yeww

2010-03-03 23:21:46

;) Congratulations. And good work.


for i := 0 to 10 do
begin
Wait(1000);
if not(LoggedIn)then
Result := True;
end;

You never Inc(i); ;)

Dgby714

2010-03-03 23:28:23

Now to try fixing LoginPlayer; =)

i luffs yeww

2010-03-03 23:29:50

Read my edit. :p

Also, the edit you did to the old Logout won't work. You've three begins and only one end. ;)

And this doesn't work in Simba. Which it should, since we're going all Simba soon.

Dgby714

2010-03-04 00:17:28

From: i luffs yeww
Read my edit. :p

Also, the edit you did to the old Logout won't work. You've three begins and only one end. ;)

And this doesn't work in Simba. Which it should, since we're going all Simba soon.


there is no inc(i) its inc©

I get "Compiled succesfully in 639 ms." in Simba idk why yours dosnt work.

i luffs yeww

2010-03-04 00:53:06


for i := 0 to 10 do
begin
Wait(1000);
if not(AtLobbyScreen)then
Result := True;
end;

You need an Inc(i) there.. It'll always stay at 0 right now.

Dgby714

2010-03-04 00:56:25

Still working on LoginPlayer; =)

Anyone got a banned account i can borrow for a sec?

From: i luffs yeww

for i := 0 to 10 do
begin
Wait(1000);
if not(AtLobbyScreen)then
Result := True;
end;

You need an Inc(i) there.. It'll always stay at 0 right now.


not for a for (that came out wrong)
if i did
repeat 
until(i >= 10)
i would need one but for a for you dont (wow whats wrogn with me?) try this
program test;
var
i: integer;
begin
for i := 0 to 10 do
WriteLn(IntToStr(i));
end.

i luffs yeww

2010-03-04 10:02:21

Oh shit what am I thinking? Haha sorry. Why do you need a banned account?

Dgby714

2010-03-04 10:03:44

From: i luffs yeww
Oh shit what am I thinking? Haha sorry. Why do you need a banned account?


to update a line in Login.scar….

Line:
        711: If (CountColor(16711680, 341, 219, 391, 233) = 128) then
Actions := ['Your account has been disabled', 0, 0, 'NextPlayer', 'Acc Disabled'];

-=uber*1337=-

2010-03-04 15:59:45

Is there a function that selects safe mode?
Even when I log in manually, all of the scripts select safe mode resolution, over, and over, and over, and over.
What could be causing that?

i luffs yeww

2010-03-04 19:08:24

You have to be in safe mode to auto. :p Set it before you auto.

Coh3n

2010-03-04 19:11:36

You don't even need to use bitmaps. Just use a GetColor(). :)

Good job, though.

EDIT: Also, for your new Logout function, you should use ExitToLobby, and then click the X in the lobby screen. There's no point in repeating code when you don't need to.

EDIT2: You could also add a toLobby: Boolean parameter to Logout, rather than a whole new function, but that may cause a lot of compiling errors throughout SRL.

RAM

2010-03-04 19:43:19

Looks Good, I like how you commented everything, but it would have been a bit more useful if you posted the actual edited version, such as I pm-ed you about ;)

ZephyrsFury

2010-03-05 06:05:21

Thanks for this. I added a combined version of this and Blumblebee's fixes to the dev repos. Expect it to be in the public repos soon. Good job :)

Blumblebee

2010-03-05 11:33:35

no problem, thanks for using some of my work :)

-=uber*1337=-

2010-03-05 13:34:45

Just updated and everything worked great.
Ran twice.
And the third, fourth and fifth time i got this:
[Runtime Error] : Out Of Range in line 297 in script C:\Users\Admin\Desktop\SCAR\SCAR 3.23 Beta\includes\SRL\SRL\Core\Login.scar
*Note: using http://www.villavu.com/repositories/srl-opendev

Mrbanana

2010-03-05 15:48:46

From: -=uber*1337=-
Just updated and everything worked great.
Ran twice.
And the third, fourth and fifth time i got this:
[Runtime Error] : Out Of Range in line 297 in script C:\Users\Admin\Desktop\SCAR\SCAR 3.23 Beta\includes\SRL\SRL\Core\Login.scar
*Note: using http://www.villavu.com/repositories/srl-opendev


I also get this error.

Line 297
  if (SRL_Procs[srl_OnExitToLobby] <> nil) then