OpenTTD GameScript API: GSClient Class Reference

OpenTTD GameScript API 15.0-beta1

Public Types | Static Public Member Functions
GSClient Class Reference

Class that handles all client related functions. More...

`#include <script_client.hpp>`

Inheritance diagram for GSClient:

## Public Types
enum | ClientID : int { CLIENT_INVALID , CLIENT_SERVER , CLIENT_FIRST }
| Different constants related to ClientID. More...

## Static Public Member Functions
static ClientID | ResolveClientID (ClientID client)
| Resolves the given client id to the correct index for the client.
static string | GetName (ClientID client)
| Get the name of the given client.
static GSCompany::CompanyID | GetCompany (ClientID client)
| Get the company in which the given client is playing.
static GSDate::Date | GetJoinDate (ClientID client)
| Get the economy-date when the given client has joined.

## Detailed Description

Class that handles all client related functions.

## Member Enumeration Documentation

## ◆ ClientID

enum GSClient::ClientID : int

Different constants related to ClientID.

Enumerator
CLIENT_INVALID | Client is not part of anything.
CLIENT_SERVER | Servers always have this ID.
CLIENT_FIRST | The first client ID.

## Member Function Documentation

## ◆ GetCompany()

static GSCompany::CompanyID GSClient::GetCompany | ( | ClientID | client | ) |
| static

Get the company in which the given client is playing.

Parameters

  client | The client to get company for.

Precondition
  ResolveClientID(client) != CLIENT_INVALID.

Returns
  The company in which client is playing or COMPANY_SPECTATOR.

## ◆ GetJoinDate()

static GSDate::Date GSClient::GetJoinDate | ( | ClientID | client | ) |
| static

Get the economy-date when the given client has joined.

Parameters

  client | The client to get joining date for.

Precondition
  ResolveClientID(client) != CLIENT_INVALID.

Returns
  The economy-date when client has joined.

See also
  GSEconomyTime

## ◆ GetName()

static string GSClient::GetName | ( | ClientID | client | ) |
| static

Get the name of the given client.

Parameters

  client | The client to get the name for.

Precondition
  ResolveClientID(client) != CLIENT_INVALID.

Returns
  The name of the given client.

## ◆ ResolveClientID()

static ClientID GSClient::ResolveClientID | ( | ClientID | client | ) |
| static

Resolves the given client id to the correct index for the client.

If the client with the given id does not exist it will return CLIENT_INVALID.

Parameters

  client | The client id to resolve.

Returns
  The resolved client id.