Skip to content
ASArcaneMP Scripting APIScripting reference
Data shapeServer APIGenerated

EventBus

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

Asynchronous resource event bus.

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

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

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:6962

Broadcasts a named event to every connected client’s shared Events handlers. Throws a RangeError when the name is over 1 KiB or the payload over 1 MiB.

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. At most 1 MiB once serialized.

void


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

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

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:6933

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:6955

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:6909

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:6916

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:6984

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:6880

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:6888

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:6895

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:6902

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:6977

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:6970

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:6940

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