# 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!'); ``` - - - (TLoginPlayer)= ## type TLoginPlayer ```pascal TLoginPlayer = 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 TLogin methods to interact with TLoginPlayers stored in TLogin.Players array. The **Active** variable decides wether the player is inteded to be skipped or not by TLogin. - - - (TLogin)= ## type TLogin ```pascal TLogin = record(TInterface) Players: array of TLoginPlayer; PlayerIndex: Int32; AllowDangerousWorlds: Boolean; end; ``` Type responsible for handling login and managing cached TLoginPlayers. - - - ## 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 TLogin.FindText(Text: String; out B: TBox): Boolean; function TLogin.FindText(Text: String): Boolean; overload; ``` Internal TLogin method used to find a message on the TLogin interface. You probably will never to use this directly. - - - ## Login.IsReady ```pascal function TLogin.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 TLogin.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 TLogin.ClickText(Text: String): Boolean; ``` Internal TLogin method used to find the specified **Text** on the TLogin interface and click it. You probably will never to use this directly. - - - ## Login.ClickWorld ```pascal function TLogin.ClickWorld(World: Int32): Boolean; ``` Internal TLogin method used to click a world on the login interface. You probably will never to use this directly. - - - ## Login.IsOpen ```pascal function TLogin.IsOpen(): Boolean; ``` TLogin method used to check if we are on the login screen. Example: ```pascal WriteLn Login.IsOpen(); ``` - - - ## Login.IsWorldSwitcherOpen ```pascal function TLogin.IsWorldSwitcherOpen(): Boolean; ``` TLogin method used to check if the login world switcher is open. Example: ```pascal WriteLn Login.IsWorldSwitcherOpen(); ``` - - - ## Login.OpenWorldSwitcher ```pascal function TLogin.OpenWorldSwitcher(): Boolean; ``` TLogin method used to open the login screen world switcher. Example: ```pascal if not Login.IsWorldSwitcherOpen() then WriteLn Login.OpenWorldSwitcher(); ``` - - - ## Login.CloseWorldSwitcher ```pascal function TLogin.CloseWorldSwitcher(): Boolean; ``` TLogin method used to close the login screen world switcher. Example: ```pascal if Login.IsWorldSwitcherOpen() then WriteLn Login.CloseWorldSwitcher(); ``` - - - ## Login.GetCurrentWorld ```pascal function TLogin.GetCurrentWorld(): Int32; ``` Returns the currently selected world. Example: ```pascal WriteLn Login.GetCurrentWorld(); ``` - - - ## Login.SwitchToWorld ```pascal function TLogin.SwitchToWorld(World: Int32): Boolean; ``` Attempts to switch the current world to the **World** specified. Example: ```pascal WriteLn Login.SwitchToWorld(303); ``` - - - ## Login.HandleDialogs ```pascal function TLogin.HandleDialogs(): Boolean; ``` Internal TLogin method used to handle the dialog messages. You probably will never need to call this directly. - - - ## Login.EnterField ```pascal function TLogin.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 TLogin.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 TLogin.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 TLogin.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 TLogin.GetPlayer(): TLoginPlayer; ``` Returns the currently selected TLoginPlayer. The currently selected TLoginPlayer is decided by TLogin.PlayerIndex which is an index of the TLogin.Players array. Example: ```pascal WriteLn Login.GetPlayer().Username; ``` - - - ## Login.DoLogin ```pascal function TLogin.DoLogin(player: TLoginPlayer; launcher: Boolean = False): Boolean; ``` Performs a login in the loginscreen with the specified player. - - - ## Login.WaitLoginMessage ```pascal function TLogin.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 TLogin.LoginPlayer(): Boolean; ``` Attempts to login the current selected player into the game. The currently selected player is decided by TLogin.PlayerIndex which is an index of the TLogin.Players array. Example: ```pascal WriteLn Login.LoginPlayer(); ``` - - - ## Login.LoginPlayer overload which allows for fully customizable hop and percentage. It's coded to behave as the default if you just prefer having the option to customize. ```pascal function TLogin.LoginPlayer(randomHop; hopChance): Boolean; overload; ``` Attempts to login the current selected player into the game. The currently selected player is decided by TLogin.PlayerIndex which is an index of the TLogin.Players array. Example: ```pascal WriteLn Login.LoginPlayer(True, 90); // When on the main login lobby, has a 90% chance to hop ``` - - - ## Login.AddPlayer ```pascal procedure TLogin.AddPlayer(user, pass: String; pin: String = ''; worlds: TIntegerArray = []); ``` Adds a TLoginPlayer to the TLogin.Players array. Example: ```pascal Login.AddPlayer('my username', 'my password', '0000'); //Adds a player to TLogin.Players Login.PlayerIndex := High(Login.Players); //Our added TLoginPlayer will be the last in the array. Login.LoginPlayer(); //Login Login.Players[Login.PlayerIndex] ``` - - - ## Login.NextPlayer ```pascal procedure TLogin.NextPlayer(DisableCurrentPlayer: Boolean); ``` This basically increments TLogin.PlayerIndex to the next TLoginPlayer that has the **Active** variable set to true. If TLogin.PlayerIndex is already set to our last TLoginPlayer, 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 TLogin.GetPlayerPin(): String; ``` Get the current player bank pin. Example: ```pascal if BankPin.IsOpen() then BankPin.Enter(Login.GetPlayerPin()); ``` - - - ## Login.GetPlayerBioHash ```pascal function TLogin.GetPlayerBioHash(): Double; ``` Get the current player BioHash. Example: ```pascal WriteLn Login.GetPlayerBioHash(); ``` - - - ## Login.Draw ```pascal procedure TLogin.Draw(Bitmap: TMufasaBitmap); override; ``` Internal TLogin 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 TLogin.Setup(); override; ``` Internal TLogin setup method. This is automatically called by SRL and you probably will never need to call this directly. - - - ## Login.SetupAlignment ```pascal procedure TLogin.SetupAlignment(); overload; ``` Internal TLogin 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 TLogin interface coordinates. - - - (Login)= ## var Login Global TLogin variable.