Skip to main content

Global API

The global API is a set of methods available in any part of the script code.

Logging

console.log(...args: any[])
console.warn(...args: any[])
console.error(...args: any[])

Prints output to console. The only difference between these methods is log level.

console.emit(message: string, includeInLogFile: boolean): void

Emits event, which would be printed to console, and, if log file is enabled and includeInLogFile set to true, saved to log file.

Script info

script()

Returns info about current script.

Object reference:

{
name: string
version?: string
author?: string
description?: string
url?: string
}

Connected players

players()

Returns array of player objects.

Target server info

target()

Returns info about target server.

Object reference:

{
address?: {
resolved: string
input: string
}
}

Note that address will be null if called before user has configured target server. input contains raw user input, resolved contains resolved address used for connection (with port and stuff).

Colors API

colors()

Provides an instance of colors API.

Files API

file(...path: string[]): File

Provides an instance of file (files API).

Timeouts

setTimeout(callback: () => void, delay: number): number

Executes callback after specified delay (in milliseconds).

clearTimeout(id: number)

Cancels timeout with specified id.

Intervals

setInterval(callback: () => void, delay: number): number

Executes callback every specified delay (in milliseconds).

clearInterval(id: number)

Cancels interval with specified id.