Code:
(*
LoginPLayer
~~~~~~~~~~~
.. code-block:: pascal
function LoginPlayer: Boolean;
Logs in the Player[CurrentPlayer]. Detects most Client Login Errors
.. note::
by SRL Dev Team
Example:
.. code-block:: pascal
if (not LoggedIn()) then
begin
WriteLn('Error: Not Logged In! Fixing');
LoginPlayer();
end;
*)
function LoginPlayer: Boolean;
var
RetryLogin, B, BB: Boolean;
Actions: TVariantArray;
T, Attempts: LongInt;
label
ProcStart;
begin
ProcStart:
//Writeln('1');
if (not (Result)) then {Check if Logged in}
Result := LoggedIn;
//Writeln('2');
if (Result) then
begin
Result := True;
AddToSRLLog('Current player: ' + Capitalize(Players[CurrentPlayer].Name));
SRL_ExitedSquealOfFortune := false;
PlayerStartTime := GetSystemTime; // PlayerStartTime
if (SRL_Procs[srl_OnLogIn] <> nil) then
SRL_Procs[srl_OnLogIn]();
Exit;
end;
//Writeln('4');
if (not (LoginPlayerToLob)) then {Get to lobby screen}
Exit;
//Writeln('5');
Wait(500 + Random(500));
{World switching}
if (Length(Players[CurrentPlayer].WorldInfo) > 0) then
if (Players[CurrentPlayer].WorldInfo[0]) then
Players[CurrentPlayer].Member := True
else
Players[CurrentPlayer].Member := False;
if (WorldSwitcherEnabled) then
if (Length(Players[CurrentPlayer].WorldInfo) < 1) then
Players[CurrentPlayer].WorldInfo := [Players[CurrentPlayer].Member, 0, AllowPVP];
case Length(Players[CurrentPlayer].WorldInfo) of
2: SelectWorld(Players[CurrentPlayer].WorldInfo[1]);
3: begin
if (Players[CurrentPlayer].WorldInfo[0]) then
B := True
else
B := False;
if (Players[CurrentPlayer].WorldInfo[2]) then
BB := True
else
BB := False;
SelectWorld(RandomWorld(B, BB));
end;
end;
{Click Here to Play}
if (LobbyScreen) then
MouseBox(270, 450, 490, 470, mouse_left);
{Check responses}
T := GetSystemTime;
repeat
SetLength(Actions, 0);
if ((GetSystemTime - T) > 60000) then
Actions := ['One minute has passed... Debug: ' + ToStr(CountColor(LOGIN_TEXTCOLOUR, 260, 140, 510, 400)), 0, 0, 'NextPlayer', 'Login Failed']
else
case (CountColor(LOGIN_TEXTCOLOUR, 260, 140, 510, 400)) of //text colour points
// WriteLn Error Wait for Retrys Action Player[CurrentPlayer].Loc
364: Actions := ['Error Connecting.', 20000, 9, 'Terminate', 'Error Connecting'];
850: Actions := ['You need skill total of 1000.', 0, 9, 'PlayerTrue', '1000 skill club'];
1028: Actions := ['You are standing in a members-only area.', 0, 1, 'PlayerFalse', 'In Mems-Only Area'];
1239: Actions := ['Not a Members Account', 0, 1, 'PlayerFalse', 'Non-member'];
777: Actions := ['Login limit exceeded.', 0, 10, '', 'Waiting for login.'];
951: Actions := ['Your account is already logged in', 5000, 5, 'PlayerTrue', 'Already logged in'];
591: Actions := ['Client token changed.', 0, 0, 'RSUpdate', 'Client Token Changed'];
1606: Actions := ['Game session expired.', 0, 0, 'RSUpdate', 'Session Expired'];
-1: Actions := ['You need skill total of 1500.', 0, 9, 'PlayerTrue', '1500 skill club'];
-1: Actions := ['You need 20 combat for PvP', 0, 1, 'PlayerFalse', 'PvP warning'];
end;
if (CountColor(clWhite, 415, 336, 476, 356) = 82) then // HRW login button white colour points
begin
Wait(RandomRange(500, 1000));
if (Length(Players[CurrentPlayer].WorldInfo) > 2) then
begin
if (Players[CurrentPlayer].WorldInfo[2]) then
MouseBox(391, 361, 498, 383, mouse_left)
else begin
MouseBox(263, 362, 372, 383, mouse_left);
Players[CurrentPlayer].WorldInfo := [False, 0, AllowPVP];
RetryLogin := True;
Break;
end;
end
else
if (AllowPVP) then
MouseBox(391, 361, 498, 383, mouse_left)
else
MouseBox(263, 362, 372, 383, mouse_left);
Wait(3000 + Random(2000));
RetryLogin := true;
end;
{Respond}
if (Length(Actions) > 0) then
begin
WriteLn(Actions[0]);
Wait(Actions[1] + Random(100));
if (Actions[2] <> 0) then
if (Attempts < Actions[2]) or (Actions[2] = -1) then
begin
case Actions[0] of
'You are standing in a members-only area.': begin
Players[CurrentPlayer].Member := True;
Players[CurrentPlayer].WorldInfo := [True, 0, AllowPVP];
end;
'You need 20 combat for PvP': Players[CurrentPlayer].WorldInfo := [Players[CurrentPlayer].Member, 0, False];
'Not a Members Account': begin
Players[CurrentPlayer].Member := False;
Players[CurrentPlayer].WorldInfo := [False, 0, AllowPVP];
end;
'Login limit exceeded.': begin
Writeln('Runescape is lagging or we''re logged in too many times. Keep trying!');
Players[CurrentPlayer].WorldInfo := [players[currentPlayer].member, 0, AllowPVP];
Wait(5000+Random(10000));
end;
'You need skill total of 1000.': players[currentPlayer].worldInfo := [players[currentPlayer].member, 0, allowPVP];
end;
RetryLogin := True;
Wait(2000 + Random(1000));
Break;
end;
if (Actions[4] <> '') then
Players[CurrentPlayer].Loc := Actions[4];
case Actions[3] of
'PlayerFalse': NextPlayer(False);
'PlayerTrue':
begin
LeaveLobby();
NextPlayer(True);
end;
'Terminate': TerminateScript;
'RSUpdate':
begin
wait(randomRange(1000, 1500));
typeByte(VK_ESCAPE);
leaveLobby();
if (SRL_Procs[srl_OnRSUpdate] <> nil) then
begin
SRL_Procs[srl_OnRSUpdate]();
Exit;
end;
Writeln('Runescape has been updated! Please restart Simba.');
TerminateScript;
end;
end;
Exit;
end;
Wait(100);
Result := (LoggedIn);
until (Result);
{Back to lobby screen if needed}
if (RetryLogin) then
begin
RetryLogin := False;
Inc(Attempts);
goto ProcStart;
end;
{Set player start time ect...}
if (Result) then
goto ProcStart;
end;