Player Management

The Players file stores the functions related to the Players array. It also stores properties of the TPlayer type.

The source for this file can be found here.

Consts, Types, Vars

The following constants, types and variables are used throughout the chatBox methods.

type TPlayer

A record that stores useful information about the current players. It is up to the scripter to set most of these attributes in their scripts.

type
  TPlayer = record
    loginName: string;
    displayName: string;
    nickname: string;
    password: string;
    bankPin: string;
    location: string;
    isActive: boolean;
    isMember: boolean;
    findMod: boolean;
    findTrade: boolean;
    reincarnate: boolean;
    secureLogin: boolean;
    worked: TTimeMarker; // Automatically calculated if SRL's login methods are used
    world: integer; // -1 to click play button; 0 for random world
    skillLevel: array[0..(SKILL_COUNT - 1)] of integer;
    booleans: array[0..99] of boolean;
    integers: array[0..99] of integer;
    strings: array[0..99] of string;
    extendeds: array[0..99] of extended;
    variants: array[0..99] of variant;
  end;

var Player Variables

All the variables associated with players.simba.

  var
    players: TPlayerArray;
    currentPlayer: integer;
    disableIPScreenshots: boolean;

* players: An array which contains all players
* currentPlayer: The index of the player currently running in the players array
* disableIPScreenshots: Disables the screenshots taken in the lobby screen

isLoggedIn

function isLoggedIn(): boolean;

Returns true if a player is logged in. It uses the top left corner of the logout button to return the result.

Note

  • by Olly & Coh3n
  • Last updated: 11 August 2013 by Coh3n

Example:

if isLoggedIn() then
  writeln('We are logged in!');

TPlayerArray methods

The following methods should be called through the players variable.

Example:

if players.getActive() >=1 then
  writeln('There is still active players');

getActive

function TPlayerArray.getActive(): integer;

Returns the number of players that are still active in the TPlayerArray.

Note

  • by ss23 & Coh3n
  • Last updated: 22 December 2012 by Coh3n

Example:

while (players.getActive() > 0) do
  mainloop();

setup

procedure TPlayerArray.setup(names: TStringArray; const army: string = 'default');

Sets up the TPlayerArray with the players names . It will look for the names in the army army (default = ‘default’) . This should be used if you are not using the SRLPlayerForm, and your players are setup in Rafiki.

Note

  • by Bart (masterBB)
  • Last updated: 4 April 2013 by Bart

Example:

players.setup(['woodcutter5', 'miner3', 'fisher6'], 'BartsArmy');

setup (overload)

procedure TPlayerArray.setup(const players: PF_TPlayerArray); overload;

Same as above, except the list of players is passed from the SRL Player Form.

Note

  • by Olly

Example:

players.setup(playerForm.players);

switchTo

function TPlayerArray.switchTo(player: integer; active: boolean = true; login: boolean = true): boolean;

Switches to the player index in the TPlayerArray. Sets the previous player’s activity to active (default = true) . It will login the new player if login is set to true (default = true) .

Note

  • by Dankness, Ron, Raymond, ZephyrsFury & Coh3n
  • Last updated: 15 March 2015 by The Mayor

Example:

players.switchTo(3);
players.switchTo(3, false);
players.switchTo(3, false, false); // To switch but not login

randomNext

function TPlayerArray.randomNext(active: boolean = true; login: boolean = true): boolean;

Switches to a random active player in the TPlayerArray. Sets the previous player’s activity to active (default = true) . It will login the new player if login is set to true (default = true) .

Note

  • by ZephyrsFury & Coh3n
  • Last updated: 15 March 2015 by The Mayor

Example:

players.randomNext();
players.randomNext(false);
players.randomNext(false, false);

TPlayer methods

The following methods should be called through the players array, with the appropriate index (normally currentPlayer) .

Example:

if players[currentPlayer].login() then
  writeln('We just logged in the player that is currently active');

write

procedure TPlayer.write();

Writes the standard information about the player to the debug box.

Note

  • by Coh3n
  • Last updated: 22 December 2012 by Zyt3x

Example:

players[currentPlayer].write();

loginToLobby

function TPlayer.loginToLobby(): boolean;

Logs the TPlayer into to the lobby. Returns true when the lobby screen is visible.

Note

  • by The SRL Developers Team
  • Last updated: 23 May 2015 by The Mayor

Example:

players[currentPlayer].loginToLobby();

login

function TPlayer.login(): boolean;

Returns true if the TPlayer is logged in to the game. Works from both the login screen and the lobby.

Note

  • by The SRL Developers Team
  • Last updated: 19 March 2015 by The Mayor

Example:

players[currentPlayer].login();

logout

function TPlayer.logout(): boolean;

Returns true if the TPlayer is logged out to the login screen

Note

  • by Coh3n
  • Last updated: 23 July 2013 by Coh3n

Example:

players[currentPlayer].logout();

exitToLobby

function TPlayer.exitToLobby(): boolean;

Returns true if the TPlayer is logged out to the lobby

Note

  • by Coh3n
  • Last updated: 14 March 2015 by The Mayor

Example:

players[currentPlayer].exitToLobby();

leaveLobby

function TPlayer.leaveLobby(): boolean;

Returns true if it returns to the login screen from the lobby.

Note

  • by Coh3n
  • Last updated: 3 March 2013 by Coh3n

Example:

players[currentPlayer].leaveLobby();

switchToWorld

function TPlayer.switchToWorld(newWorld: integer = 0): boolean;

Returns true if it switches the TPlayer to the worls newWorld (default = 0; random world)

Note

  • by Coh3n
  • Last updated: 22 June 2013 by Coh3n

Example:

players[currentPlayer].switchToWorld();
players[currentPlayer].switchToWorld(115);