Clientside Scripting Reference

In Skyrim Multiplayer there are no dedicated clientside scripts. Code snippets that runs client-side are passed as strings to makeProperty, updateOwner and updateNeighbor which are described in Serverside Scripting Reference.

ctx.sp

Refers to Skyrim Platform API. See Skyrim Platform page.

// Print to console
ctx.sp.printConsole("Hello Skyrim Platform!");
// Kill player character (locally)
ctx.sp.Game.getPlayer().kill();

ctx.refr

In makeProperty is always undefined.

In updateOwner is similar to ctx.sp.Game.getPlayer().

In updateNeighbor refers to neighbor synchronized ObjectReference or Actor.

const pos = [
ctx.refr.getPositionX(),
ctx.refr.getPositionY(),
ctx.refr.getPositionZ()
];

ctx.value

In makeProperty is always undefined.

In updateOwner / updateNeighbor is equal to the value of a property that is processed currently or undefined if there is no value or it's not visible due to flags.

ctx.sp.Game.setPlayerLevel(ctx.value || 1);

ctx.state

A writable object that is used to store data between updateOwner/updateNeighbor calls or makeProperty initializations.

state is currently shared between properties.

ctx.state.x = "y";

ctx.get()

Get the value of the specified property. Built-in properties are not supported properly, so attempts getting them are leading to the undefined behavior.

const v = ctx.get("myAwesomeProperty");

ctx.getFormIdInServerFormat()

Gets serverside formId by clientside formId or 0 if not found.

const serversideFormId = ctx.getFormIdInServerFormat(0xff00016a);

ctx.getFormIdInClientFormat()

Opposite to getFormIdInServerFormat. Gets clientside formId by serverside formId or 0 if not found.

const clientsideFormId = ctx.getFormIdInClientFormat(0xff000000);

ctx.respawn()

Respawns ctx.refr immediately.

ctx.respawn();

ctx.sendEvent()

Available only in makeProperty context. Sends an event to the server.

ctx.sendEvent({ foo: 'bar' });