Players

This file holds functions and procedures that manage and handle an array of players.

  • Ouputs a global variable ‘players’ that all players should be added to (see below).
procedure DeclarePlayers();
begin
  with Players.New()^ do
  begin
    LoginName := 'username';
    Password := 'password';
    BankPin := 'pin';

    isActive := True;
  end;

  with Players.New()^ do
  begin
    LoginName := 'username2';
    Password := 'password2';
    BankPin := 'pin2';

    isActive := True;
    World := 2; // This player will be logged into world 2
  end;
end;

TPlayerArray.SetCount

procedure TPlayerArray.SetCount(Number: Integer);

Sets the amount of players to be stored in the array.

Example:

Players.SetCount(1);

TPlayerArray.GetCount

function TPlayerArray.GetCount(): Integer;

Returns the amount of players stored in the array.

Example:

srl.Writeln(Players.GetCount());

TPlayerArray.GetCurrent

function TPlayerArray.GetCurrent(): TPlayer;

Returns a pointer to the currently used player. - Derefrence “Players.GetCurrent()^” to get a TPlayer

Example:

srl.Writeln(Players.GetCurrent()^.LoginName);
Players.GetCurrent()^.isActive := False;

TPlayerArray.SetCurrent

procedure TPlayerArray.SetCurrent(idx: Integer);

Sets the player to be currently used.

Example:

Players.SetCurrent(1);

TPlayerArray.GetActive

function TPlayerArray.GetActive(): Integer;

Returns the amount of current active players.

Example:

srl.Writeln(Players.GetActive());

TPlayerArray.GetPlayer

function TPlayerArray.GetPlayer(idx: Integer): TPlayer;

Returns the player in the index ‘idx’.

Example:

srl.Writeln(Players.GetPlayer(0).LoginName);

TPlayerArray.SwitchTo

   function TPlayerArray.SwitchTo(Index: Integer): Boolean;

- Logs out the current player
- Sets the current player as in-active and sets the new player as active
- Logs in the new (now current) player

Example:

Players.SwitchTo(1);

TPlayerArray.Next

function TPlayerArray.Next(): Boolean;

Switches and logs in the next player, will terminate the script if no active players exist.

Example:

if (Players.Next()) then
  srl.Writeln('Succesfully switched and logged in our next player');

TPlayerArray.Add

procedure TPlayerArray.Add(Player: TPlayer);

Adds the player ‘Player’ into the player array.

Example:

Players.Add(['login', 'password', '1234', True, True]);

TPlayerArray.New

function TPlayerArray.New(): PPlayer;

Creates and results a new player.


TPlayerArray.LoginCurrent

function TPlayerArray.LoginCurrent(): Boolean;

Logs in the currently active player.