Server functions

class ServerFunctions

Public Static Functions

static void LogMessage(unsigned short level, const char *message) noexcept

Write a log message with its own timestamp.

It will have “[Script]:” prepended to it so as to mark it as a script-generated log message.

Parameters
  • level – The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN, 3 for LOG_ERROR, 4 for LOG_FATAL).

  • message – The message logged.

Returns

void

static void LogAppend(unsigned short level, const char *message) noexcept

Write a log message without its own timestamp.

It will have “[Script]:” prepended to it so as to mark it as a script-generated log message.

Parameters
  • level – The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN, 3 for LOG_ERROR, 4 for LOG_FATAL).

  • message – The message logged.

Returns

void

static void StopServer(int code) noexcept

Shut down the server.

Parameters

code – The shutdown code.

Returns

void

static void Kick(unsigned short pid) noexcept

Kick a certain player from the server.

Parameters

pid – The player ID.

Returns

void

static void BanAddress(const char *ipAddress) noexcept

Ban a certain IP address from the server.

Parameters

ipAddress – The IP address.

Returns

void

static void UnbanAddress(const char *ipAddress) noexcept

Unban a certain IP address from the server.

Parameters

ipAddress – The IP address.

Returns

void

static bool DoesFilePathExist(const char *filePath) noexcept

Check whether a certain file path exists.

This will be a case sensitive check on case sensitive filesystems.

Whenever you want to enforce case insensitivity, use GetCaseInsensitiveFilename() instead.

Returns

Whether the file exists or not.

static const char *GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept

Get the first filename in a folder that has a case insensitive match with the filename argument.

This is used to retain case insensitivity when opening data files on Linux.

Returns

The filename that matches.

static const char *GetDataPath() noexcept

Get the path of the server’s data folder.

Returns

The data path.

static unsigned int GetMillisecondsSinceServerStart() noexcept

Get the milliseconds elapsed since the server was started.

Returns

The time since the server’s startup in milliseconds.

static const char *GetOperatingSystemType() noexcept

Get the type of the operating system used by the server.

Note: Currently, the type can be “Windows”, “Linux”, “OS X” or “Unknown OS”.

Returns

The type of the operating system.

static const char *GetArchitectureType() noexcept

Get the architecture type used by the server.

Note: Currently, the type can be “64-bit”, “32-bit”, “ARMv#” or “Unknown architecture”.

Returns

The architecture type.

static const char *GetServerVersion() noexcept

Get the TES3MP version of the server.

Returns

The server version.

static const char *GetProtocolVersion() noexcept

Get the protocol version of the server.

Returns

The protocol version.

static int GetAvgPing(unsigned short pid) noexcept

Get the average ping of a certain player.

Parameters

pid – The player ID.

Returns

The average ping.

static const char *GetIP(unsigned short pid) noexcept

Get the IP address of a certain player.

Parameters

pid – The player ID.

Returns

The IP address.

static unsigned short GetPort() noexcept

Get the port used by the server.

Returns

The port.

static unsigned int GetMaxPlayers() noexcept

Get the maximum number of players.

Returns

Max players

static bool HasPassword() noexcept

Checking if the server requires a password to connect.

Returns

Whether the server requires a password

static bool GetDataFileEnforcementState() noexcept

Get the data file enforcement state of the server.

If true, clients are required to use the same data files as set for the server.

Returns

The enforcement state.

static bool GetScriptErrorIgnoringState() noexcept

Get the script error ignoring state of the server.

If true, script errors will not crash the server.

Returns

The script error ignoring state.

static void SetGameMode(const char *gameMode) noexcept

Set the game mode of the server, as displayed in the server browser.

Parameters

gameMode – The new game mode.

Returns

void

static void SetHostname(const char *name) noexcept

Set the name of the server, as displayed in the server browser.

Parameters

name – The new name.

Returns

void

static void SetServerPassword(const char *password) noexcept

Set the password required to join the server.

Parameters

password – The password.

Returns

void

static void SetDataFileEnforcementState(bool state) noexcept

Set the data file enforcement state of the server.

If true, clients are required to use the same data files as set for the server.

Parameters

state – The new enforcement state.

Returns

void

static void SetScriptErrorIgnoringState(bool state) noexcept

Set whether script errors should be ignored or not.

If true, script errors will not crash the server, but could have any number of unforeseen consequences, which is why this is a highly experimental setting.

Parameters

state – The new script error ignoring state.

Returns

void

static void SetRuleString(const char *key, const char *value) noexcept

Set a rule string for the server details displayed in the server browser.

Parameters
  • key – The name of the rule.

  • value – The string value of the rule.

Returns

void

static void SetRuleValue(const char *key, double value) noexcept

Set a rule value for the server details displayed in the server browser.

Parameters
  • key – The name of the rule.

  • value – The numerical value of the rule.

Returns

void

static void AddDataFileRequirement(const char *dataFilename, const char *checksumString) noexcept

Add a data file and a corresponding CRC32 checksum to the data file loadout that connecting clients need to match.

It can be used multiple times to set multiple checksums for the same data file.

Note: If an empty string is provided for the checksum, a checksum will not be required for that data file.

Parameters
  • dataFilename – The filename of the data file.

  • checksumString – A string with the CRC32 checksum required.