Skip to content
FMFallout Multiplayer Scripting APIScripting guides and API
Data shapeServer APIGenerated

EventBus

Defined in: server/api.d.ts:3806

Asynchronous resource event bus.

emit(eventName, …args): Promise<void>

Defined in: server/api.d.ts:3857

Invokes every shared handler and waits for all synchronous and asynchronous results.

string

Shared event name.

…unknown[]

Arguments delivered to every matching handler.

Promise<void>

Promise rejected with an AggregateError when one or more handlers fail.


emitAllClients(eventName, payload?): void

Defined in: server/api.d.ts:3895

Broadcasts a named event to every connected client’s shared Events handlers.

string

Client shared-event name.

unknown

Optional payload. A string is sent as is and must already be JSON text: each client parses it and drops an event that does not parse. Other values are JSON-serialized.

void


emitLocal(eventName, …args): Promise<void>

Defined in: server/api.d.ts:3881

Emits an event only within the calling resource.

string

Private local event name.

…unknown[]

Arguments delivered only to handlers owned by the calling resource.

Promise<void>

Promise rejected when one or more local handlers fail.


emitTo(resourceName, eventName, …args): Promise<void>

Defined in: server/api.d.ts:3866

Invokes matching handlers belonging only to one resource.

string

Destination running resource.

string

Shared event name.

…unknown[]

Arguments delivered to matching handlers owned by the destination.

Promise<void>

Promise rejected when one or more destination handlers fail.


listenerCount(eventName): number

Defined in: server/api.d.ts:3888

Counts persistent and one-shot shared handlers across resources.

string

Shared event name to inspect.

number

Number of matching handlers.


off<K>(eventName, handler): void

Defined in: server/api.d.ts:3842

Removes a matching handler owned by the calling resource.

K extends keyof EventMap

K

Case-sensitive event name.

(…args) => unknown

Resource-owned callback invoked with the emitted arguments.

void

off(eventName, handler): void

Defined in: server/api.d.ts:3849

Removes a matching handler owned by the calling resource.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

void


offClient(eventName, handler): void

Defined in: server/api.d.ts:3917

Removes a matching client-originated event handler owned by the calling resource.

string

Case-sensitive event name.

(player, payload?) => unknown

Resource-owned callback invoked with the sending player and the parsed payload, which is absent when the client sent none. The payload is untrusted.

void


on<K>(eventName, handler): Unsubscribe

Defined in: server/api.d.ts:3813

Registers a persistent handler in the shared event namespace.

K extends keyof EventMap

K

Case-sensitive event name.

(…args) => unknown

Resource-owned callback invoked with the emitted arguments.

Unsubscribe

Function that removes this exact subscription.

on(eventName, handler): Unsubscribe

Defined in: server/api.d.ts:3821

Registers a persistent handler in the shared event namespace.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

Unsubscribe

Function that removes this exact subscription.


once<K>(eventName, handler): void

Defined in: server/api.d.ts:3828

Registers a handler that is removed before its first invocation.

K extends keyof EventMap

K

Case-sensitive event name.

(…args) => unknown

Resource-owned callback invoked with the emitted arguments.

void

once(eventName, handler): void

Defined in: server/api.d.ts:3835

Registers a handler that is removed before its first invocation.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

void


onceClient(eventName, handler): void

Defined in: server/api.d.ts:3910

Registers a one-shot server handler for a client-originated event.

string

Case-sensitive event name.

(player, payload?) => unknown

Resource-owned callback invoked with the sending player and the parsed payload, which is absent when the client sent none. The payload is untrusted.

void


onClient(eventName, handler): Unsubscribe

Defined in: server/api.d.ts:3903

Registers a persistent server handler for events originating from clients; this namespace is isolated from native events.

string

Case-sensitive event name.

(player, payload?) => unknown

Resource-owned callback invoked with the sending player and the parsed payload, which is absent when the client sent none. The payload is untrusted.

Unsubscribe

Function that removes this exact subscription.


onLocal(eventName, handler): void

Defined in: server/api.d.ts:3873

Registers a handler in the calling resource’s private local-event namespace.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

void