Serverside Scripting Reference

Server declares mp global variable that gives access to the whole API. This page contains the list of mp object methods available to use in scripts.

mp.makeProperty()

Creates a new property that would be attached to all instances of MpActor and MpObjectReference. Values are saved to database automatically. See Properties System for more information.

/* Definition */
interface MakePropertyOptions {
  // If set to false, `updateOwner` would never be invoked
  // Player's client wouldn't see it's own value of this property
  // Reasonable for passwords and other secret values
  isVisibleByOwner: boolean;

  // If set to false, `updateNeighbor` would never be invoked
  // Player's client wouldn't see values of neighbor Actors/ObjectReferences
  isVisibleByNeighbors: boolean;

  // Body of functions that would be invoked on client every update.
  updateOwner: string; // For the PlayerCharacter
  updateNeighbor: string; // For each synchronized Actor/ObjectReference
}

interface Mp {
  // ...
  makeProperty(propertyName: string, options: MakePropertyOptions): void;
  // ...
}

/* Usage */
mp.makeProperty("playerLevel", {
    isVisibleByOwner: true,
    isVisibleByNeighbors: false,
    updateOwner: "ctx.sp.Game.setPlayerLevel(ctx.value)"
    updateNeighbor: ""
});

mp.makeEventSource()

Creates a new event source allowing you to catch specific game situations and pass them to a server as events. See Events System for more information.

mp.get()

Returns the actual value of a specified property. If there is no value, then undefined returned.

mp.set()

Changes value of the specified property.

mp.clear()

Clears added properties and event sources.

mp.sendUiMessage()

Sends a message to the user's in-game browser using WebSocket.

Last updated

Was this helpful?