Miscellaneous functions

class MiscellaneousFunctions

Public Static Functions

bool DoesFileExist(const char *filePath)

Check whether a certain file exists.

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

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

Return
Whether the file exists or not.

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

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.

Return
The filename that matches.

unsigned int GetLastPlayerId()

Get the last player ID currently connected to the server.

Every player receives a unique numerical index known as their player ID upon joining the server.

Return
The player ID.

int GetCurrentMpNum()

Get the current (latest) mpNum generated by the server.

Every object that did not exist in an .ESM or .ESP data file and has instead been placed or spawned through a server-sent packet has a numerical index known as its mpNum.

When ObjectPlace and ObjectSpawn packets are received from players, their objects lack mpNums, so the server assigns them some based on incrementing the server’s current mpNum, with the operation’s final mpNum becoming the server’s new current mpNum.

Return
The mpNum.

void SetCurrentMpNum(int mpNum)

Set the current (latest) mpNum generated by the server.

When restarting a server, it is important to revert to the previous current (latest) mpNum as stored in the server’s data, so as to avoid starting over from 0 and ending up assigning duplicate mpNums to objects.

Return
void
Parameters
  • mpNum: The number that should be used as the new current mpNum.

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

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.

Return
void
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.

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

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.

Return
void
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.