# Login Handles logging in players. Summary: - Add players with `Login.AddPlayer` - Login the current player with `Login.LoginPlayer` - Switch to the next player with `Login.NextPlayer` Example: ```pascal Login.AddPlayer('myusername', 'mypassword'); if not Login.LoginPlayer() then TerminateScript('Failed to login!'); ``` - - - (TRSLoginPlayer)= ## type TRSLoginPlayer ```pascal TRSLoginPlayer = record User: String; Password: String; Pin: String; Worlds: TIntegerArray; Active: Boolean; BioHash: Double; end; ``` Type responsible for managing player data. You usually don't use this directly but instead use TRSLogin methods to interact with TRSLoginPlayers stored in TRSLogin.Players array. The **Active** variable decides wether the player is inteded to be skipped or not by TRSLogin. - - - (TRSLogin)= ## type TRSLogin ```pascal TRSLogin = record(TRSInterface) Players: array of TRSLoginPlayer; PlayerIndex: Int32; AllowDangerousWorlds: Boolean; end; ``` Type responsible for handling login and managing cached TRSLoginPlayers. - - - ## LOGIN_MESSAGES ```pascal LOGIN_MESSAGE_NONE = ''; LOGIN_MESSAGE_CONNECTING = 'Connecting to server'; LOGIN_MESSAGE_INVALID_CREDENTIALS = 'Invalid credentials'; LOGIN_MESSAGE_NEED_SKILL_TOTAL = 'You need a skill total of'; LOGIN_MESSAGE_INVALID_USER_PASS = 'Please enter your username/email address.'; LOGIN_MESSAGE_ERROR_CONNECTING = 'Error connecting to server'; LOGIN_MESSAGE_ACCOUNT_NOT_LOGGED_OUT = 'Your account has not logged out'; LOGIN_MESSAGE_LOGIN_SERVER_OFFLINE = 'Login server offline'; LOGIN_MESSAGE_ERROR_LOADING_PROFILE = 'Error loading your profile'; LOGIN_MESSAGE_CONNECTION_TIMED_OUT = 'Connection timed out'; LOGIN_MESSAGE_LOGIN_LIMIT_EXCEEDED = 'Login limit exceeded'; LOGIN_MESSAGE_WORLD_FULL = 'This world is full'; LOGIN_MESSAGE_ACCOUNT_DISABLED = 'Your account has been disabled'; LOGIN_MESSAGE_ACCOUNT_RULE_BREAKER = 'Your account has been involved'; LOGIN_MESSAGE_MEMBERS = 'You need a members account'; LOGIN_MESSAGE_IN_MEMBERS_AREA = 'You are standing in a members-only area'; LOGIN_MESSAGE_AUTHENTICATOR = 'Authenticator'; ``` Global constants for most if not all login messages. Each of this messages is stored in **LOGIN_MESSAGES** in the same order. - - - ## Login.FindText ```pascal function TRSLogin.FindText(Text: String; out B: TBox): Boolean; function TRSLogin.FindText(Text: String): Boolean; overload; ``` Internal TRSLogin method used to find a message on the TRSLogin interface. You probably will never to use this directly. - - - ## Login.IsReady ```pascal function TRSLogin.IsReady(): Boolean; ``` Checks if the login screen is ready to login. In other words, has no dialogs up. Example: ```pascal WriteLn Login.IsReady(); ``` - - - ## Login.UsingLauncher ```pascal function TRSLogin.UsingLauncher(): Boolean; ``` Checks if the client was launched by a launcher (Steam/Jagex Launcher) or was manually ran by the user. Example: ```pascal WriteLn Login.UsingLauncher(); ``` - - - ## Login.ClickText ```pascal function TRSLogin.ClickText(Text: String): Boolean; ``` Internal TRSLogin method used to find the specified **Text** on the TRSLogin interface and click it. You probably will never to use this directly. - - - ## Login.ClickWorld ```pascal function TRSLogin.ClickWorld(World: Int32): Boolean; ``` Internal TRSLogin method used to click a world on the login interface. You probably will never to use this directly. - - - ## Login.IsOpen ```pascal function TRSLogin.IsOpen(): Boolean; ``` TRSLogin method used to check if we are on the login screen. Example: ```pascal WriteLn Login.IsOpen(); ``` - - - ## Login.IsWorldSwitcherOpen ```pascal function TRSLogin.IsWorldSwitcherOpen(): Boolean; ``` TRSLogin method used to check if the login world switcher is open. Example: ```pascal WriteLn Login.IsWorldSwitcherOpen(); ``` - - - ## Login.OpenWorldSwitcher ```pascal function TRSLogin.OpenWorldSwitcher(): Boolean; ``` TRSLogin method used to open the login screen world switcher. Example: ```pascal if not Login.IsWorldSwitcherOpen() then WriteLn Login.OpenWorldSwitcher(); ``` - - - ## Login.CloseWorldSwitcher ```pascal function TRSLogin.CloseWorldSwitcher(): Boolean; ``` TRSLogin method used to close the login screen world switcher. Example: ```pascal if Login.IsWorldSwitcherOpen() then WriteLn Login.CloseWorldSwitcher(); ``` - - - ## Login.GetCurrentWorld ```pascal function TRSLogin.GetCurrentWorld(): Int32; ``` Returns the currently selected world. Example: ```pascal WriteLn Login.GetCurrentWorld(); ``` - - - ## Login.SwitchToWorld ```pascal function TRSLogin.SwitchToWorld(World: Int32): Boolean; ``` Attempts to switch the current world to the **World** specified. Example: ```pascal WriteLn Login.SwitchToWorld(303); ``` - - - ## Login.HandleDialogs ```pascal function TRSLogin.HandleDialogs(): Boolean; ``` Internal TRSLogin method used to handle the dialog messages. You probably will never need to call this directly. - - - ## Login.EnterField ```pascal function TRSLogin.EnterField(Field, Details: String): Boolean; ``` Used to enter player details in the login screen. This is not an internal method but you probably will never need to call this directly. Example: ```pascal WriteLn Login.EnterField('Login:', 'my user name') and Login.EnterField('Password:', 'my password'); ``` - - - ## Login.GetLoginMessage ```pascal function TRSLogin.GetLoginMessage(): String; ``` Returns the login message that matches any of the messages stored in the constant **LOGIN_MESSAGES**. This is not an internal method but you probably will never need to call this directly. Example: ```pascal WriteLn Login.GetLoginMessage(); ``` - - - ## Login.HandleMessage ```pascal function TRSLogin.HandleMessage(Message: String): Boolean; ``` Attempts to handle the currently displayed login message. This is not an internal method but you probably will never need to call this directly. Example: ```pascal WriteLn Login.HandleMessage(Login.GetLoginMessage()); ``` - - - ## Login.EnterGame ```pascal function TRSLogin.EnterGame(): Boolean; ``` Attempts to login into the game. This is not an internal method but you probably will never need to call this directly. This assumes that the player username and password are already filled in. Example: ```pascal if Login.EnterField('Login:', 'my user name') and Login.EnterField('Password:', 'my password') then WriteLn Login.EnterGame(); ``` - - - ## Login.GetPlayer ```pascal function TRSLogin.GetPlayer(): TRSLoginPlayer; ``` Returns the currently selected TRSLoginPlayer. The currently selected TRSLoginPlayer is decided by TRSLogin.PlayerIndex which is an index of the TRSLogin.Players array. Example: ```pascal WriteLn Login.GetPlayer().Username; ``` - - - ## Login.DoLogin ```pascal function TRSLogin.DoLogin(player: TRSLoginPlayer; launcher: Boolean = False): Boolean; ``` Performs a login in the loginscreen with the specified player. - - - ## Login.WaitLoginMessage ```pascal function TRSLogin.WaitLoginMessage(): Boolean; ``` Waits for a login message after a login was performed, returns true if we successfully enter the game lobby. - - - ## Login.LoginPlayer ```pascal function TRSLogin.LoginPlayer(): Boolean; ``` Attempts to login the current selected player into the game. The currently selected player is decided by TRSLogin.PlayerIndex which is an index of the TRSLogin.Players array. Example: ```pascal WriteLn Login.LoginPlayer(); ``` - - - ## Login.AddPlayer ```pascal procedure TRSLogin.AddPlayer(user, pass: String; pin: String = ''; worlds: TIntegerArray = []); ``` Adds a TRSLoginPlayer to the TRSLogin.Players array. Example: ```pascal Login.AddPlayer('my username', 'my password', '0000'); //Adds a player to TRSLogin.Players Login.PlayerIndex := High(Login.Players); //Our added TRSLoginPlayer will be the last in the array. Login.LoginPlayer(); //Login Login.Players[Login.PlayerIndex] ``` - - - ## Login.NextPlayer ```pascal procedure TRSLogin.NextPlayer(DisableCurrentPlayer: Boolean); ``` This basically increments TRSLogin.PlayerIndex to the next TRSLoginPlayer that has the **Active** variable set to true. If TRSLogin.PlayerIndex is already set to our last TRSLoginPlayer, then it's reset to 0 and set to the first **Active** player. Example: ```pascal WriteLn Login.PlayerIndex; Login.NextPlayer(True); //Make sure you have a couple of players to run this example properly. WriteLn Login.PlayerIndex; ``` - - - ## Login.GetPlayerPin ```pascal function TRSLogin.GetPlayerPin(): String; ``` Get the current player bank pin. Example: ```pascal if BankPin.IsOpen() then BankPin.Enter(Login.GetPlayerPin()); ``` - - - ## Login.GetPlayerBioHash ```pascal function TRSLogin.GetPlayerBioHash(): Double; ``` Get the current player BioHash. Example: ```pascal WriteLn Login.GetPlayerBioHash(); ``` - - - ## Login.Draw ```pascal procedure TRSLogin.Draw(Bitmap: TMufasaBitmap); override; ``` Internal TRSLogin method used for debugging. You probably will never need to call this directly but can be useful for debugging. This is automatically called with **SRL.Debug()**. Example: ```pascal SRL.Debug(); ``` - - - ## Login.Setup ```pascal procedure TRSLogin.Setup(); override; ``` Internal TRSLogin setup method. This is automatically called by SRL and you probably will never need to call this directly. - - - ## Login.SetupAlignment ```pascal procedure TRSLogin.SetupAlignment(Mode: ERSClientMode); override; ``` Internal TRSLogin aligment method. This is automatically called by SRL and you probably will never need to call this directly. This is responsible for setting up the TRSLogin interface coordinates. - - - (Login)= ## var Login Global TRSLogin variable.