The ruined streets of Boston beneath pre-war billboards
Fallout MPScripting

Build your
Commonwealth

Create your own game modes with TypeScript and JavaScript

02Scripting

If you can script it, the server can run it

Resources are plain TypeScript or JavaScript, loaded by the server and hot-reloaded while players stay connected. The API below is the one the mod itself is built on.

A command, in twenty lines

Drop a folder in the server’s resources, export a server entry point, and it loads on startup. Greet players as they arrive in the world and hand them a starter kit on request.

serverresources/welcome/src/server/index.ts
// Form IDs come from Fallout4.esm. Look yours up in the Creation Kit or xEdit.
const kStimpak = "0x00023736";

// playerConnect fires before the player has a position. Wait for playerReady to touch the world.
Events.on("playerReady", (player: Player) => {
  Chat.sendToPlayer(player, `Welcome to the Commonwealth, ${player.nickname}. Try /kit.`);
});

Events.on("playerCommand", (player: Player, command: string, args: string[]) => {
  if (command !== "kit") return;

  // Entity state is replicated and survives nothing but the session, which is all a kit flag needs
  if (player.state.get("kitTaken")) {
    Chat.sendToPlayer(player, "You have already taken a kit.");
    return;
  }

  const count = Math.min(Number(args[0] ?? 3) || 3, 10);
  player.giveItem(kStimpak, count);
  player.state.set("kitTaken", true);

  Chat.sendToPlayer(player, `${count} stimpaks. Do not spend them all in Concord.`);
});

02Reference

The whole server API

Generated from the running server, so this page and the mod cannot disagree. Every global, class, member and event the server exposes. Client resources have an API of their own, including the Web views that draw interfaces over the game.

47 globals and classes · 653 members · 101 native events

Events

Registered with Events.on(name, handler). The signature shown is the handler's argument list.

playerConnect(player: Player)
Dispatched once a connecting player's entity exists. It has no position yet; wait for `playerReady` to place them.
playerReady(player: Player)
Dispatched once the player's world is synced and they stand in it: the moment to spawn, dress and equip them. Their inventory record follows shortly after, with their first report.
playerDisconnect(player: Player)
Dispatched while a player is leaving, before their entity is destroyed, so the handle still reads. Anything keyed on the player is cleaned up here.
playerDeath(player: Player, killer: Player | null)
Dispatched once when a player dies. `killer` is the last player who hit them, or null. Nothing brings them back on its own: call `player.respawn`.
playerShoot(player: Player)
Dispatched when a player fires, before the shot is shown to the players around them.
playerProjectile(player: Player, projectile: number, npc: Npc | null)
Dispatched when a player's game launches a projectile: a missile, a grenade in flight, a flame, or one an NPC it simulates launched (`npc`). `projectile` is the BGSProjectile form ID. Return `false` to refuse: nobody else sees it. It still flies on the shooter's own screen.
playerSpaceChange(player: Player, space: PlayerSpace, previous: PlayerSpace | null)
Dispatched when a player's game reports them in another worldspace or interior: through a door, a fast travel or `teleport`. `previous` is null for the first space they report after joining.
playerAppearanceChange(player: Player)
Dispatched when a player's game reports a new look after the one they joined with: the look editor closed, or `setLook`, `randomizeLook` or `setAppearance` changed it. `getAppearance` reads it.
playerHit(attacker: Player, victim: Player, damage: number, kind: "direct" | "blast" | "hazard" | "vats", vatsChance: number, limb: string | null, weapon: number | null)
Dispatched when a player's game lands a hit on another player, before the victim takes it. Return `false` to drop the hit. `damage` is the attacker's game's own. `kind` is a shot or a blow, an explosion's blast, a hazard the attacker left (a radiation or gas cloud), which casts its spell and carries no damage figure, or a shot of a VATS attack, whose hit the attacker's game rolled against the chance it showed: refusing one decides VATS hits on the server (their chances are the game's fVATS* settings, `setGameSetting`). `vatsChance` is the chance the attacker's VATS showed for the shot, 0 to 1, and 0 for any other kind; with `setVatsRolledByServer` every such shot strikes on the attacker's screen, and the handler rolls it, as `Math.random() < vatsChance`. `limb` is the body part struck, as the game names its types ("Head1", "LeftArm1", "Torso"...), null for a blast or none; `weapon` is the weapon form the hit came from, null for none.
playerActivatePlayer(player: Player, target: Player)
Dispatched when a player activates another player's body, the Activate button on them: where a trade, a search, a handover or any player-to-player interaction starts. The two stand within reach in the same space.
playerReload(player: Player, event: string)
Dispatched when a player starts a reload, before it is shown to the players around them. `event` is the animation event their game played.
playerAttack(player: Player, event: string)
Dispatched when a player swings a melee weapon or their fists, before it is shown to the players around them. `event` is the animation event their game took, `meleeattackStart` among others.
playerExplosion(player: Player, position: Vector3, explosion: number, npc: number | null)
Dispatched when a player's game sets off an explosion: a grenade, a mine, a missile, an explosive round, or one an NPC it simulates set off (`npc`, its network ID). `explosion` is the BGSExplosion form ID. Return `false` to refuse it: nobody else sees it and its blast lands on no one.
playerPowerArmor(player: Player, entered: boolean)
Dispatched once when a player gets into a power armor frame (`entered`) and once when they get out, however it happened.
playerSwim(player: Player, swimming: boolean)
Dispatched once when a player starts swimming and once when they are back on their feet, as their game reports it.
playerUnderwater(player: Player, underwater: boolean)
Dispatched once when the water reaches above a player's neck (`player.isUnderwater`) and once when it no longer does, as their game reports it.
playerJetpack(player: Player, firing: boolean)
Dispatched once when the jetpack of a player's power armor starts thrusting and once when it stops, as their game reports it.
playerPowerArmorBattery(player: Player, charge: number, previous: number)
Dispatched when the charge of the fusion core in a player's power armor changes, in whole units: their game drains it (a jump, among others), a new core is loaded, or `setPowerArmorBattery` set it. Not on getting in.
playerFusionCore(player: Player, kind: "consumed" | "inserted" | "ejected", core: number | null, condition: number)
Dispatched when a player's game takes a fusion core into their power armor or launches it out. `consumed`: the suit's core ran out and their game loaded the next one they carry. `inserted`: a core went into the empty suit as it reached them. `ejected`: they launched the core out of the suit (Nuclear Physicist), `core` null. `condition` is the core's charge in percent. Return `false` to refuse a core taken in: it goes back to their inventory, the suit keeps the charge it had and takes no other core until `setPowerArmorBattery` gives it a charge or they get out. A launch cannot be refused.
playerChat(player: Player, text: string)
Dispatched for a chat line, before anyone sees it. Return `false` to swallow it.
playerCommand(player: Player, command: string, args: string[])
Dispatched for a `/command arg...` line; `command` has no slash.
worldHourChange(hour: number)
Dispatched when the running clock reaches a new whole hour, 0 to 23. `World.setHour` does not raise it.
worldLightning(weather: number)
Dispatched when the server strikes lightning on its own, for a thundery weather a sky is held to: the World's, or one a player was given. `World.strikeLightning` does not raise it.
playerWeatherRegionChange(player: Player, region: number, previous: number)
Dispatched when a player's game finds them under another weather region, as they change cell: `region` is the TESRegion form ID, 0 for none. Its weathers come from `World.getRegionWeathers`.
worldDayChange(date: WorldDate, daysPassed: number)
Dispatched when the running clock passes midnight into a new day, with the new date and day count. `World.setDate` and `World.setDaysPassed` do not raise it.
doorChange(player: Player, ref: number, open: boolean)
Dispatched when a player opens or closes a door. Return `false` to refuse: their door swings back.
lockChange(player: Player, ref: number, locked: boolean)
Dispatched when a player picks, unlocks or locks a lock. Return `false` to refuse: their lock goes back.
containerOpen(player: Player, ref: number)
Dispatched when a player opens a container nobody else holds. Return `false` to keep it shut.
containerClose(player: Player, ref: number)
Dispatched when the player holding a container closes its menu; anyone may open it again.
containerChange(player: Player, ref: number, items: InventoryItem[])
Dispatched when a player's game reports what a container holds now, after they put something in or took something out. To refuse a transfer, refuse the player's `inventoryChange`, which reverts the container with it.
itemDrop(player: Player, item: Item)
Dispatched when a player drops an item. Return `false` to refuse: the item leaves the world and goes back into their inventory.
itemPickUp(player: Player, item: Item | null, ref: number | null)
Dispatched when a player picks up a loose item, before they get it: a dropped or spawned `item`, or a placed reference by its form ID as `ref`. Return `false` to refuse; the item stays where it is.
inventoryChange(player: Player, changes: InventoryDelta[])
Dispatched when a player's game reports a change the server would accept: looting, buying, crafting, using an item. Return `false` to refuse it: the server keeps its record and sends it back to their game, and any container involved keeps what it held. Changes a script made itself do not raise it.
playerCharacterLoad(player: Player)
Dispatched once a player's character is established, shortly after they join: adopted from their game. Restore a kept character here with `setCharacter`. Character methods work from here.
playerXpGain(player: Player, amount: number)
Dispatched when the player's game awards XP: a kill, a quest, a lock, a terminal, a workshop build. `amount` is the game's, Intelligence included. Return `false` to refuse it: their game takes it back.
playerLevelChange(player: Player, level: number, previous: number)
Dispatched when the character's level moves, by XP or by a script.
playerPerkRequest(player: Player, perk: number, kind: "buy" | "grant" | "remove")
Dispatched when the player's game changes a perk rank: bought on the perk chart (after the server checked points, level, the rank below and SPECIAL), given by something in the game such as a magazine, or taken away. Return `false` to refuse it: their game undoes it.
playerPerkChange(player: Player, perk: number, added: boolean)
Dispatched when a perk rank was added to or taken from the character, by their game or by a script.
playerValueRequest(player: Player, value: string, previous: number, base: number)
Dispatched when the player's game moves a SPECIAL base: the SPECIAL menu, a bobblehead, a book. `value` is its editor ID. Return `false` to refuse it: their game puts it back.
playerValueChange(player: Player, value: string, base: number, previous: number)
Dispatched when an actor value base on the character's record moved, by their game or by a script.
playerBountyChange(player: Player, faction: number, bounty: number, previous: number)
Dispatched when the bounty a player owes a crime faction changes in their game: a crime of theirs the faction saw, a payment, or `setBounty` / `addBounty`. `bounty` is the crime gold now, violent and not together. Where wanted levels and police chases start.
zoneEnter(player: Player, zone: number, name: string)
Dispatched when a player comes into a zone `Zone.create` made, or is in it when it is made.
zoneLeave(player: Player, zone: number, name: string)
Dispatched when a player goes out of a zone, or the zone is removed around them. A player who leaves the server is not told.
playerFastTravel(player: Player, destination: number)
Dispatched when a player's game is about to fast travel: a marker picked on the Pip-Boy map, or the game's own scripts. `destination` is the reference they would arrive at, a map marker's form ID. Their game waits for the answer. Return `false` to refuse it: they stay where they are. Otherwise they travel.
playerLocationChange(player: Player, location: number | null, previous: number | null)
Dispatched when a player's game moves them into another named location (a BGSLocation form ID), or out into the open (null). `previous` is null for the first one they report after joining.
playerMapWaypoint(player: Player, position: Vector3 | null)
Dispatched when a player drops their own marker on the Pip-Boy map, or removes it (`position` null). Return `false` to refuse it: their game puts back what they had.
playerLockpickStart(player: Player, ref: number)
Dispatched when a player's game is about to open the lockpicking minigame on a locked door or container (`ref`, the placed reference's form ID). Their game waits for the answer. Return `false` to refuse it: the lock stays shut and no pick is spent. Otherwise their game opens it, still checking their bobby pins and whether the lock can be picked at all. `playerLockPick` and `lockChange` follow a pick.
playerTerminalOpen(player: Player, ref: number)
Dispatched when a player sits at a terminal (`ref`, the placed reference's form ID) and their game is about to open it. Their game waits for the answer, the player seated. Return `false` to refuse it: they get up without it opening. Otherwise it opens, its hacking minigame first while it is locked. The client's `References.getTerminal` reads what it holds.
playerSleepWait(player: Player, ref: number, sleep: boolean)
Dispatched when a player's game is about to open the sleep and wait menu: `sleep` true for a bed they activated, false for waiting in a seat they sit in (`ref`, the placed reference's form ID; 0 for one placed at runtime). Their game waits for the answer. Return `false` to refuse it: no menu opens and no hours pass. Otherwise it opens as the game would, still refused by the game itself with enemies near, in the air, taking damage and so on. The hours a player then sleeps or waits pass on their own game only and their health heals; the server's clock is the World's, and their game's clock goes back to it once the menu closes.
playerTerminalHack(player: Player, terminal: number | null)
Dispatched when a player hacks a terminal: the password was found. `terminal` is the terminal reference's form ID. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerLockPick(player: Player)
Dispatched when a player picks a lock in the lockpicking minigame. `lockChange` follows with the reference. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerCraft(player: Player, workbench: number | null, recipe: number | null, item: number | null, count: number)
Dispatched when a player makes something at a workbench: cooking, chemistry, or a weapon or armor mod. `workbench` is the bench's base furniture, `recipe` the constructible object used, `item` what it makes and `count` how many, as the recipe says. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerContainerLoot(player: Player, container: number | null)
Dispatched when a player takes something from a container. `container` is the container reference's form ID. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerBookRead(player: Player, book: number | null)
Dispatched when a player reads a book or magazine, the TESObjectBOOK form ID. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerPickpocket(player: Player, victim: number | null, success: boolean)
Dispatched when a player takes an item by pickpocketing. `victim` is the actor robbed. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerMineDisarm(player: Player)
Dispatched when a player disarms a mine. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerSpeechChallenge(player: Player)
Dispatched when a player passes a speech challenge in a dialogue. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerSteal(player: Player, count: number)
Dispatched when a player's game counts a theft: items taken that belong to someone else. `count` is how many. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerAddicted(player: Player, item: number | null)
Dispatched when a player becomes addicted. `item` is the chem or drink that did it. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerTrespass(player: Player)
Dispatched when a player is caught trespassing by the game's own crime system. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerAssault(player: Player)
Dispatched when the game's crime system records an assault by a player on one of its NPCs. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerMurder(player: Player)
Dispatched when the game's crime system records a murder by a player. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerLocationCleared(player: Player)
Dispatched when the game marks the location a player is in as cleared; `Player.getLocation` names it. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerCriticalHit(player: Player, weapon: number | null, critical: boolean)
Dispatched when a player lands a sneak attack (`critical` false) or a critical hit (true) on an actor, as their HUD says it. `weapon` is the weapon's form ID, null for bare hands. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerLocationDiscover(player: Player, marker: number | null)
Dispatched when a player discovers a location by coming up to it. `marker` is the map marker reference, the one `Player.discoverLocations` takes; what a script reveals that way is not reported. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerFusionCoreConsume(player: Player)
Dispatched when a fusion core runs out in a player's game: their power armor's, or the last shot of one they fired. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerFusionCoreEject(player: Player)
Dispatched when a fusion core is ejected from power armor in a player's game. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerJunkFound(player: Player, count: number)
Dispatched when junk enters a player's inventory, picked up or given, with the count their game adds to its junk collected stat. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerHolotape(player: Player, holotape: number | null, playing: boolean)
Dispatched when a player's holotape starts, pauses, resumes or stops: `holotape` is the tape's form ID and `playing` whether it runs now. A tape that plays a recording; one that opens a terminal or a game is not reported. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerSandmanKill(player: Player)
Dispatched when a player kills a sleeping actor with the Mister Sandman kill. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerCorpseEat(player: Player)
Dispatched when a player feeds on a corpse, as the Cannibal perk lets them. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerInvest(player: Player)
Dispatched when a player invests caps in one of the game's vendors. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerRicochet(player: Player)
Dispatched when a shot at a player bounces back and kills the shooter, the Ricochet perk's doing. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerMysteriousStranger(player: Player)
Dispatched when the Mysterious Stranger turns up for a player in VATS. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerDisarm(player: Player, target: number | null)
Dispatched when a player knocks the weapon out of an actor's hands. `target` is the actor disarmed. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
playerBobblehead(player: Player)
Dispatched when a player collects a bobblehead. Reported by the player's game after the fact: it cannot be refused, and the form IDs are the client's word.
mineLaid(mine: Mine)
Dispatched once a player's mine settles and is armed. Return `false` to refuse: it leaves the world unexploded.
mineTrigger(mine: Mine, player: Player)
Dispatched when a player walks onto another player's mine, before it goes off. Return `false` to keep it armed; the player's game asks again every half second while they stand on it.
mineRemove(mine: Mine)
Dispatched when a mine goes, whatever took it: its blast, a disarm, its owner leaving or a script. The handle still reads.
npcHit(attacker: Player, npc: Npc, damage: number, kind: "direct" | "blast" | "vats", vatsChance: number, limb: string | null, weapon: number | null)
Dispatched when a player's game lands a hit on an NPC, before the NPC takes it. Return `false` to drop the hit, except on an NPC the attacker's own game runs (`getSimulator`), which took it already: that one is told so scripts learn who hit it, and the attacker is still the killer `npcDeath` names. `damage` is the attacker's game's own; `kind` is a shot or a blow, an explosion's blast, or a shot of a VATS attack, whose hit the attacker's game rolled against the chance it showed: refusing one decides VATS hits on the server. `vatsChance` is the chance the attacker's VATS showed, 0 to 1, and 0 for any other kind, as for `playerHit`. `limb` is the body part struck, as the game names its types ("Head1", "LeftArm1", "Torso"...), null for a blast or none; `weapon` is the weapon form the hit came from, null for none.
npcAttack(npc: Npc, victim: Player, damage: number, kind: "direct" | "blast", limb: string | null, weapon: number | null)
Dispatched when an NPC lands a hit on a player, before the victim takes it. Return `false` to drop the hit, except on a player whose own game runs the NPC (`getSimulator`), who took it already: that one is told so scripts learn of it. `damage` is the game's own, from the client that runs the NPC. `limb` is the body part struck, as the game names its types ("Head1", "LeftArm1", "Torso"...), null for a blast or none; `weapon` is the weapon form the hit came from, null for none.
npcDeath(npc: Npc, killer: Player | null)
Dispatched once when an NPC dies. `killer` is the last player who hit it, or null. It comes back on its own a while later; `npcRespawn` follows.
npcActivate(player: Player, npc: Npc)
Dispatched when a player activates an NPC, the Activate button on its body: what a shopkeeper, a quest giver or any interaction starts from. Raised whether or not `setActivationBlocked` stops the game's own greeting and dialogue.
npcTarget(npc: Npc, target: Player | Npc | null)
Dispatched when the player or NPC an NPC fights changes, as the game that runs it decides: it noticed an enemy, switched to another, or stopped fighting (`target` null, also on its death). Where aggro, bounties and wanted levels start.
npcArrive(npc: Npc)
Dispatched once when an NPC reaches where `goTo` sent it; it then stands there until `stopGoing` or the next `goTo`. Sent after a body, it is raised again each time it catches up after the body walked off.
npcRespawn(npc: Npc)
Dispatched when an NPC is back at its placement, whole: on its own after its death, or from `respawn`.
npcSimulatorChange(npc: Npc, simulator: Player | null)
Dispatched when another player's game takes over running an NPC, or when nobody near does any more (`simulator` null) and the server walks it.
npcLeaderChange(npc: Npc, leader: Player | null)
Dispatched when an NPC becomes a player's companion (`setLeader`), or follows nobody any more (`leader` null): let go, or its leader left.
workshopBuild(player: Player, form: number, workbench: number, position: Vector3, angle: Vector3)
Dispatched when a player builds an object in a settlement, before anyone else sees it. Return `false` to refuse: their game takes it back out. The recipe's components are theirs to have spent; the server cannot refund them.
workshopMove(player: Player, item: WorkshopItem, position: Vector3, angle: Vector3)
Dispatched when a player moves a built object, before anyone else sees it. Return `false` to refuse: the object is put back where it was for everyone, as a new `WorkshopItem`, and the old handle reads nothing.
workshopEnter(player: Player, workbench: number)
Dispatched when a player enters workshop mode at a workbench, the workbench reference's form ID.
workshopLeave(player: Player, workbench: number)
Dispatched when a player leaves workshop mode, or enters it at another workbench.
workshopScrap(player: Player, item: WorkshopItem)
Dispatched when a player scraps or stores a built object, before it goes for everyone. Return `false` to refuse: the object is put back for everyone, as a new `WorkshopItem`, and the old handle reads nothing. The player keeps what their game gave them for it.
resourceStart(resourceName: string)
Dispatched after a resource entry point has run and immediately before the resource becomes running.
resourceStop(resourceName: string)
Dispatched while a resource is stopping, before its stop callback, timers, exports and event handlers are cleaned up.
entityStateChange(entity: Entity, key: string, value: any, previous: any)
Dispatched when one key of an entity's state changes: on the server when a script writes it, on a client when the write arrives. `value` is undefined when the key was removed and `previous` is undefined when it held nothing before, so a stored null stays distinguishable from an absent key. The entity is whatever the game's WrapScriptEntity answers, and the base Entity handle by default.
consoleCommand(command: string, args: string[])
Dispatched for a line typed into the server console that no built-in command (help, ensure, refresh, ...) claimed. `args` is the rest of the line, split on whitespace. The console is the operator's, so this is the place for commands no player may run.
playerVoiceStart(player: Player)
Dispatched when a player starts speaking, as isPlayerTalking turns true.
playerVoiceStop(player: Player)
Dispatched shortly after a player's last voice frame, as isPlayerTalking turns false. A player who disconnects while talking gets no stop, so clear them on disconnect too.
playerVoiceTierChange(player: Player, tier: number)
Dispatched when a player switches voice tier themselves: 0 whisper, 1 normal, 2 shout. setPlayerTier does not raise it.
playerConnecting(connection: PendingConnection)
Dispatched when a player asks to join, before the connection exists: they hold no player slot, are not counted as online, and are sent nothing -- no resource list, no download, no body. The request waits until every handler has returned and every Promise a handler returned has settled, then it is let in if a player slot is free (otherwise it is refused as full). `connection.reject()` turns it away instead, and so does a handler that throws or rejects, or handlers that have not settled within the server's admission timeout (30 seconds by default, restarted by every `connection.update()`). With no handler at all, every request is let in at once.

Globals

Always in scope, in every resource. No imports.

Events

global

Asynchronous resource event bus.

Methods
on(eventName: string, handler: EventHandler): Unsubscribe

Registers a persistent handler in the shared event namespace.

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the emitted arguments.

Returns Function that removes this exact subscription.

once(eventName: string, handler: EventHandler)

Registers a handler that is removed before its first invocation.

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the emitted arguments.
off(eventName: string, handler: EventHandler)

Removes a matching handler owned by the calling resource.

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the emitted arguments.
emit(eventName: string, ...args: unknown[]): Promise<void>

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

eventName
Shared event name.
args
Arguments delivered to every matching handler.

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

emitTo(resourceName: string, eventName: string, ...args: unknown[]): Promise<void>

Invokes matching handlers belonging only to one resource.

resourceName
Destination running resource.
eventName
Shared event name.
args
Arguments delivered to matching handlers owned by the destination.

Returns Promise rejected when one or more destination handlers fail.

onLocal(eventName: string, handler: EventHandler)

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

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the emitted arguments.
emitLocal(eventName: string, ...args: unknown[]): Promise<void>

Emits an event only within the calling resource.

eventName
Private local event name.
args
Arguments delivered only to handlers owned by the calling resource.

Returns Promise rejected when one or more local handlers fail.

listenerCount(eventName: string): number

Counts persistent and one-shot shared handlers across resources.

eventName
Shared event name to inspect.

Returns Number of matching handlers.

emitAllClients(eventName: string, payload?: unknown)

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

eventName
Client shared-event name.
payload
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.
onClient(eventName: string, handler: (player: Player, payload?: unknown) => unknown | Promise<unknown>): Unsubscribe

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

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the sending player and the parsed payload, which is absent when the client sent none. The payload is untrusted.

Returns Function that removes this exact subscription.

onceClient(eventName: string, handler: (player: Player, payload?: unknown) => unknown | Promise<unknown>)

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

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the sending player and the parsed payload, which is absent when the client sent none. The payload is untrusted.
offClient(eventName: string, handler: (player: Player, payload?: unknown) => unknown | Promise<unknown>)

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

eventName
Case-sensitive event name.
handler
Resource-owned callback invoked with the sending player and the parsed payload, which is absent when the client sent none. The payload is untrusted.

Chat

global

Server-side delivery of structured chat messages to connected clients.

Methods
sendToAll(text: string, options?: { author?: string; color?: number | Color })

Broadcasts a structured chat message to all clients.

text
Message body broadcast to every connected client.
options
Optional author label and color: a Color or a packed 0xRRGGBBAA integer.
sendToPlayer(player: Entity, text: string, options?: { author?: string; color?: number | Color })

Sends a structured chat message to one player's owning connection.

player
Player-owned entity identifying the destination connection.
text
Message body sent to the player.
options
Optional author label and color: a Color or a packed 0xRRGGBBAA integer.

World

global

The server's clock, calendar and weather, which every client follows, and what the game's data files say of weathers and climates.

Properties
hour: numberread-only

The hour of the day, from 0 up to but not including 24, with the minutes as the fraction: 13.5 is half past one.

timeScale: numberread-only

Game minutes per real minute. 20 is the game's own pace; 0 holds the clock.

date: WorldDateread-only

The calendar date every client's game shows. It turns over at midnight as the clock runs.

daysPassed: numberread-only

Whole days the clock has run, the game's GameDaysPassed: what its timers, vendors' restocks and crops count in.

weather: numberread-only

The TESWeather form ID every client shows.

weatherForced: booleanread-only

Whether the weather was swapped in at once rather than transitioned to.

previousWeather: numberread-only

The weather the sky is still moving away from, 0 once the move is over: up to two game hours after `setWeather`, past the game's longest transition.

lightningEnabled: booleanread-only

Whether the server strikes lightning on its own while `weather` thunders, at the pace the game would. In a session the game strikes only on the server's word, so every player sees the same strikes.

Methods
setHour(hour: number)

Sets the clock. Every client jumps to it. The date stays as it is.

hour
The hour, wrapped into 0-24; 13.5 is half past one.
resetLocation(location: number | string): number

Resets an area as the game's own respawn does after its days have passed, as Papyrus `Location.Reset` and FiveM scripts that repopulate a zone do: every dead NPC the data files place there is back, whole, at its placement (`npcRespawn` for each), and every player's game marks the location not cleared and refills its containers, loot and encounters when it next loads them. A raider camp, a dungeon, a town: cleared places fill up again.

location
A location (LCTN) form ID, as a number or hex string: "0x1D5F3". Its child locations are reset with it.

Returns How many of the server's NPCs came back. Throws for a form that is not a location.

setTimeScale(scale: number)

Sets how fast the clock runs.

scale
Game minutes per real minute, 0 or more; 0 holds the clock.
setDate(year: number, month: number, day: number)

Sets the calendar date every client's Pip-Boy shows. The hour and the day count stay as they are.

year
The full year, 2000 to 2999.
month
1 to 12.
day
1 to the month's last; the calendar has no leap years.
setDaysPassed(days: number)

Sets how many days the clock has run, which the game's timers count in. The date stays as it is.

days
Whole days, 0 or more.
setWeather(weather: number | string | null, force?: boolean)

Sets the weather every client shows. A transition runs on the game clock, so every client fades at the same point, one that joins during it included. Only a client's data files can tell whether the form is a weather, so a wrong one leaves the sky as it is.

weather
A TESWeather form ID, as a number or hex string; null for the server's default, CommonwealthClear.
force
Swap it in at once rather than transition to it.
getWeathers(): WeatherRecord[]

Every weather the game's official masters define, by form ID.

Returns Empty when the server could not read the game's data files.

setLightningEnabled(enabled: boolean)

Starts or stops the server's own lightning.

enabled
On, or off: no lightning but what scripts strike.
strikeLightning(weather?: number | string)

Strikes lightning in every player's sky that thunders: a flash and a thunderclap, at the same moment for all.

weather
Only for skies in this weather; any weather that thunders when left out.
getRegionWeathers(region: number | string): Climate | null

The weathers a region rolls, as the data files give it: the game takes them over the worldspace's climate while the player stands in the region.

region
A TESRegion form ID, as `Player.getWeatherRegion` gives it.

Returns Null when the region has no weathers, or the form is not one.

getClimate(worldSpace: number | string): Climate | null

The climate a worldspace's sky rolls its weathers from, as the data files give it: the base a script rolls its own weather cycle on.

worldSpace
A TESWorldSpace form ID.

Returns Null when the worldspace has none, or the form is not one.

Objects

global

Doors, locks and containers, by the form ID of their placed reference. The server knows only what changed this session; the rest is as the data files place it, which only a client loads.

Methods
isDoorOpen(ref: number | string): boolean | null

Whether a door stands open.

ref
The placed reference's form ID.

Returns Null when nobody moved it this session.

isLocked(ref: number | string): boolean | null

Whether a door or container is locked.

ref
The placed reference's form ID.

Returns Null when nobody changed its lock this session.

isActivationBlocked(ref: number | string): boolean | null

Whether a script blocked activating a reference.

ref
The placed reference's form ID.

Returns Null when no script decided this session: the game's own state stands, which blocks a settlement's workbench until its quest gives it to the player.

setActivationBlocked(ref: number | string, blocked: boolean)

Blocks or allows activating a reference for everyone, players who join later included. Allowing a settlement's workbench lets players enter its build mode.

ref
The placed reference's form ID.
blocked
Blocked or allowed.
isEnabled(ref: number | string): boolean | null

Whether a script left a reference in the world or took it out.

ref
The placed reference's form ID.

Returns Null when no script decided this session: the game's own state stands.

setEnabled(ref: number | string, enabled: boolean)

Takes a reference the data files place out of every player's world, as ObjectReference.Disable does, or puts it back, players who join later included: a barricade torn down, a door bricked up, a prop shown for an event. Held against the game's own scripts and cell loads, which put references back as they please.

ref
The placed reference's form ID.
enabled
In the world, or out of it.
move(ref: number | string, position: Vector3, angle?: Vector3): boolean

Moves a placed reference for everyone, players who join later included, as a player moving it in a settlement's build mode does: the power it receives through the air and its wires follow it.

ref
The placed reference's form ID.
position
Where it stands now.
angle
Its rotation, radians.

Returns False for a reference the session scrapped or a pose that is not finite.

getMovedPosition(ref: number | string): Vector3 | null

Where a player's build mode or a script last put a placed reference.

ref
The placed reference's form ID.

Returns Null while it stands where the data files place it.

setDoorOpen(ref: number | string, open: boolean)

Opens or closes a door for everyone, players who join later included.

ref
The placed reference's form ID.
open
Open or closed.
setLocked(ref: number | string, locked: boolean)

Locks or unlocks a door or container for everyone.

ref
The placed reference's form ID.
locked
Locked or not.
getContainer(ref: number | string): InventoryItem[] | null

What a container holds.

ref
The placed reference's form ID.

Returns Null until a player or a script set its contents this session; before that, each client rolls its own.

setContainer(ref: number | string, items: { form: number | string; count: number }[]): boolean

Fills a container for everyone.

ref
The placed reference's form ID.
items
Exactly what it should hold.

Returns False past 1024 kinds of item.

getContainerHolder(ref: number | string): Player | null

The player whose menu has a container open; nobody else can take from it meanwhile.

ref
The placed reference's form ID.

Returns Null when nobody holds it.

Voice

global

Server-side proximity voice rules: how far voice carries, and who may talk to or hear whom.

Methods
setRange(range: number)

Sets how far voice carries for talkers with no override of their own. Connected clients are told, so their playback fades out at the same distance.

range
Audibility radius in world units; values <= 0 restore the default of 25.
getRange(): number

Reads the server-wide proximity range.

Returns Radius in world units.

setPlayerRange(player: Entity, range: number)

Overrides how far one player's voice carries, whichever voice tier they chose.

player
Player whose voice carries the given distance.
range
Audibility radius in world units; values <= 0 return them to the radius of their voice tier.
getPlayerRange(player: Entity): number

Reads how far a player's voice carries, with the server-wide default already resolved.

player
Player to query.

Returns Radius in world units.

setTierRange(tier: number, range: number)

Sets how far a voice tier carries. Players switch tier themselves; whisper starts at 3, shout at 25, and normal carries the server-wide range. Set a tier to 0 to make it carry the server-wide range, which takes it away. Connected clients are told.

tier
Voice tier: 0 whisper, 1 normal, 2 shout.
range
Audibility radius in world units; values <= 0 make the tier carry the server-wide range.
getTierRange(tier: number): number

Reads how far a voice tier carries, with the server-wide range already resolved.

tier
Voice tier: 0 whisper, 1 normal, 2 shout.

Returns Radius in world units.

setPlayerTier(player: Entity, tier: number)

Puts a player on a voice tier, as if they had switched to it. Their own indicator follows, and the playerVoiceTierChange event is not raised.

player
Player to move.
tier
Voice tier: 0 whisper, 1 normal, 2 shout.
getPlayerTier(player: Entity): number

Reads the voice tier a player is on. A player switching tier raises the playerVoiceTierChange event with the player and the new tier.

player
Player to query.

Returns 0 whisper, 1 normal, 2 shout.

setPlayerMuted(player: Entity, muted: boolean)

Server-wide mute: a muted player's voice reaches nobody.

player
Player to mute or unmute.
muted
True to stop their voice reaching anyone.
isPlayerMuted(player: Entity): boolean

Checks the server-wide mute flag.

player
Player to query.

Returns True when the player's voice reaches nobody.

setPlayerDeaf(player: Entity, deaf: boolean)

Server-wide deafen: a deaf player receives nobody.

player
Player to deafen or undeafen.
deaf
True to stop them receiving anyone's voice.
isPlayerDeaf(player: Entity): boolean

Checks the server-wide deafen flag.

player
Player to query.

Returns True when the player receives nobody's voice.

setLocalMute(listener: Entity, target: Entity, muted: boolean)

One-way mute between two players, enforced by the server rather than the client.

listener
Player who stops hearing the target.
target
Player the listener stops hearing.
muted
True to mute, false to restore.
isLocallyMuted(listener: Entity, target: Entity): boolean

Checks a one-way mute.

listener
Player doing the muting.
target
Player being muted.

Returns True when the listener does not receive the target.

isPlayerVoiceEnabled(player: Entity): boolean

Checks whether a player left voice chat enabled in their own client settings. A preference, not a permission: use setPlayerMuted or setPlayerDeaf to enforce anything.

player
Player to query.

Returns True unless the player turned voice chat off.

isPlayerTalking(player: Entity): boolean

Checks whether a player is speaking right now. Tracks speech rather than the push-to-talk key: silence is dropped before it reaches the server, and the state clears shortly after the last frame. The same signal raises the playerVoiceStart and playerVoiceStop events.

player
Player to query.

Returns True while the player's voice is reaching the server.

Messages

global

Typed request and notification channel between local resources through the global Messages object.

Methods
handle(messageType: string, handler: MessageHandler)

Registers or replaces a message handler owned by the calling resource.

messageType
Message type unique within the receiving resource.
handler
Handler invoked with the payload and a reply callback; the reply is ignored for notifications.
request(resourceName: string, messageType: string, payload?: unknown): Promise<unknown>

Sends a request to another local resource and waits for its handler to call reply.

resourceName
Destination running resource.
messageType
Handler type registered by the destination.
payload
Optional payload delivered to the handler.

Returns Promise resolved with the reply value or rejected when delivery or handling fails.

send(resourceName: string, messageType: string, payload?: unknown)

Sends a fire-and-forget notification to another local resource.

resourceName
Destination running resource.
messageType
Handler type registered by the destination.
payload
Optional payload delivered to the handler.

Imports

global

Bulk access to values exported by another running resource through the global Imports object.

Methods
get(resourceName: string): Record<string, unknown>

Builds an object containing every currently registered export from another resource; undeclared dependencies produce a warning.

resourceName
Name of the running resource whose exports should be read.

Returns Object keyed by export name, or an empty object when the resource has no exports.

Exports

global

Registration and lookup of cross-resource values through the global Exports object.

Methods
register(name: string, value: unknown): boolean

Registers a value from the calling resource for use by dependent resources.

name
Export name, preferably declared in the current resource manifest.
value
JavaScript value or function retained by the current resource.

Returns True when the value was registered.

get(resourceName: string, exportName: string): unknown

Reads one registered export from another running resource; undeclared dependencies produce a warning.

resourceName
Name of the running resource that owns the export.
exportName
Registered export name.

Returns The exported value.

console

global

Resource-aware console that routes output through the Framework logger.

Methods
log(...values: unknown[])

Writes an informational log entry prefixed with the current resource name.

values
Values formatted and joined with spaces.
info(...values: unknown[])

Alias of console.log for informational output.

values
Values formatted and joined with spaces.
warn(...values: unknown[])

Writes a warning log entry prefixed with the current resource name.

values
Values formatted and joined with spaces.
error(...values: unknown[])

Writes an error log entry prefixed with the current resource name.

values
Values formatted and joined with spaces.
debug(...values: unknown[])

Writes a debug log entry prefixed with the current resource name.

values
Values formatted and joined with spaces.

ExecutionEnvironment

global

Runtime-side flags exposed as the global ExecutionEnvironment.

Properties
isClient: booleanread-only

True in the sandboxed client scripting runtime.

isServer: booleanread-only

True in the authoritative server scripting runtime.

frameworkVersion: stringread-only

Local Framework release version.

modVersion: stringread-only

Local mod version from InstanceOptions.modVersion; empty when unset.

Players and entities

What the server hands your event handlers.

Player

classextends BasePlayer

A connected player and the character they control. Their own game decides their body: what a getter reads is their last report, and a setter is a request their game carries out, then reports back.

Constructor
new Player(id: number)

Wraps an already connected player with this ID; it neither connects nor spawns anyone.

id
Network entity identifier.
Properties
nickname: stringread-only

The name the player connected with. Empty once they are gone.

health: number

Current health, as the player's game last reported it. Assigning asks their game to move it there, as `setValue("Health", value)` does; it reads the new value once they report it.

maxHealth: numberread-only

Health at full.

armor: numberread-only

Damage resistance from the armor the player wears.

isInvulnerable: booleanread-only

Whether `setInvulnerable` made the player unhurtable.

isKnockedDown: booleanread-only

Whether the player is knocked down, alive: in their ragdoll or getting up, after a blast or a client script's `LocalPlayer.knockDown`.

isBleedingOut: booleanread-only

Whether the player is in the game's bleedout: down on the ground and alive, where a client script put them with `LocalPlayer.setBleedingOut`.

isDead: booleanread-only

Whether the player is dead. A dead player stays down until `respawn`.

isFemale: booleanread-only

Whether the character is female.

heading: numberread-only

Facing, in radians around Z.

aimPitch: numberread-only

Aim pitch, in radians.

velocity: Vector3read-only

Velocity, in game units per second.

isSneaking: booleanread-only

Whether the player sneaks.

isJumping: booleanread-only

Whether the player is in the air: from a jump, a fall or their power armor jetpack.

isSprinting: booleanread-only

Whether the player sprints.

isRunning: booleanread-only

Whether the player runs rather than walks.

isWeaponDrawn: booleanread-only

Whether the player's weapon is out.

isAiming: booleanread-only

Whether the player aims down the sights of a drawn gun.

isPipBoyOpen: booleanread-only

Whether the player's Pip-Boy is up.

isInPowerArmor: booleanread-only

Whether the player wears a power armor frame.

isSwimming: booleanread-only

Whether the player swims: in water deep enough that their game took them off their feet.

isUnderwater: booleanread-only

Whether the water reaches above the player's neck, as their game's IsUnderWater condition answers. A swimmer's body often keeps it so at the surface too.

isJetpackFiring: booleanread-only

Whether the jetpack of the player's power armor thrusts.

Methods
exitPowerArmor(): boolean

Takes the player out of their power armor; the frame stays where they stand. `playerPowerArmor` follows once their game is done, which it is not while they fly the fly camera (`NoClip`): the game leaves the player's own update alone until the camera comes back.

Returns True when sent; false when the player is gone or not in power armor.

kill(): boolean

Kills the player through their game's own hit path; `playerDeath` follows with a null killer.

Returns True when sent; false when the player is gone or already dead.

openLookEditor(): boolean

Opens the character look editor on the player's screen.

Returns True when sent; false when the player is gone.

stopIdle(): boolean

Stops the idle animation the player plays and returns them to their stance.

Returns True when sent; false when the player is gone.

toString(): string

Formats this handle for logging.

Returns The player's network ID and nickname.

teleport(position: Vector3, heading?: number, space?: { worldSpace?: number | string; interiorCell?: number | string }, options?: { loadScreen?: boolean }): boolean

Moves the player, within their space or into another one. Into an interior they land at a persistent reference inside it, as a quest script moves the player, and `position` is not used: wait for `playerSpaceChange`, then teleport them within it. `playerSpaceChange` follows any change of space.

position
Where to, in the space the player goes to.
heading
Facing in radians; the current one when left out.
space
Another worldspace or an interior cell, exactly one of the two; the one the player is in when left out.
options
loadScreen: whether the player's game may show its loading screen when the destination is not loaded (default true). With false the destination streams in with no loading screen, as the game's own "No Load Screen" doors do: their game stalls for the load instead, so fade the screen first (`Hud.fade`).

Returns True when sent; false when the player is gone, or the interior has no reference to land at. Throws for a position that is not a finite Vector3.

respawn(position?: Vector3, heading?: number): boolean

Brings a dead player back at full health. Nothing respawns a player on its own: call this from `playerDeath`, at once or later.

position
Where to come back; where the player fell when left out.
heading
Facing in radians; the one they died with when left out.

Returns True when sent; false when the player is gone or alive.

fire(shots?: number): boolean

Has the player's game fire its drawn weapon.

shots
How many times, 1 to 255; once when left out.

Returns True when sent; false when the player is gone.

setWeaponDrawn(drawn: boolean | null): boolean

Holds the player's weapon out or away, as FiveM's SetCurrentPedWeapon forces a ped's: their game draws or holsters it at once and keeps it so against their own ready-weapon key and the game's. Away for a safe zone, out for a scripted scene. With no weapon in hand, out raises their fists. To stop attacks too, a client script turns off `Controls` "fighting".

drawn
True to hold their weapon out, false to keep it away, null to hand it back to them.

Returns True when sent; false when the player is gone.

setClipAmmo(rounds: number): boolean

Loads rounds into the player's weapon, as FiveM's SetAmmoInClip does a ped's. The rounds come from those they carry, as a reload takes them: never more than they have, so `giveItem` the ammo first. Their game ignores it without a weapon that loads ammo in hand.

rounds
The rounds to load, 0 to 100000; more than the weapon's clip loads a full clip.

Returns True when sent; false when the player is gone.

setCollision(enabled: boolean): boolean

Takes the player's collision away or gives it back, as FiveM's SetEntityCollision does a ped and the console's tcl the player: without it they move along where they look, through walls and floors, without gravity. An admin's noclip on foot; everyone else sees their body pass through. It ends with their session.

enabled
False to take their collision away, true to give it back.

Returns True when sent; false when the player is gone.

setRace(race: number | string | null): boolean

Rebuilds the player on another race, as the console's setrace and Actor.SetRace do: a ghoul. Their skin and body become the race's, their head parts stay their own, and every other player sees their puppet rebuilt the same way. Only human and ghoul are supported; any other race is refused. The race they had comes back with null, and when their session ends.

race
0x13746 (HumanRace) or 0xEAFB6 (GhoulRace); null for the race they had.

Returns True when sent; false when the player is gone.

enterPowerArmor(frame?: number | string): boolean

Places a power armor frame where the player stands and puts them into it at once, as `Actor.SwitchToPowerArmor` does. `playerPowerArmor` follows. The suit's pieces are the frame's; dress them with `setOutfit`.

frame
The TESFurniture of the frame to place; the game's empty frame when left out.

Returns True when sent; false when the player is gone or already in power armor.

setPowerArmorBattery(charge: number): boolean

Sets the charge of the fusion core in the player's power armor, through the value their game drains. At 0 their game does what it does with an empty core: it loads the next fusion core they carry, or leaves the suit unpowered. Above the core's capacity the capacity follows. It also lifts the hold a refused core left the suit in. `playerPowerArmorBattery` follows.

charge
The charge to leave in the core, 0 to 1000; a full fusion core holds 100.

Returns True when sent; false when the player is gone or not in power armor.

getPowerArmor(): PlayerPowerArmor | null

The power armor frame the player wears.

Returns The frame, or null when they wear none or are gone.

getSpace(): PlayerSpace | null

Where the player is.

Returns The worldspace or interior cell, or null when the player is gone.

getWeapon(): PlayerWeapon | null

The weapon in the player's hands.

Returns The weapon, or null when they have none or are gone.

getOutfit(): OutfitPiece[]

What the player wears.

Returns One entry per armor piece; empty when the player is gone.

setOutfit(pieces: (number | string | { form: number | string; mods?: (number | string)[] })[], mode?: "replace" | "add" | "remove"): boolean

Dresses the player. Pieces the player's game cannot wear are skipped there.

pieces
Armor form IDs, or objects naming the mods to attach. Up to 32 pieces of 8 mods.
mode
`replace`, the default, wears exactly these and takes every other piece off; `add` puts them on over what is worn; `remove` takes them off.

Returns True when sent; false when the player is gone.

randomizeOutfit(seed?: number): boolean

Dresses the player in a random playable outfit, mods included.

seed
Rolls the same outfit for the same seed; a fresh one when left out.

Returns True when sent; false when the player is gone.

setLook(look: { female?: boolean; skinTone?: { r: number; g: number; b: number }; hair?: number | string }): boolean

Changes the character's look; the player's game rebuilds them and everyone sees it.

look
What to change: the sex, the skin tone in 0-255 channels, a hair BGSHeadPart. What is left out stays.

Returns True when sent; false when the player is gone.

randomizeLook(seed?: number, morphsOnly?: boolean): boolean

Rolls the character a new look from their race's character generation data.

seed
Rolls the same look for the same seed; a fresh one when left out.
morphsOnly
Only the face sliders and regions, keeping sex, hair and colours.

Returns True when sent; false when the player is gone.

getAppearance(): string | null

The player's whole look as their game last reported it, as an opaque string to keep (a database column) and hand back to `setAppearance`.

Returns Null before their first report or once they are gone.

setAppearance(look: string): boolean

Puts a whole look back on the player: their game rebuilds them and everyone sees it. Throws for a look from another server version.

look
As `getAppearance` returned it on this server version.

Returns True when sent; false when the player is gone.

setGameName(name: string): boolean

Names the player's character in their own game, as the Vault 111 registration form does: what the game's menus show, and what the SPECIAL menu requires before it closes. Others see the nametag, not this.

name
1 to 64 characters.

Returns True when sent; false when the player is gone.

getInventory(): InventoryItem[]

What the player carries, from the server's record.

Returns One entry per base object and condition; empty before the player's first report, shortly after they join, and once they are gone.

getItemCount(form: number | string): number

How many of an item the player carries.

form
The base object.

Returns The count; 0 when they carry none or are gone.

giveItem(form: number | string, count?: number, condition?: number): boolean

Puts items in the player's inventory. It does not equip them: see `equipItem`.

form
The base object.
count
How many, 1 to 1000000; one when left out.
condition
Their condition in percent of full, 0 to 100, as one stack: a fusion core's charge. Full when left out.

Returns True when the record changed; false before the player's first report or once they are gone.

removeItem(form: number | string, count?: number, condition?: number): boolean

Takes items out of the player's inventory.

form
The base object.
count
How many, 1 to 1000000; one when left out. More than they carry takes them all.
condition
The condition to take first, 0 to 100; the rest come from the fullest stacks. Full when left out.

Returns True when the record changed; false before the player's first report or once they are gone.

setItemCount(form: number | string, count: number): boolean

Sets how many of an item the player carries, over every condition: more are added at full condition, fewer are taken from full stacks first.

form
The base object.
count
How many the player should carry, 0 to 1000000.

Returns True when the record changed; false before the player's first report or once they are gone.

equipItem(form: number | string): boolean

Has the player draw a weapon or wear an armor piece they carry. Right after `giveItem` it lands too: the inventory reaches their game first.

form
A weapon or armor piece the player carries.

Returns True when sent; false when the server's record has none of it or the player is gone.

getIdleTime(): number

How long the player has neither moved nor turned their view, in seconds, as the server measures it from what their game reports: what an AFK check reads.

Returns 0 for one who is moving or looking around, or who is gone.

setItemMods(form: number | string, mods: number[], current?: number[]): boolean

Changes the mods on one item the player carries, as FiveM's GiveWeaponComponentToPed and RemoveWeaponComponentFromPed do, or a workbench would: its condition stays, and the weapon in hand is taken up again with them. Mods that do not fit the item are left out by their game. The change reaches `getInventory` and `getWeapon` once their game reports it.

form
A weapon or armor piece the player carries.
mods
The OMOD form IDs it should carry, all of them: a scope, a barrel, a paint. Empty gives it the mods its record gives a new one, as a weapon is never without a receiver.
current
The mods of the one to change, among several; the weapon in hand when left out and it is of this form, else the first one found.

Returns True when changed, or already so; false when the player carries none that matches.

unequipItem(form: number | string): boolean

Has the player put a weapon away for good or take an armor piece off: they keep carrying it.

form
A weapon or armor piece the player carries.

Returns True when sent; false when the server's record has none of it or the player is gone.

setInvulnerable(invulnerable: boolean): boolean

Makes the player unhurtable, as FiveM's SetPlayerInvincible does: their game makes them a ghost, which shots, blows and explosions pass over, and turns on the game's immortal mode, so a fall or radiation never takes their last point of health; the server drops every hit still reported on them, from players and NPCs, before `playerHit` or `npcAttack`. It lasts until undone or they leave.

invulnerable
True to make them unhurtable, false to make them hurtable again.

Returns True when sent; false when the player is gone.

setDamageModifier(modifier: number): boolean

Scales the damage the player's hits deal, on players and NPCs alike, as FiveM's SetPlayerWeaponDamageModifier does. Every hit is scaled by the attacker's modifier, the weapon's (`setWeaponDamageModifier`) and the victim's defense (`setDefenseModifier`) before `playerHit` or `npcHit` hears of it: their `damage` is what is dealt. A hit on an NPC the attacker's own game runs is taken there at once, unscaled, and the difference is dealt or given back right after. It lasts until set again or they leave.

modifier
From 0 to 100: 1 for none, 0.5 for half, 2 for double, 0 for no damage at all.

Returns True when set; false when the player is gone.

getDamageModifier(): number

What `setDamageModifier` scales the player's hits by.

Returns The modifier; 1 when none was set.

setDefenseModifier(modifier: number): boolean

Scales the damage hits deal the player, from players and NPCs alike, as FiveM's SetPlayerWeaponDefenseModifier does: 0.5 halves what they take. A hit by an NPC their own game runs is taken there at once, unscaled, and the difference is dealt or given back right after. Falls, radiation and hazards are their game's and are not scaled. It lasts until set again or they leave.

modifier
From 0 to 100: 1 for none, 0.5 for half, 2 for double, 0 for no damage at all.

Returns True when set; false when the player is gone.

getDefenseModifier(): number

What `setDefenseModifier` scales the hits on the player by.

Returns The modifier; 1 when none was set.

say(line: number | string): boolean

Has the player's character speak, voice and subtitle, as FiveM's PlayAmbientSpeechNative does a player's ped: their own game says it, picking a topic's line among those whose conditions pass, and every other player's game hears their puppet say the same line in the player voice of their sex. Lines the character says on its own, in dialogue or in a fight, are heard the same way.

line
A dialogue topic (DIAL) by form ID or editor ID, such as `0x1B40FA`, the player's combat lines, or one of its lines (INFO) by form ID.

Returns True when sent; false when the player is gone. Throws for a form no DIAL or INFO record has.

knockDown(force?: number, from?: Vector3): boolean

Knocks the player off their feet into their ragdoll from the server, as FiveM's SetPedToRagdoll does a player's ped: their game pushes them, as `LocalPlayer.knockDown` does, they lie a moment and get up by themselves, and every other player sees them fall. A player who is down, dead, held in place or in furniture is left as they are.

force
How hard they are thrown, as ObjectReference.PushActorAway takes it: small numbers, 1 to 50 (600 threw an NPC 8,700 units); 0, the default, drops them where they stand.
from
The point they are thrown away from; where they stand by default.

Returns True when sent; false when the player is gone.

setScale(scale: number): boolean

Scales the player in every game, as ObjectReference.SetScale does: their own game scales their character, and every other game their body. It lasts until set again or they leave.

scale
1 for their normal size, from 0.01 to 10.

Returns True when sent; false when the player is gone.

setAlpha(alpha: number, fade?: boolean): boolean

Draws the player more or less see-through for everyone, as FiveM's SetEntityAlpha and SetEntityVisible do a player's ped: their own game sets it, as `LocalPlayer.setAlpha` does, and every other game draws their body the same. At 0 no game shows their nametag either. An admin's invisibility, a spectator, a spawn's protection.

alpha
0, invisible, to 1, solid.
fade
Fade there rather than cut (default false).

Returns True when sent; false when the player is gone.

setRestrained(restrained: boolean): boolean

Holds the player in place from the server, as FiveM's FreezeEntityPosition does a player's ped and Actor.SetRestrained an actor: their game keeps them standing where they are, neither moving nor acting, until let go. Cuffs, an arrest, an admin freeze, a cutscene. A player who is down or dead is left as they are.

restrained
True to hold them where they stand, false to let them go.

Returns True when sent; false when the player is gone.

playIdle(idle: string | number): boolean

Plays an idle animation on the player, as `Actor.PlayIdle` does; everyone around them sees it. The idle's own conditions apply, so one meant for another skeleton, a piece of furniture or a state the player is not in does nothing. Moving ends most idles; `stopIdle` ends any.

idle
An idle animation from the game's data (an IDLE record): its editor ID, such as `"Salute"`, or its form ID.

Returns True when sent; false when the player is gone. Throws for a name or form ID no IDLE record has.

getValue(value: string | number): number | null

An actor value as it stands: Health, ActionPoints and Rads as the player's game last reported them, any other the base the record holds.

value
An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.

Returns The value; null before the character is established or for a value the record does not hold.

getBaseValue(value: string | number): number | null

The base the character's record holds for an actor value: SPECIAL, Experience, and any base a script set.

value
An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.

Returns The base; null for one the record does not hold.

setBaseValue(value: string | number, base: number): boolean

Sets an actor value's base on the record and in the player's game, as `ObjectReference.SetValue` does: for Health or CarryWeight that is the maximum. It is saved with the character and set again whenever they join.

value
An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
base
The new base. SPECIAL is rounded and kept within 1 to 11.

Returns True when the record changed; false before the character is established.

damageValue(value: string | number, amount: number): boolean

Lowers an actor value's current value in the player's game, as `ObjectReference.DamageValue` does. Health damaged to 0 kills.

value
An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
amount
How much, at least 0. Rads rise by it.

Returns True when sent; false when the player is gone.

restoreValue(value: string | number, amount: number): boolean

Raises an actor value's current value in the player's game up to its maximum, as `ObjectReference.RestoreValue` does.

value
An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
amount
How much, at least 0. Rads fall by it.

Returns True when sent; false when the player is gone.

setValue(value: string | number, current: number): boolean

Moves an actor value's current value in the player's game, keeping its base.

value
An actor value: its editor ID, such as `"Strength"` or `"Health"`, or its form ID.
current
The current value to reach; no higher than the maximum.

Returns True when sent; false when the player is gone.

getLevel(): number

The character's level.

Returns The level; 0 when the player is gone.

setLevel(level: number): boolean

Sets the character's level and their XP to the start of it. No perk points come with it: see `setPerkPoints`.

level
1 to 65535.

Returns True when the record changed; false before the character is established.

getXp(): number

The character's total experience.

Returns The XP; 0 when the player is gone.

setXp(xp: number): boolean

Sets the character's total experience, and their level to match. No perk points come with it.

xp
The total, at least 0.

Returns True when the record changed; false before the character is established.

addXp(amount: number): boolean

Awards experience as the game does: each level it reaches brings a perk point and the game's level-up.

amount
More than 0. Not scaled by Intelligence.

Returns True when the record changed; false before the character is established.

getPerkPoints(): number

The character's unspent perk points.

Returns The points; 0 when the player is gone.

setPerkPoints(points: number): boolean

Sets the character's unspent perk points.

points
0 to 255.

Returns True when the record changed; false before the character is established.

getPerks(): number[]

The perk ranks the character holds. Each rank of a perk is a BGSPerk of its own.

Returns Their form IDs; empty when the player is gone.

hasPerk(perk: number | string): boolean

Whether the character holds a perk rank.

perk
A BGSPerk rank.

Returns True when they hold it. Throws for a form ID that is no perk.

addPerk(perk: number | string, withLowerRanks?: boolean): boolean

Gives the character a perk rank without spending a point.

perk
A BGSPerk rank.
withLowerRanks
Also give the ranks below it; true when left out.

Returns True when the record changed; false before the character is established. Throws for a form ID that is no perk.

removePerk(perk: number | string): boolean

Takes a perk rank from the character, and every rank above it. No point is refunded.

perk
A BGSPerk rank.

Returns True when the record changed; false when they do not hold it.

getCaps(): number

The bottle caps the player carries: the Caps001 item in the inventory record.

Returns The count; 0 before the first inventory report or once they are gone.

setCaps(caps: number): boolean

Sets the bottle caps the player carries.

caps
0 to 1000000.

Returns True when the record changed; false before the first inventory report.

openSpecialMenu(): boolean

Opens the game's SPECIAL allocation menu on the player's screen, as the Vault 111 exit does. Each point they move comes back as `playerValueRequest`.

Returns True when sent; false when the player is gone.

openPerkChart(): boolean

Opens the game's perk chart on the player's screen. Each rank bought comes back as `playerPerkRequest`.

Returns True when sent; false when the player is gone.

getCharacter(): CharacterDocument | null

The whole character: experience, level, perk points, bases, perks, current values and inventory. Keep it wherever the gamemode likes; `setCharacter` takes it back.

Returns The document; null before the character is established.

setCharacter(character: Partial<CharacterDocument>): boolean

Replaces the character with a document, and brings the player's game to it.

character
As `getCharacter` returns it. What it leaves out stays as it is.

Returns True when applied; false before the character is established. Throws for a malformed document.

static xpForLevel(level: number): number

The total experience a level starts at, by the game's formula.

level
1 to 65535.

Returns The XP.

getFactions(): { faction: number; rank: number }[]

The factions the server put the player in, each with its rank. The factions their character holds from the game's own data, such as PlayerFaction, are not listed.

Returns One entry per faction, in the order they were joined; empty when the player is gone.

getFactionRank(faction: number | string): number | null

The player's rank in a faction the server put them in.

faction
A TESFaction form ID, as a number or hex string.

Returns The rank; null when the server did not put them in it.

setFactionRank(faction: number | string, rank?: number): boolean

Puts the player in a faction at a rank, or re-ranks them, as `Actor.SetFactionRank` does: their own game and every other player's give their character the membership, so the game's hostility follows it. NPCs of the faction and its allies treat them as one of their own; its enemies attack them. Up to 16 factions per player; whether a player's hits on another land stays `playerHit`'s say.

faction
A TESFaction form ID, as a number or hex string.
rank
0 to 127; 0 when left out.

Returns True when set; false when the player is gone or already in 16 factions.

removeFromFaction(faction: number | string): boolean

Takes the player out of a faction the server put them in, as `Actor.RemoveFromFaction` does.

faction
A TESFaction form ID, as a number or hex string.

Returns True when they were in it; false otherwise or when the player is gone.

getBounty(faction: number | string): number

The bounty the player owes a crime faction, as FiveM's wanted level reads: the crime gold their game says they owe it, violent and not together. Their own crimes raise it as the game's do, theft and assault the faction's members witness; `setBounty` and `addBounty` change it. `playerBountyChange` follows every change.

faction
A TESFaction form ID, as a number or hex string.

Returns The crime gold; 0 when they owe none or are gone.

setBounty(faction: number | string, amount: number, violent?: boolean): boolean

Sets the bounty a player owes a crime faction, as Papyrus `Faction.SetCrimeGold` / `SetCrimeGoldViolent` and FiveM's SetPlayerWantedLevel do: their own game records it, so the faction's guards answer it as the game does a crime of theirs. `getBounty` reads the result once their game reports it.

faction
A TESFaction form ID, as a number or hex string.
amount
The new crime gold, 0 to 1,000,000; 0 clears it.
violent
The violent part (assault, murder), which the game's guards answer by attacking; the non-violent one (theft, trespass) when false or left out.

Returns True when sent; false when the player is gone.

addBounty(faction: number | string, amount: number, violent?: boolean): boolean

Adds to the bounty a player owes a crime faction, as Papyrus `Faction.ModCrimeGold` does; a negative amount pays part of it off.

faction
A TESFaction form ID, as a number or hex string.
amount
How much to add, -1,000,000 to 1,000,000; never below 0 in all.
violent
The violent part (assault, murder), which the game's guards answer by attacking; the non-violent one (theft, trespass) when false or left out.

Returns True when sent; false when the player is gone.

removeFromAllFactions(): boolean

Takes the player out of every faction the server put them in. The factions their character holds from the game's own data stay.

Returns True when sent; false when the player is gone.

fastTravel(destination: number | string): boolean

Has the player's game fast travel to a reference, through the game's own fast travel, as `Game.FastTravel` does. `playerFastTravel` is not raised: the script decided already.

destination
The reference to arrive at: a map marker, or any other placed reference.

Returns True when sent; false when the player is gone.

getLocation(): number | null

The named location the player is in, a BGSLocation form ID, as their game last reported it.

Returns Null in the open, before their first report, or when the player is gone.

getMapWaypoint(): Vector3 | null

Where the player's own map marker is: the waypoint they dropped on the Pip-Boy map, or the one a script set.

Returns The position, in the space they stood in; null while they have none or when the player is gone.

setMapWaypoint(position: Vector3 | null): boolean

Places the player's own map marker, which their compass and Pip-Boy map show, or takes it off. `playerMapWaypoint` is not raised: the script decided already.

position
Where to, in the space the player stands in; null takes it off.

Returns True when sent; false when the player is gone.

discoverLocations(markers: (number | string)[], canTravel?: boolean): boolean

Puts map markers on the player's map, as `ObjectReference.AddToMap` does, without its notice. The map is their game's own: the server keeps no copy, so send it again when they join.

markers
Map marker references, each a form ID as a number or hex string; up to 4096.
canTravel
Also fast travel destinations (default true); false shows them on the map only.

Returns True when sent; false when the player is gone.

forgetLocations(markers: (number | string)[]): boolean

Takes map markers off the player's map; they stop being fast travel destinations.

markers
Map marker references, each a form ID as a number or hex string; up to 4096.

Returns True when sent; false when the player is gone.

setGameSetting(name: string, value: number | boolean): boolean

Changes one of the game's own tuning values (a game setting, GMST) in the player's game, where it takes effect at once and lasts until they leave. The server keeps no copy: to make it a rule, set it for each player as they join. A name their game has not, or a value of the wrong kind, changes nothing there.

name
The setting's name as the game's data defines it: "fJumpHeightMin", "fSprintSpeedMult".
value
The new value, of the setting's kind: a boolean for a b setting, a number for the others.

Returns True when sent; false when the player is gone.

setDifficulty(difficulty: "veryEasy" | "easy" | "normal" | "hard" | "veryHard" | "survival"): boolean

Sets the game's difficulty for the player, as its settings menu does: how hard they hit and are hit. "survival" is the game's Survival mode with all its rules, run by its own quest in the player's game: hunger, thirst and sleep, illness, carry weight that hurts, no fast travel, no saving, no compass markers for unfound places. It lasts until they leave, when their game goes back to what it was; set it again for each player as they join.

difficulty
The game's difficulty setting.

Returns True when sent; false when the player is gone.

setVatsRolledByServer(enabled: boolean): boolean

Moves the roll of the player's VATS hits to the server. Their game rolls each queued shot against the chance it shows; while this is on, every shot with a chance above 0 strikes instead, and its hit reaches `playerHit` or `npcHit` as kind "vats" with that chance: the handler rolls it (`Math.random() < vatsChance`) and returns `false` for a miss. Lasts until they leave; set it again for each player as they join.

enabled
True to roll the player's VATS hits on the server, false to leave them to their game.

Returns True when sent; false when the player is gone.

setWeather(weather: number | string | null, force?: boolean): boolean

Gives the player a sky of their own, over the one `World` holds for everyone: the weather of the worldspace they stand in, a storm over one quest, a clear sky for a cutscene. The server strikes its lightning as for the World's. Lasts until they leave: to make it a rule, set it on `playerSpaceChange`, `playerWeatherRegionChange` or as they join.

weather
A TESWeather form ID for this player alone; null to follow `World.weather` again.
force
Swap it in at once rather than transition to it.

Returns True when sent; false when the player is gone.

setHour(hour: number | null): boolean

Holds the player's clock, and the sun and the sky with it, at an hour of their own until it is released. Their game's day count and date stay the world's. Lasts until they leave.

hour
The hour to hold the player's clock at, wrapped into 0-24; null to follow `World.hour` again.

Returns True when sent; false when the player is gone.

getWeather(): number | null

The weather `setWeather` gave the player alone.

Returns Null while they follow `World.weather`, or once they are gone.

strikeLightning(): boolean

Strikes lightning in the player's sky alone: a flash and a thunderclap, if their sky is in a weather that thunders. In a session the game's own strikes come from the server (`World.setLightningEnabled`).

Returns True when sent; false when the player is gone.

getWeatherRegion(): number

The region whose weathers the player's game would roll where they stand, as their game finds it each time they change cell: the TESRegion form ID, for `World.getRegionWeathers`.

Returns 0 when they stand in no region with weathers, or their game has not said yet.

static getInRange(center: Vector3 | Player | Npc, radius: number, options?: { space?: { worldSpace: number } | { interiorCell: number }; limit?: number }): Player[]

The players around a point, a player or an NPC, nearest first, as FiveM scripts run GetActivePlayers through a distance check: who hears a shout, who stands in a zone, who is close enough to trade. Positions are the ones the players' games last reported.

center
A point, or a player or an NPC, whose position and space are then the search's; a player is not counted among its own.
radius
How far from it, in game units.
options
`space`: where a point is, the Commonwealth when left out. `limit`: how many at most, 32 by default, never more than 512.

Returns Empty when nobody is in range, or the center is gone. Throws for a center that is none of these, or a negative radius.

static setWeaponDamageModifier(weapon: number | string, modifier: number)

Scales the damage every hit of a weapon deals, whoever wields it, players and NPCs alike, as FiveM's SetWeaponDamageModifier does; it stacks with the attacker's `setDamageModifier` and the victim's `setDefenseModifier`. It lasts while the server runs.

weapon
The weapon (WEAP) whose hits are scaled.
modifier
From 0 to 100: 1 for none, which forgets it.
static getWeaponDamageModifier(weapon: number | string): number

What `setWeaponDamageModifier` scales the weapon's hits by.

weapon
The weapon (WEAP).

Returns The modifier; 1 when none was set.

static all(): Player[]

Every connected player.

Returns One handle per player, in no particular order.

static getById(id: number): Player | null

Looks a player up by network ID.

id
Network entity identifier.

Returns The handle, or null when no connected player has that ID.

BasePlayer

classextends Entity

Framework-owned base handle for a connected player, extended by each game or mod.

Constructor
new BasePlayer(id: number)

Creates a wrapper for an existing connected player with this ID; it does not connect or spawn a player.

id
Network entity identifier.
Properties
steamId: stringread-only

Authenticated Steam identifier, or an empty string when unavailable.

epicId: stringread-only

Epic Games account identifier the client reported, not verified by the server, or an empty string when unavailable.

discordId: stringread-only

Authenticated Discord identifier, or an empty string when unavailable.

discordName: stringread-only

Discord username the client reported, not verified by the server, or an empty string when unavailable.

hardwareId: stringread-only

Framework hardware identifier, or an empty string when unavailable.

ping: numberread-only

Current round-trip latency in milliseconds, or -1 when unavailable.

ip: stringread-only

Current remote network address, or an empty string when unavailable.

Methods
toString(): string

Formats this player handle for logging and debugging.

Returns Text containing the player's network entity ID.

isNametagVisible(): boolean

Checks whether this player's nametag is shown to other players.

Returns True unless the nametag was hidden; false also when this game has no nametags.

isNametagHealthVisible(): boolean

Checks whether the health bar under this player's nametag is shown.

Returns True unless the health bar was hidden; false also when this game has no nametags.

getNametagText(): string

Reads this player's nametag text override.

Returns The override, or an empty string when the player's own name is drawn.

getNametagColor(): number

Reads this player's nametag color.

Returns Packed 0xAARRGGBB color; opaque white when untinted.

kick(reason?: string)

Disconnects this player from the server.

reason
Optional reason shown to the disconnected player; omitting it uses the generic kicked reason.
emit(eventName: string, payloadJson?: string)

Emits a named script event to this player's client connection.

eventName
Client event name.
payloadJson
Optional JSON payload forwarded verbatim to the owning client.
getIP(): string

Returns this player's current remote network address.

Returns Address string, or an empty string when the player or peer is unavailable.

setNametagVisible(visible: boolean)

Shows or hides the name over this player's head for every other player. The health bar has its own switch, and each player can still hide all nametags locally.

visible
True to show this player's nametag to everyone, false to hide it.
setNametagHealthVisible(visible: boolean)

Shows or hides the health bar under this player's nametag, leaving the name itself alone.

visible
True to show the health bar under this player's name, false to hide it.
setNametagText(text?: string)

Overrides the text drawn on this player's nametag.

text
Text to show instead of the player's name, cut to 64 bytes; empty or omitted restores the name.
setNametagColor(color: number)

Tints the text on this player's nametag.

color
Packed 0xAARRGGBB color.

Entity

class

Base handle for a live replicated network entity.

Constructor
new Entity(id: number)

Creates a script wrapper for an existing entity with this ID; it does not spawn an entity.

id
Network entity identifier.
Properties
id: numberread-only

Immutable network entity identifier.

virtualWorld: numberread-only

Current virtual-world identifier.

position: Vector3

Authoritative world-space position; assignment forces replicated state.

rotation: Quaternion | Vector3

Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.

state: StateBagread-only

Arbitrary key/value state carried by this entity. The server writes it and every client that can see the entity receives it; see StateBag.

Methods
toString(): string

Formats this entity handle for logging and debugging.

Returns Text containing the network entity ID.

setVirtualWorld(world: number)

Moves this entity into another virtual world.

world
Virtual-world identifier used to partition replication and visibility.
setVisibleTo(player: Entity | null)

Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.

player
Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.

Item

classextends Entity

A loose item in the world: one a player dropped or a script spawned. Picking it up destroys it, after which the handle reads nothing. Setting `position` moves it for everyone.

Constructor
new Item(id: number)

Wraps an existing item with this ID; it spawns nothing. See `Item.spawn`.

id
Network entity identifier.
Properties
form: numberread-only

The base object's form ID; 0 once it is gone.

count: numberread-only

How many the stack holds; 0 once it is gone.

Methods
destroy(): boolean

Takes the item out of the world for everyone.

Returns True when it was there to take.

toString(): string

Formats this handle for logging.

Returns The item's network ID, form and count.

getSpace(): PlayerSpace | null

Where the item lies.

Returns The worldspace or interior cell, or null once it is gone.

static spawn(form: number | string, count: number, position: Vector3, space: { worldSpace?: number | string; interiorCell?: number | string }, angle?: Vector3): Item | null

Puts a loose item in the world, which any player can pick up. It does not fall: it stays where it is put.

form
The base object.
count
How many, 1 to 1000000.
position
Where it lies.
space
The worldspace, or the interior cell: exactly one of the two.
angle
Its rotation, radians.

Returns The item, or null when it could not be created.

static all(): Item[]

Every loose item in the world.

Returns One handle per item.

StateBag

class

Arbitrary key/value state attached to one replicated entity, reached as `entity.state`. Keys set on the server replicate to every client that can currently see the entity.

Methods
get(key: string): any

Reads one key from this entity's state.

key
Key to read.

Returns The stored value, or undefined when the key is not set.

has(key: string): boolean

Checks whether this entity's state holds a key.

key
Key to test.

Returns True when the key is set.

keys(): string[]

Lists the keys this entity's state holds, sorted.

Returns Every key currently set, in ascending order.

toObject(): Record<string, any>

Copies this entity's whole state into a plain object.

Returns Every key and value currently set. The copy does not track later changes.

onChange(key: string | null, handler: Function): Function

Watches this entity's state. The filter is applied before the handler runs, so a listener watching one key of one entity is not woken by unrelated changes. The subscription is dropped when the registering resource stops.

key
Only report this key, or null to report every key of this entity.
handler
Called as (key: string, value: any, previous: any) with the changed key, its new value and the value before it. `value` is undefined when the key was removed and `previous` is undefined when it held nothing.

Returns A zero-argument function that cancels this subscription.

set(key: string, value: any, options?: { scope?: 'broadcast' | 'owner' | 'server' }): boolean

Writes one key of this entity's state and replicates it to whoever the scope names. Throws when a limit is reached.

key
Key to write; at most 64 UTF-8 bytes.
value
Value to store. Booleans, numbers and strings travel as themselves; anything else is serialized as JSON. At most 4096 bytes.
options
Who the key reaches: every client that can see the entity (the default), only its owning client, or nobody -- server-side storage that never goes on the wire.

Returns True when the value changed, false when it was already stored.

remove(key: string): boolean

Removes one key from this entity's state, telling every client that held it.

key
Key to drop.

Returns True when the key was set and has been removed.

PendingConnection

type

A player asking to join, handed to `playerConnecting`. Every identifier is reported by the player's own client and is not verified by the server.

Properties
nickname: stringread-only

The name the player asked to join under.

steamId: stringread-only

Steam identifier the client reported, or an empty string when it had none.

epicId: stringread-only

Epic Games account identifier the client reported, or an empty string when it had none.

discordId: stringread-only

Discord identifier the client reported, or an empty string when it had none.

discordName: stringread-only

Discord username the client reported, or an empty string when it had none.

hardwareId: stringread-only

Framework hardware identifier the client reported, or an empty string when it had none.

ticket: stringread-only

The string the client was launched with, as the `ticket` of its launch link, or an empty string. The framework passes it through untouched; checking it -- against a one-time join ticket your own launcher or website issued, typically -- is the script's job.

ip: stringread-only

The remote address the connection comes from, without its port.

Methods
reject(reason?: string)

Turns the player away before they receive anything. Takes effect on the next server tick, whatever other handlers are still doing. Does nothing once the connection is decided or the player has left.

reason
Shown to the player as written, up to 512 bytes. Omitted, they read that the server refused the connection.
update(message: string)

Shows the waiting player a line of status and restarts the admission timeout, so a queue that keeps updating its players is never timed out. Does nothing once the connection is decided or the player has left.

message
One line for the player's connecting screen, up to 256 bytes: 'Checking the whitelist', 'You are 4th in the queue'.
isPending(): boolean

Checks whether this connection is still waiting on a decision.

Returns False once it was let in or turned away, or the player gave up and left; a queue drops such entries.

Maths and colour

Positions, rotations and colours, with the operators you expect.

Vector2

class

Mutable two-dimensional vector.

Constructor
new Vector2(x: number, y: number)

Creates a vector from two numeric components.

x
Initial X component.
y
Initial Y component.
Properties
x: number

Mutable X component.

y: number

Mutable Y component.

length: numberread-only

Read-only Euclidean magnitude of this vector.

lengthSquared: numberread-only

Read-only squared magnitude, avoiding a square-root calculation.

Methods
add(other: Vector2): this

Adds another vector to this vector in place.

other
Vector to add component-wise.

Returns This mutated vector for chaining.

sub(other: Vector2): this

Subtracts another vector from this vector in place.

other
Vector to subtract component-wise.

Returns This mutated vector for chaining.

mul(scalar: number): this

Multiplies this vector by a scalar in place.

scalar
Multiplier applied to both components.

Returns This mutated vector for chaining.

div(scalar: number): this

Divides this vector by a scalar in place.

scalar
Divisor applied to both components; must be non-zero.

Returns This mutated vector for chaining.

dot(other: Vector2): number

Computes the dot product without changing either vector.

other
Vector used for the dot product.

Returns Scalar dot product.

normalize(): this

Normalizes this vector in place; a zero vector remains unchanged.

Returns This mutated vector for chaining.

lerp(target: Vector2, t: number): this

Linearly interpolates this vector toward a target in place.

target
Destination vector.
t
Interpolation factor; 0 keeps the current value and 1 reaches target.

Returns This mutated vector for chaining.

set(x: number, y: number): this

Replaces both components in place.

x
Replacement X component.
y
Replacement Y component.

Returns This mutated vector for chaining.

distance(other: Vector2): number

Computes Euclidean distance to another vector.

other
Vector to measure from this vector.

Returns Distance between the two vectors.

clone(): Vector2

Creates an independent copy of this vector.

Returns New vector with the same components.

toString(): string

Formats this vector for logging and debugging.

Returns Text in Vector2(x, y) form.

toJSON(): { x: number; y: number }

Converts this vector to a plain object for JSON.stringify.

Returns Object containing the current components.

static zero(): Vector2

Creates a vector whose components are zero.

Returns New Vector2(0, 0).

static one(): Vector2

Creates a vector whose components are one.

Returns New Vector2(1, 1).

Vector3

class

Mutable three-dimensional vector for positions, directions, and Euler angles.

Constructor
new Vector3(x: number, y: number, z: number)

Creates a vector from three numeric components.

x
Initial X component.
y
Initial Y component.
z
Initial Z component.
Properties
x: number

Mutable X component.

y: number

Mutable Y component.

z: number

Mutable Z component.

length: numberread-only

Read-only Euclidean magnitude of this vector.

lengthSquared: numberread-only

Read-only squared magnitude, avoiding a square-root calculation.

Methods
add(other: Vector3): this

Adds another vector to this vector in place.

other
Vector to add component-wise.

Returns This mutated vector for chaining.

sub(other: Vector3): this

Subtracts another vector from this vector in place.

other
Vector to subtract component-wise.

Returns This mutated vector for chaining.

mul(scalar: number): this

Multiplies this vector by a scalar in place.

scalar
Multiplier applied to every component.

Returns This mutated vector for chaining.

div(scalar: number): this

Divides this vector by a scalar in place.

scalar
Divisor applied to every component; must be non-zero.

Returns This mutated vector for chaining.

dot(other: Vector3): number

Computes the dot product without changing either vector.

other
Vector used for the dot product.

Returns Scalar dot product.

cross(other: Vector3): this

Replaces this vector with its cross product against another vector.

other
Second vector in the cross product.

Returns This mutated perpendicular vector for chaining.

normalize(): this

Normalizes this vector in place; a zero vector remains unchanged.

Returns This mutated vector for chaining.

lerp(target: Vector3, t: number): this

Linearly interpolates this vector toward a target in place.

target
Destination vector.
t
Interpolation factor; 0 keeps the current value and 1 reaches target.

Returns This mutated vector for chaining.

set(x: number, y: number, z: number): this

Replaces all components in place.

x
Replacement X component.
y
Replacement Y component.
z
Replacement Z component.

Returns This mutated vector for chaining.

distance(other: Vector3): number

Computes Euclidean distance to another vector.

other
Vector to measure from this vector.

Returns Distance between the two vectors.

clone(): Vector3

Creates an independent copy of this vector.

Returns New vector with the same components.

toString(): string

Formats this vector for logging and debugging.

Returns Text in Vector3(x, y, z) form.

toJSON(): { x: number; y: number; z: number }

Converts this vector to a plain object for JSON.stringify.

Returns Object containing the current components.

static zero(): Vector3

Creates a zero vector.

Returns New Vector3(0, 0, 0).

static one(): Vector3

Creates a vector whose components are one.

Returns New Vector3(1, 1, 1).

static up(): Vector3

Creates the framework's positive-Y unit direction.

Returns New Vector3(0, 1, 0).

static forward(): Vector3

Creates the framework's positive-Z unit direction.

Returns New Vector3(0, 0, 1).

static right(): Vector3

Creates the framework's positive-X unit direction.

Returns New Vector3(1, 0, 0).

Vector4

class

Mutable four-dimensional vector.

Constructor
new Vector4(x: number, y: number, z: number, w: number)

Creates a vector from four numeric components.

x
Initial X component.
y
Initial Y component.
z
Initial Z component.
w
Initial W component.
Properties
x: number

Mutable X component.

y: number

Mutable Y component.

z: number

Mutable Z component.

w: number

Mutable W component.

length: numberread-only

Read-only Euclidean magnitude of this vector.

lengthSquared: numberread-only

Read-only squared magnitude, avoiding a square-root calculation.

Methods
add(other: Vector4): this

Adds another vector to this vector in place.

other
Vector to add component-wise.

Returns This mutated vector for chaining.

sub(other: Vector4): this

Subtracts another vector from this vector in place.

other
Vector to subtract component-wise.

Returns This mutated vector for chaining.

mul(scalar: number): this

Multiplies this vector by a scalar in place.

scalar
Multiplier applied to every component.

Returns This mutated vector for chaining.

div(scalar: number): this

Divides this vector by a scalar in place.

scalar
Divisor applied to every component; must be non-zero.

Returns This mutated vector for chaining.

dot(other: Vector4): number

Computes the dot product without changing either vector.

other
Vector used for the dot product.

Returns Scalar dot product.

distance(other: Vector4): number

Computes Euclidean distance to another vector.

other
Vector to measure from this vector.

Returns Distance between the two vectors.

normalize(): this

Normalizes this vector in place; a zero vector remains unchanged.

Returns This mutated vector for chaining.

lerp(target: Vector4, t: number): this

Linearly interpolates this vector toward a target in place.

target
Destination vector.
t
Interpolation factor; 0 keeps the current value and 1 reaches target.

Returns This mutated vector for chaining.

set(x: number, y: number, z: number, w: number): this

Replaces all components in place.

x
Replacement X component.
y
Replacement Y component.
z
Replacement Z component.
w
Replacement W component.

Returns This mutated vector for chaining.

clone(): Vector4

Creates an independent copy of this vector.

Returns New vector with the same components.

toString(): string

Formats this vector for logging and debugging.

Returns Text in Vector4(x, y, z, w) form.

toJSON(): { x: number; y: number; z: number; w: number }

Converts this vector to a plain object for JSON.stringify.

Returns Object containing the current components.

static zero(): Vector4

Creates a zero vector.

Returns New Vector4(0, 0, 0, 0).

static one(): Vector4

Creates a vector whose components are one.

Returns New Vector4(1, 1, 1, 1).

Quaternion

class

Mutable quaternion for three-dimensional rotations. Components are scalar-first (w, x, y, z), matching GLM — not the x, y, z, w order some libraries use.

Constructor
new Quaternion(w: number, x: number, y: number, z: number)

Creates a quaternion in scalar-first w, x, y, z component order. Watch the trap: the scalar w is the first argument, unlike the x, y, z, w order used by some other libraries.

w
Initial scalar component (comes first — this is not x, y, z, w order).
x
Initial X imaginary component.
y
Initial Y imaginary component.
z
Initial Z imaginary component.
Properties
w: number

Mutable scalar component.

x: number

Mutable X imaginary component.

y: number

Mutable Y imaginary component.

z: number

Mutable Z imaginary component.

length: numberread-only

Read-only magnitude (norm) of this quaternion; 1 for a unit rotation.

lengthSquared: numberread-only

Read-only squared magnitude, avoiding a square-root calculation.

Methods
mul(other: Quaternion): this

Composes this rotation with another quaternion in place.

other
Rotation composed after this quaternion.

Returns This mutated quaternion for chaining.

normalize(): this

Normalizes this quaternion in place; a zero quaternion becomes the identity rotation instead of NaN.

Returns This unit quaternion for chaining.

conjugate(): Quaternion

Computes the conjugate without changing this quaternion.

Returns New conjugated quaternion.

inverse(): Quaternion

Computes the inverse rotation without changing this quaternion.

Returns New inverse quaternion.

slerp(target: Quaternion, t: number): this

Spherically interpolates this quaternion toward a target in place.

target
Destination rotation.
t
Interpolation factor; 0 keeps the current rotation and 1 reaches target.

Returns This mutated quaternion for chaining.

dot(other: Quaternion): number

Computes the quaternion dot product.

other
Quaternion used for the dot product.

Returns Scalar dot product.

rotateVector(vector: Vector3): Vector3

Applies this rotation to a vector without mutating either value.

vector
Vector to rotate.

Returns New rotated vector.

toEuler(): Vector3

Converts this rotation to Euler angles in radians.

Returns Pitch, yaw, and roll as a Vector3.

set(w: number, x: number, y: number, z: number): this

Replaces all quaternion components in place.

w
Replacement scalar component.
x
Replacement X imaginary component.
y
Replacement Y imaginary component.
z
Replacement Z imaginary component.

Returns This mutated quaternion for chaining.

clone(): Quaternion

Creates an independent copy of this quaternion.

Returns New quaternion with the same components.

toString(): string

Formats this quaternion for logging and debugging.

Returns Text in Quaternion(w, x, y, z) form.

toJSON(): { w: number; x: number; y: number; z: number }

Converts this quaternion to a plain object for JSON.stringify.

Returns Object containing the current components.

static identity(): Quaternion

Creates the identity rotation.

Returns New Quaternion(1, 0, 0, 0).

static fromEuler(pitch: number, yaw: number, roll: number): Quaternion

Creates a rotation from Euler angles.

pitch
Pitch angle in radians.
yaw
Yaw angle in radians.
roll
Roll angle in radians.

Returns New rotation quaternion.

static fromAxisAngle(axis: Vector3, angle: number): Quaternion

Creates a rotation around an axis.

axis
Rotation axis; it is normalized internally.
angle
Rotation angle in radians.

Returns New axis-angle rotation quaternion.

Color

class

Mutable RGBA color, with components stored from 0 to 1.

Constructor
new Color(r: number, g: number, b: number, a?: number)

Creates a color from normalized RGBA components.

r
Initial red component from 0 to 1.
g
Initial green component from 0 to 1.
b
Initial blue component from 0 to 1.
a
Optional alpha component from 0 to 1; defaults to 1.
Properties
r: number

Mutable normalized red component.

g: number

Mutable normalized green component.

b: number

Mutable normalized blue component.

a: number

Mutable normalized alpha component.

Methods
lerp(target: Color, t: number): this

Linearly interpolates every component toward a target in place.

target
Destination color.
t
Interpolation factor; 0 keeps this color and 1 reaches target.

Returns This mutated color for chaining.

set(r: number, g: number, b: number, a?: number): this

Replaces this color's normalized components in place.

r
Replacement red component from 0 to 1.
g
Replacement green component from 0 to 1.
b
Replacement blue component from 0 to 1.
a
Optional replacement alpha; defaults to 1 when omitted.

Returns This mutated color for chaining.

clone(): Color

Creates an independent copy of this color.

Returns New color with the same components.

toHex(includeAlpha?: boolean): string

Converts normalized components to a hexadecimal CSS-style string.

includeAlpha
Whether to append the alpha byte; defaults to false.

Returns Lowercase #rrggbb or #rrggbbaa string.

toString(): string

Formats this color for logging and debugging.

Returns Text in Color(r, g, b, a) form.

toJSON(): { r: number; g: number; b: number; a: number }

Converts this color to a plain object for JSON.stringify.

Returns Object containing the current normalized components.

static fromHex(hex: string): Color

Parses a hexadecimal color string.

hex
Hexadecimal color in #RRGGBB or #RRGGBBAA form; the leading # is optional. Three- and four-digit shorthands are not supported.

Returns Parsed color, or opaque white when the input is invalid.

static fromRGB(r: number, g: number, b: number, a?: number): Color

Creates a normalized color from byte components.

r
Red byte from 0 to 255.
g
Green byte from 0 to 255.
b
Blue byte from 0 to 255.
a
Optional alpha byte from 0 to 255; defaults to 255.

Returns New normalized color.

static white(): Color

Creates opaque white.

Returns New Color(1, 1, 1, 1).

static black(): Color

Creates opaque black.

Returns New Color(0, 0, 0, 1).

static red(): Color

Creates opaque red.

Returns New Color(1, 0, 0, 1).

static green(): Color

Creates opaque green.

Returns New Color(0, 1, 0, 1).

static blue(): Color

Creates opaque blue.

Returns New Color(0, 0, 1, 1).

static yellow(): Color

Creates opaque yellow.

Returns New Color(1, 1, 0, 1).

static cyan(): Color

Creates opaque cyan.

Returns New Color(0, 1, 1, 1).

static magenta(): Color

Creates opaque magenta.

Returns New Color(1, 0, 1, 1).

static transparent(): Color

Creates fully transparent black.

Returns New Color(0, 0, 0, 0).

Other types

The structural types the API passes around.

PlayerSpace

type

Where a player is: the worldspace it stands in, or the interior cell, which has none.

Properties
worldSpace: number

The TESWorldSpace form ID; 0 inside an interior.

interiorCell: number

The interior TESObjectCELL form ID; 0 outside.

PlayerWeapon

type

The weapon in a player's hands, drawn or holstered.

Properties
form: number

The TESObjectWEAP form ID.

ammo: number

The ammo form ID it loads; 0 for none.

mods: number[]

The OMOD form IDs attached to it.

OutfitPiece

type

One armor piece a player wears, with the mods attached to it.

Properties
form: number

The TESObjectARMO form ID.

mods: number[]

The OMOD form IDs attached to it.

PlayerPowerArmor

type

The power armor frame a player wears.

Properties
frame: number | null

The frame's reference form ID when the data files placed it; null for one the game created at runtime.

base: number | null

The frame's TESFurniture form ID; null when the game created that record at runtime.

battery: number

The charge left in the inserted fusion core, in whole units rounded up; 0 when it is empty or there is none.

batteryMax: number

The inserted fusion core's capacity, 100 for the game's own; 0 while none was ever inserted.

InventoryItem

type

A stack in a player's inventory, as the server's record holds it.

Properties
form: number

The base object's form ID.

count: number

How many the player carries.

condition: number

The stack's condition in percent of full, 0 to 100: the charge a fusion core has left. 100 for an item that has none.

mods: number[]

The OMOD form IDs attached to the stack, in the order it keeps them; empty for an item that takes none, or that the game gives its default ones.

WorldDate

type

A calendar date as the game keeps it: twelve months of 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 and 31 days, no leap years.

Properties
year: number

The full year, 2000 to 2999.

month: number

1 to 12.

day: number

1 to the month's last.

WeatherRecord

type

A weather the game's data files define.

Properties
weather: number

The TESWeather form ID.

editorId: string

Its editor ID: "CommonwealthClear", "CommonwealthRadstorm".

kind: "none" | "pleasant" | "cloudy" | "rain" | "snow"

Its classification, as the game's GetIsPleasant/Cloudy/Rain/Snow conditions read it.

ClimateWeather

type

One weather a climate rolls.

Properties
weather: number

The TESWeather form ID.

chance: number

Its weight among the climate's weathers, as the data files give it (they sum to 100 in the official climates).

Climate

type

The weathers a worldspace's sky rolls once a weather has run its course.

Properties
editorId: string

The climate's editor ID.

weathers: ClimateWeather[]

Its weathers and their chances.

Explosion

global

Explosions set off in every player's game at once, as the game sets off its own: the blast, its light, sound, debris and decals, and whatever the explosion leaves behind. An explosion is named by form ID (a number or hex string) or by its editor ID in the official masters ("FragGrenadeExplosion").

Methods
spawn(explosion: number | string, position: Vector3, options?: { space?: { worldSpace?: number | string; interiorCell?: number | string }; scale?: number; damage?: number; owner?: Player | Npc })

Sets off an explosion in the game of every player in that space whose game has the spot loaded. Each game's blast hurts what that game simulates: its own player, the NPCs it runs.

explosion
A BGSExplosion (EXPL) form ID: a frag grenade's, a mini nuke's, a car's.
position
Where it goes off.
options
`space`: the worldspace or interior cell; the owner's when an owner is given, else the Commonwealth. `scale`: of its radii, 1 by default. `damage`: a multiplier of its damage, 0 for one that hurts nobody. `owner`: who it is credited to.

Effect

global

Effects in every player's game: placed effects that stream like any entity, effect shaders and visual effects on bodies and references, and impacts. Forms are named by form ID (a number or hex string) or by their editor ID in the official masters; an editor ID made only of hex digits reads as a form ID.

Methods
spawn(form: number | string, position: Vector3 | null, options?: { angle?: Vector3; space?: { worldSpace?: number | string; interiorCell?: number | string }; lifetime?: number; range?: number; attach?: { to: Player | Npc | number | string; node?: string; offset?: Vector3; rotation?: Vector3 } }): number

Places an effect every player near it sees, players who come near later included: each game places its own copy while they are in range. Attached, it is a prop: a box carried, a lantern on the back, a flame over a head.

form
The base object to place: a fog patch, a smoke column or a fire (the game's FX statics, movable statics and activators), a hazard (HAZD), a light (LIGH), any other placeable object.
position
Where it stands; null for an attached one, which starts where its body stands.
options
`angle`: its rotation in radians. `space`: the worldspace or interior cell; the body's when attached, else the Commonwealth. `lifetime`: seconds until it is removed on its own; it stays until `remove` when left out. `range`: how near players must be to have it, 8192 units by default. `attach`: holds it on a body or a placed reference every frame, on the named node ("WEAPON", "RArm_Hand", "Head"; the root when left out), shifted by `offset` and turned by `rotation` (radians) in the node's frame; everyone in the space has it. Give it something without collision, or it pushes what it touches.

Returns The effect's ID, for `remove`; 0 when it could not be made.

remove(effect: number): boolean

Removes a placed effect from every game.

effect
An ID `spawn` gave.

Returns False when there is no such effect.

move(effect: number, position: Vector3, angle?: Vector3): boolean

Moves a placed effect in every game, players who come near later included: a lift, a gate, a prop a script carries. Each call is one step; call it each tick for a glide.

effect
An ID `spawn` gave.
position
Where it stands now.
angle
Its rotation in radians; kept when left out.

Returns False when there is no such effect, or it is attached.

exists(effect: number): boolean

Whether a placed effect is still there: its lifetime may have run out.

effect
An ID `spawn` gave.
playShader(target: Player | Npc | number | string, shader: number | string, seconds?: number)

Plays an effect shader over a body or a reference in every game where it is loaded, as EffectShader.Play does.

target
A player, an NPC, or a placed reference's form ID.
shader
A TESEffectShader (EFSH) form ID: a glow, a burn, a membrane.
seconds
How long; until `stopShader` when left out.
stopShader(target: Player | Npc | number | string, shader: number | string)

Stops an effect shader on a body or a reference.

target
A player, an NPC, or a placed reference's form ID.
shader
The shader played.
playVisual(target: Player | Npc | number | string, effect: number | string, seconds?: number)

Attaches a visual effect to a body or a reference in every game where it is loaded, as VisualEffect.Play does.

target
A player, an NPC, or a placed reference's form ID.
effect
A BGSReferenceEffect (RFCT) form ID: an art object's particles or model, with or without a shader.
seconds
How long; until `stopVisual` when left out.
stopVisual(target: Player | Npc | number | string, effect: number | string)

Takes a visual effect off a body or a reference.

target
A player, an NPC, or a placed reference's form ID.
effect
The visual effect played.
playImpact(target: Player | Npc | number | string, impactSet: number | string, options?: { node?: string; direction?: Vector3; length?: number })

Plays an impact where a ray from the target lands, in every game where the target is loaded, as ObjectReference.PlayImpactEffect does: the decal, particles and sound of the surface's material.

target
A player, an NPC, or a placed reference's form ID.
impactSet
A BGSImpactDataSet (IPDS) form ID: what each material shows when hit.
options
The ray: from the named node of the target (its root when left out), along the direction (straight down by default), for the length in game units (512).

Sound

global

Sounds in every player's game at once, heard where each game places its listener.

Methods
play(sound: number | string, at: Vector3 | Player | Npc | number | string, options?: { space?: { worldSpace?: number | string; interiorCell?: number | string }; volume?: number }): number

Plays a sound for every player near enough to hear it: the descriptor's own attenuation decides how far it carries.

sound
A sound descriptor (SNDR) by form ID or editor ID.
at
A spot, or a player, an NPC or a placed reference the sound follows as it moves.
options
`space`: the spot's worldspace or interior cell, the Commonwealth when left out. `volume`: 0 to 1, 1 by default.

Returns The sound's number, for `stop`.

stop(sound: number)

Stops a sound in every game still playing it.

sound
A number `play` gave.

InventoryDelta

type

How many of one item a player's inventory gained or lost.

Properties
form: number

The base object's form ID.

delta: number

Gained when positive, lost when negative.

condition: number

The stack's condition in percent of full, 0 to 100: the charge a fusion core has left. 100 for an item that has none.

mods: number[]

The OMOD form IDs attached to the stack, in the order it keeps them; empty for an item that takes none.

from: number | null

The reference on the other side, such as a container; null for none the game named.

CharacterDocument

type

A whole character, as getCharacter gives it and setCharacter takes it. Actor values are keyed by editor ID; forms are hex strings.

Properties
version: number

The document's format, 1.

nickname: string

The nickname of the player it was taken from.

experience: number

Total XP.

level: number

The level.

perkPoints: number

Unspent perk points.

values: Record<string, number>

Actor value bases: SPECIAL and any a script set.

perks: string[]

The BGSPerk ranks held.

current: Record<string, number>

Health, ActionPoints and Rads as they stood.

inventory: { form: string; count: number }[]

What the character carries.

Faction

global

How the game's factions react to each other, on every client. Combined with `Player.setFactionRank` it decides who the game treats as friend or foe: NPCs, turrets and companions alike.

Methods
getReaction(faction: number | string, other: number | string): "neutral" | "enemy" | "ally" | "friend" | null

How one faction reacts to another, where the server overrides it.

faction
A TESFaction form ID, as a number or hex string.
other
The faction it reacts to, as a number or hex string.

Returns The reaction; null when the game's data files decide.

setReaction(faction: number | string, other: number | string, reaction: "neutral" | "enemy" | "ally" | "friend", mutual?: boolean): boolean

Overrides how one faction reacts to another on every client, as `Faction.SetAlly` and `Faction.SetEnemy` do, until it is cleared or the server stops. A faction can be its own enemy. Up to 64 directions are overridden at once.

faction
A TESFaction form ID, as a number or hex string.
other
The faction it reacts to, as a number or hex string.
reaction
Enemies fight on sight; allies and friends help each other, friends also in combat.
mutual
Both directions, as `Faction.SetAlly` and `Faction.SetEnemy` do; true when left out.

Returns True when set; false when the table is full.

clearReaction(faction: number | string, other: number | string, mutual?: boolean): boolean

Gives a reaction back to the game's data files on every client.

faction
A TESFaction form ID, as a number or hex string.
other
The faction it reacts to, as a number or hex string.
mutual
Both directions, as `Faction.SetAlly` and `Faction.SetEnemy` do; true when left out.

Returns True when one was overridden.

Zone

global

Areas of the world the server watches, as FiveM resources do with PolyZone: an upright cylinder, around a point in a worldspace or an interior. `zoneEnter` and `zoneLeave` tell scripts who came in and who went out, from the places players' games report: a safe zone, a shop's floor, a job's drop point. The server alone knows of them.

Methods
create(options: { center: Vector3; radius: number; height?: number; name?: string; space?: { worldSpace: number } | { interiorCell: number } }): number

Starts watching an area. Players already in it are told so at the next update.

options
`center` and `radius`, on the ground plane, in game units. `height`: how far above and below the center it reaches, no limit when left out. `name`: given back with its events. `space`: its worldspace or interior, the Commonwealth when left out.

Returns The zone's ID. Throws for a missing center or a radius that is not above 0.

remove(zone: number): boolean

Stops watching an area; the players in it are told they left.

zone
The zone's ID, as `create` gave it.

Returns False for an unknown ID.

getPlayers(zone: number): Player[]

The players in an area, as the last update found them.

zone
The zone's ID, as `create` gave it.

Returns Empty for an unknown ID.

contains(zone: number, position: Vector3, space?: { worldSpace: number } | { interiorCell: number }): boolean

Whether a point lies in an area: where an NPC stands, a drop, a spawn.

zone
The zone's ID, as `create` gave it.
position
The point.
space
Where the point is; the Commonwealth when left out.

Returns False for an unknown ID.

all(): number[]

Every zone's ID.

Returns In the order they were made.

Quests

global

The game's own quests, given to players as scripts decide. A player's game lists the quests they have in the Pip-Boy, and tracks the active ones on the HUD with the data files' quest name and objective texts. There is no quest logic here: scripts decide which quest a player has, which objectives they see, and when each is done. A player's quests go when they disconnect.

Methods
show(player: Player, quest: number): boolean

Gives the player the quest, with no objectives and not active. Nothing changes when they have it already.

player
A connected player.
quest
The quest's form ID (QUST) in the game's data files.

Returns False when the player is gone.

hide(player: Player, quest: number): boolean

Takes the quest and its objectives off the player.

player
A connected player.
quest
The quest's form ID (QUST) in the game's data files.

Returns False when they did not have it.

setActive(player: Player, quest: number, active: boolean): boolean

Tracks the quest on the player's HUD, or stops tracking it.

player
A connected player.
quest
The quest's form ID (QUST) in the game's data files.
active
Whether the HUD tracks it.

Returns False when they do not have the quest.

setObjective(player: Player, quest: number, index: number, state: 'hidden' | 'displayed' | 'completed' | 'failed'): boolean

Sets one of the quest's objectives for the player. A quest holds 32 objectives at most.

player
A connected player.
quest
The quest's form ID (QUST) in the game's data files.
index
The objective's index in the quest (its QOBJ value, as the data files give it).
state
'displayed' shows it on the HUD tracker; 'completed' and 'failed' mark it in the Pip-Boy; 'hidden' takes it off.

Returns False when they do not have the quest, or it holds 32 objectives already.

getShown(player: Player): number[]

The quests the player has, by form ID.

player
A connected player.

Returns Empty when they have none.

isActive(player: Player, quest: number): boolean | null

Whether the player's HUD tracks the quest.

player
A connected player.
quest
The quest's form ID (QUST) in the game's data files.

Returns Null when they do not have it.

getObjective(player: Player, quest: number, index: number): 'hidden' | 'displayed' | 'completed' | 'failed' | null

The state of one of the quest's objectives for the player.

player
A connected player.
quest
The quest's form ID (QUST) in the game's data files.
index
The objective's index in the quest (its QOBJ value, as the data files give it).

Returns Null when they do not have the quest.

Mine

classextends Entity

An armed mine a player laid. Its owner's game holds the mine and sets it off; the server decides when. Once it goes off or is removed the handle reads nothing. Mines go with their owner when they leave.

Constructor
new Mine(id: number)

Wraps an armed mine with this ID; it lays nothing.

id
Network entity identifier.
Properties
radius: numberread-only

How close a player must come to set it off, in game units; 0 once it is gone.

explosion: numberread-only

The BGSExplosion form ID it sets off; 0 once it is gone.

Methods
detonate(): boolean

Has the owner's game set the mine off where it lies, as if a player walked onto it. The blast is the owner's: `playerExplosion` and `playerHit` follow.

Returns True when sent; false when it is gone or already going off.

remove(): boolean

Takes the mine out of the world without a blast.

Returns True when it was armed.

toString(): string

Formats this handle for logging.

Returns The mine's network ID, owner and radius.

getOwner(): Player | null

The player who laid it.

Returns The owner, or null once the mine or its owner is gone.

static all(): Mine[]

Every armed mine.

Returns One handle per mine.

RadioStation

classextends Entity

A radio station every player's game carries. It joins each Pip-Boy's station list once heard and plays through world radios tuned to it, everywhere in the world. The server says what is on air and since when, so every player hears the same moment of the same track. A station outlives the resource that created it until destroyed.

Constructor
new RadioStation(id: number)

Wraps the station with this ID; it creates nothing.

id
Network entity identifier.
Properties
name: stringread-only

What the Pip-Boy lists it as; empty once it is gone.

frequency: numberread-only

The frequency it transmits on; 0 once it is gone.

sound: numberread-only

The BGSSoundDescriptorForm form ID on air; 0 while it is silent or plays a stream.

stream: stringread-only

The URL `playStream` put on air; empty while none is.

duration: numberread-only

How long the track on air runs, in milliseconds, as given to `play`; 0 when not given.

elapsed: numberread-only

How long the track on air has run, in milliseconds; 0 while it is silent.

Methods
stop(): boolean

Takes the track off air: every player's radio falls silent on this station.

Returns False once the station is gone.

destroy(): boolean

Takes the station off every player's radio.

Returns False once the station is gone.

toString(): string

Formats this handle for logging.

Returns The station's network ID, name and frequency.

play(sound: number | string, durationMs?: number): boolean

Puts a track on air from now, replacing what played. Only a player's data files can tell whether the form is a sound descriptor, so a wrong one stays silent. No event marks the end of a track: the script schedules the next one itself, from the duration it knows.

sound
A BGSSoundDescriptorForm form ID, as a number or hex string.
durationMs
How long it runs. With it, a player tuning in until then still hears it; without it, a player's radio drops it once it has played out.

Returns False once the station is gone.

playStream(url: string, durationMs?: number): boolean

Puts an audio stream on air from now, replacing what played: a server-hosted file, a playlist entry, a live DJ. Each player's game fetches it and plays it while their Pip-Boy radio is on and tuned to this station, at the position every other listener hears (a live stream plays from its live edge). World radios tuned to the station stay silent: only the Pip-Boy plays streams.

url
An http or https URL of an audio file (mp3, aac, wav, wma) or a live stream.
durationMs
How long it runs, as for `play`. Leave it out for a live stream.

Returns False once the station is gone, or for a URL that is not http or https.

static create(name: string, frequency: number): RadioStation | null

Creates a silent station on every player's radio.

name
What the Pip-Boy lists it as, up to 64 characters.
frequency
What it transmits on, 80 to 110, the Pip-Boy's dial; no other station may hold it. A game station on the same frequency plays over it unless the game's stations are off.

Returns The station, or null when the name or frequency was refused.

static setVanillaStationsEnabled(enabled: boolean)

Puts the game's own stations (Diamond City Radio, Classical Radio, and the quest signals and distress beacons too) on or off every player's radio. Each player's game runs them alone, so no two players hear the same thing on them. Off, they leave the Pip-Boy's list and every world radio, and the scenes behind them play out in person instead. A player joining later follows the setting.

enabled
False takes them off; true puts them back.
static areVanillaStationsEnabled(): boolean

Whether the game's own stations are on the radio.

Returns True unless a script turned them off.

static all(): RadioStation[]

Every station.

Returns One handle per station.

Blip

classextends Entity

A marker on every player's HUD compass and Pip-Boy map, as FiveM's blips: at a point, or following a player or an NPC. A player sees it while they are in its worldspace or interior. A blip outlives the resource that made it until destroyed. Move it with `setPosition` or `attachTo`, not by setting `position`.

Constructor
new Blip(id: number)

Wraps the blip with this ID; it creates nothing.

id
Network entity identifier.
Properties
label: stringread-only

What the Pip-Boy map's tooltip says; empty once it is gone.

Methods
destroy(): boolean

Takes the blip off every player's compass and map.

Returns False once it is gone.

toString(): string

Formats this handle for logging.

Returns The blip's network ID and label.

setPosition(position: Vector3, space?: { worldSpace: number } | { interiorCell: number }): boolean

Moves the blip to a point, as FiveM's SetBlipCoords does; it stops following anyone.

position
Where, in world units.
space
Where that is; its current space when left out.

Returns False once it is gone.

attachTo(target: Player | Npc | null): boolean

Has the blip follow a player or an NPC, as FiveM's AddBlipForEntity does: each player's game puts it on that body while it has it loaded, and on where the server last saw it otherwise.

target
Whose body to follow; null to stay where it is.

Returns False once it is gone.

getAttached(): Player | Npc | null

Whom the blip follows.

Returns Null for a blip at a point, or once that body is gone.

setPlayer(player: Player | null): boolean

Shows the blip to one player only, as a FiveM blip a client script made for its own player: a delivery's drop point, a bounty on someone's own map.

player
The one player who sees it; null for everyone.

Returns False once it is gone.

getPlayer(): Player | null

The one player who sees the blip.

Returns Null while everyone does.

setLabel(label: string): boolean

Changes what the Pip-Boy map's tooltip says.

label
Up to 63 bytes of UTF-8.

Returns False once it is gone.

static create(options: { position?: Vector3; entity?: Player | Npc; label?: string; kind?: "quest" | "custom" | "powerArmor"; compass?: boolean; map?: boolean; space?: { worldSpace: number } | { interiorCell: number }; player?: Player }): Blip | null

Puts a blip on every player's compass and map, as FiveM's AddBlipForCoord and AddBlipForEntity do.

options
`position` or `entity`, where it is or whom it follows. `label`: the map's tooltip. `kind`: the icon, "quest" by default. `compass` and `map`: where it shows, both by default. `space`: a point's worldspace or interior, the Commonwealth when left out. `player`: the one player who sees it, everyone when left out.

Returns The blip; null when it could not be made. Throws for options that name neither a position nor a body.

static all(): Blip[]

Every blip.

Returns One handle per blip.

TextLabel

classextends Entity

Text floating in the world on every player's screen, as FiveM resources draw 3D text: over a shop's door, a ped's head, a player. A player sees it while they are in its worldspace or interior and within its range. A label outlives the resource that made it until destroyed. Move it with `setPosition` or `attachTo`, not by setting `position`.

Constructor
new TextLabel(id: number)

Wraps the label with this ID; it creates nothing.

id
Network entity identifier.
Properties
text: stringread-only

What it says; empty once it is gone.

Methods
destroy(): boolean

Takes the label off every player's screen.

Returns False once it is gone.

toString(): string

Formats this handle for logging.

Returns The label's network ID and text.

setText(text: string): boolean

Changes what the label says.

text
Up to 127 bytes of UTF-8; a line break starts a new line.

Returns False once it is gone.

setColor(color: number): boolean

Changes the text's color.

color
0xRRGGBBAA: 0xFFFFFFFF is opaque white.

Returns False once it is gone.

setPosition(position: Vector3, space?: { worldSpace: number } | { interiorCell: number }): boolean

Moves the label to a point; it stops floating over anyone.

position
Where, in world units.
space
Where that is; its current space when left out.

Returns False once it is gone.

attachTo(target: Player | Npc | null): boolean

Has the label float over a player or an NPC: each player's game draws it over that body while it has it loaded, and over where the server last saw it otherwise.

target
Whose body to float over; null to stay where it is.

Returns False once it is gone.

static create(options: { text: string; position?: Vector3; entity?: Player | Npc; height?: number; color?: number; range?: number; space?: { worldSpace: number } | { interiorCell: number }; player?: Player }): TextLabel | null

Puts floating text in the world for every player, as FiveM's DrawText3D is drawn: "[E] Shop" over a counter, a name over a head.

options
`text`: what it says. `position` or `entity`: where it is or whom it floats over. `height`: how far above, 140 over a body and 0 at a point by default. `color`: 0xRRGGBBAA, white by default. `range`: how far from a player it is drawn, 1000 by default, at most 20000. `space`: a point's worldspace or interior, the Commonwealth when left out. `player`: the one player who sees it, everyone when left out.

Returns The label; null when it could not be made. Throws for options without text, or naming neither a position nor a body.

static all(): TextLabel[]

Every label.

Returns One handle per label.

Checkpoint

classextends Entity

A ring on the ground on every player's screen, as FiveM resources draw a marker with CreateCheckpoint or DrawMarker: a translucent upright cylinder at a job's pickup, a shop's door, a race's next gate. A player sees it while they are in its worldspace or interior and within its range. It shows the place; `Zone.create` with the same center and radius tells scripts who steps in. Move it with `setPosition`, not by setting `position`.

Constructor
new Checkpoint(id: number)

Wraps the checkpoint with this ID; it creates nothing.

id
Network entity identifier.
Properties
radius: numberread-only

Its radius in game units; 0 once it is gone.

Methods
destroy(): boolean

Takes the checkpoint off every player's screen.

Returns False once it is gone.

toString(): string

Formats this handle for logging.

Returns The checkpoint's network ID and radius.

setColor(color: number): boolean

Changes its color.

color
0xRRGGBBAA; the alpha is the wall's, the rim is drawn more solid.

Returns False once it is gone.

setRadius(radius: number): boolean

Widens or narrows it.

radius
Game units, above 0 and at most 5000.

Returns False once it is gone.

setPosition(position: Vector3, space?: { worldSpace: number } | { interiorCell: number }): boolean

Moves it.

position
The middle of its base, on the ground.
space
Where that is; its current space when left out.

Returns False once it is gone.

static create(options: { position: Vector3; radius?: number; height?: number; color?: number; range?: number; space?: { worldSpace: number } | { interiorCell: number }; player?: Player }): Checkpoint | null

Puts a ring on the ground for every player, or one player.

options
`position`: the middle of its base, on the ground. `radius`: 100 by default, at most 5000. `height`: how high its wall rises, 50 by default, 0 for a flat ring. `color`: 0xRRGGBBAA, a translucent amber by default. `range`: how far from a player it is drawn, 3000 by default, at most 20000. `space`: its worldspace or interior, the Commonwealth when left out. `player`: the one player who sees it, everyone when left out.

Returns The checkpoint; null when it could not be made. Throws for options without a position, or a radius out of range.

static all(): Checkpoint[]

Every checkpoint.

Returns One handle per checkpoint.

Npc

classextends Entity

A non-player actor the server took over from the data files: the generic placed ones, not the unique, essential or quest actors, which stay each client's own. A client near it runs it with the game's own AI and reports its health; nobody near, the server walks it. It lives for the whole session and comes back on its own a while after it dies. A script also makes its own with `Npc.spawn`: those stay dead until `respawn` and leave with `remove`. Move it with `teleport`, not by setting `position`.

Constructor
new Npc(id: number)

Wraps an existing NPC with this ID; it spawns nothing.

id
Network entity identifier.
Properties
ref: numberread-only

The form ID of the placed reference (ACHR) it stands for; 0 for one a script spawned.

form: numberread-only

The TESNPC every client builds it from; the server rolled any leveled list.

editorId: stringread-only

The editor ID of its TESNPC record, such as "EncRaider01"; empty when the record has none. The game's display names are localized in each player's own files, so the server has none to give.

level: numberread-only

The level its TESNPC record gives it. A record that scales with the player's level has none of its own: the lowest level it can have is given.

health: numberread-only

Current health, as its simulator last measured it. 0 until a client has run it: the server cannot work it out from the records.

maxHealth: numberread-only

Health at full; 0 until a client has run it.

isDead: booleanread-only

Whether it is dead.

isRestrained: booleanread-only

Whether `setRestrained` froze it in place.

isSneaking: booleanread-only

Whether the game that runs it has it in the sneak stance, as its last report says.

isActivationBlocked: booleanread-only

Whether `setActivationBlocked` stopped the game's own activation of it.

name: stringread-only

The name `setName` gave it; empty while it shows its record's own.

isEssential: booleanread-only

Whether `setEssential` made it essential. One only its records make essential reads false.

isInvulnerable: booleanread-only

Whether `setInvulnerable` made it unhurtable.

heading: numberread-only

Facing, in radians around Z.

Methods
kill(): boolean

Kills it through the path a hit takes; `npcDeath` follows with a null killer. One no client has run yet dies when the next one takes it on.

Returns True when sent; false when it is already dead.

remove(): boolean

Takes an NPC a script spawned out of the session; every player's game drops it at the next update. The handle resolves to nothing after.

Returns True when it goes; false for one that stands for a placed reference, which lives for the whole session.

respawn(): boolean

Puts it back at its placement, whole, dead or alive; `npcRespawn` follows.

Returns True when done.

toString(): string

Formats this handle for logging.

Returns The NPC's network ID, reference and form.

getSpace(): PlayerSpace | null

Where the NPC is.

Returns The worldspace or interior cell.

getSimulator(): Player | null

The player whose game runs the NPC.

Returns Null while nobody near does and the server walks it.

getCombatTarget(): Player | Npc | null

Who the NPC fights, as the game that runs it reports: its own choice, or the target `attack` gave it. The `npcTarget` event tells each change.

Returns Null while it fights nobody, or is dead.

getLeader(): Player | null

The player the NPC follows as a companion.

Returns Null when it follows nobody.

setLeader(player: Player | null): boolean

Makes the NPC a player's companion, as the game's own Followers quest makes one: the leader's game runs it with the follow packages, command mode and trading of a vanilla companion, and every other player sees it follow. It is taken along when its leader goes to another space or far off, and let go when the leader leaves; `npcLeaderChange` follows.

player
Who it follows; null lets it go.

Returns True when done; false for a dead NPC or a player who is gone. Throws for anything but a Player or null.

damage(amount: number): boolean

Hits the NPC from nobody, as a shot would; `npcHit` is not raised.

amount
Health to take, above 0.

Returns True when sent; false when it is dead.

heal(amount: number): boolean

Gives the NPC health back, as FiveM's SetEntityHealth raises a ped's and Actor.RestoreValue does: the game that runs it restores it, and `health` follows with its next report. One nobody runs is healed on the server.

amount
Health to give back, above 0; the NPC stops at its maximum.

Returns True when sent; false when it is dead or gone.

goTo(target: Vector3 | Player | Npc): boolean

Sends the NPC somewhere, as FiveM's TaskGoToCoord does a ped: the game that runs it has it travel there as a commanded companion does, along the navmesh, and the server walks it there while nobody near runs it. `npcArrive` follows once it is there; it then stands there until `stopGoing` or the next `goTo`. Its fights still come first.

target
A point of the NPC's space, or a player or NPC to walk up to.

Returns True when sent; false when it is dead or the target is itself.

use(ref: number | string): boolean

Has the NPC use a piece of furniture, as FiveM's TaskStartScenarioAtPosition puts a ped to a scenario and a companion obeys the player's command: the game that runs it walks it there and activates it, sitting down or getting to work, and sends it back if it gets up on its own. It replaces a `goTo` order, and `goTo` replaces it. `stopUsing` lets it go.

ref
A placed piece of furniture, by its reference's form ID: a chair, a bench, a workstation.

Returns True when sent; false when it is dead or gone.

setMaxHealth(value: number): boolean

Sets the NPC's health at full, as FiveM's SetEntityMaxHealth does an entity: the game that runs it carries it as the NPC's permanent Health, and every player's copy takes it from there. The damage it took is kept, so an unhurt NPC stays at full. It lasts while the NPC does, through respawns.

value
Health at full, at least 1.

Returns True when sent; false when it is dead or gone.

setScale(scale: number): boolean

Scales the NPC on every player's copy, as ObjectReference.SetScale does: its body, its collision and its reach grow or shrink together. It lasts while the NPC does, through respawns.

scale
1 for its record's size, from 0.01 to 10: 1.5 a hulking boss, 0.5 a runt.

Returns True when sent; false when it is gone.

setValue(value: string | number, base: number): boolean

Sets one of the NPC's actor values on every player's copy, as FiveM's ped natives tune a ped: SpeedMult (100 is its own speed) for SetPedMoveRateOverride, Aggression, Confidence and Assistance for SetPedCombatAttributes. Each copy holds the base, its own coming back with `resetValue`. A value the game derives from something else keeps its own: DamageResist comes from the armor worn, so dress the NPC (`setOutfit`) instead. An `attack` or `flee` order holds Aggression or Confidence while it runs. Up to 16 values per NPC; it lasts while the NPC does.

value
An actor value by editor ID, such as `"SpeedMult"`, `"Aggression"` or `"Confidence"`, or by form ID. Not Health: `setMaxHealth` sets that.
base
The base every copy holds.

Returns True when sent; false when the NPC is gone or 16 values are already set. Throws for a name or form no actor value has, and for Health.

getValue(value: string | number): number | null

The base `setValue` gave one of the NPC's actor values.

value
An actor value by editor ID, such as `"SpeedMult"`, `"Aggression"` or `"Confidence"`, or by form ID. Not Health: `setMaxHealth` sets that.

Returns Null when the script set none; the record's own is in each player's game alone.

resetValue(value: string | number): boolean

Gives every copy its own base for one actor value back.

value
An actor value by editor ID, such as `"SpeedMult"`, `"Aggression"` or `"Confidence"`, or by form ID. Not Health: `setMaxHealth` sets that.

Returns True when sent; false when the NPC is gone or the value was not set.

setWeaponDrawn(drawn: boolean | null): boolean

Holds the NPC's weapon out or away, as FiveM's SetCurrentPedWeapon draws a ped's: the game that runs it draws or holsters it (Actor.DrawWeapon) and keeps it so when its AI would change it, and every player's copy follows. A guard on watch, a trader with nothing in hand. It does not start or end a fight.

drawn
True to hold its weapon out, false to keep it away, null to leave it to its AI.

Returns True when sent; false when it is dead or gone.

setCollision(enabled: boolean): boolean

Takes the NPC's collision away or gives it back on every player's copy, as FiveM's SetEntityCollision does a ped and the console's tcl a selected actor: without it the NPC moves along where it looks, through walls and floors, without gravity. A ghost through a wall, a body walked out of a locked room. It lasts while the NPC does.

enabled
False to take its collision away, true to give it back.

Returns True when sent; false when it is dead or gone.

setSneaking(sneaking: boolean): boolean

Has the NPC sneak, as FiveM's SetPedStealthMovement does a ped: the game that runs it holds it in the sneak stance (the console's SetForceSneak) wherever its AI takes it, and every player's copy crouches with it. `isSneaking` reports the stance its game runs.

sneaking
True to crouch into sneak, false to stand up.

Returns True when sent; false when it is dead or gone.

knockDown(force?: number, from?: Vector3): boolean

Knocks the NPC off its feet into its ragdoll, as FiveM's SetPedToRagdoll does a ped: the game that runs it pushes its body, it lies a moment and gets up by itself, and every player's copy falls and gets up with it. One that is down already, seated or held in place is left as it is.

force
How hard it is thrown, as ObjectReference.PushActorAway takes it: small numbers, 1 to 50 (600 threw an NPC 8,700 units); 0, the default, drops it where it stands.
from
The point it is thrown away from; where it stands by default.

Returns True when sent; false when it is dead, gone, or no player's game runs it.

setAlpha(alpha: number): boolean

Draws the NPC more or less see-through on every player's copy, as FiveM's SetEntityAlpha does a ped and Actor.SetAlpha an actor: a ghost, a stalker, an NPC kept out of sight. Its collision and its AI are left as they are. It lasts while the NPC does.

alpha
0, invisible, to 1, solid.

Returns True when sent; false when it is gone.

flee(from: Player | Npc): boolean

Has the NPC run from a player or an NPC, as FiveM's TaskSmartFleePed does a ped: the game that runs it puts it in combat with that body with its Confidence at Cowardly, so it runs and hides as a frightened settler does, and every player sees it. Its own Confidence comes back when it stops. It replaces an `attack` order, and `attack` replaces it. `stopFleeing` ends it.

from
The body it runs from.

Returns True when sent; false when it is dead or gone, or the body is not alive in its space.

stopFleeing(): boolean

Ends a `flee` order: the NPC's fight ends and its own Confidence comes back.

Returns True when sent; false when it is dead, gone or not fleeing.

wander(center?: Vector3): boolean

Has the NPC live around a point, as FiveM's TaskWanderInArea does a ped: the game that runs it idles, sits, leans and walks about within 512 units of the center, as Fallout 4's settlers sandbox, and every player sees it do so. It replaces a `goTo` or `use` order, and either replaces it. `stopWandering` gives it back its own packages.

center
The middle of the area, in the NPC's space; where it stands when left out.

Returns True when sent; false when it is dead or gone.

stopWandering(): boolean

Ends a `wander` order: the NPC goes back to its own packages.

Returns True when sent; false when it is dead, gone or not wandering.

setRestrained(restrained: boolean): boolean

Freezes the NPC in place on every player's copy, as FiveM's FreezeEntityPosition does a ped and Actor.SetRestrained an actor: it stands where it is and neither walks, fights nor talks, its head still free to turn (`lookAt`). A shopkeeper behind his counter, a prisoner. It lasts through respawns.

restrained
True to freeze it where it stands, false to let it go.

Returns True when sent; false when the NPC is gone.

lookAt(target: Player | Npc | null): boolean

Turns the NPC's head and eyes toward a player or another NPC and keeps them there, on every player's copy, as FiveM's TaskLookAtEntity does a ped and Actor.SetLookAt an actor: a shopkeeper watching his customer, a guard eyeing a stranger. It does not turn its body or stop what it does.

target
Whose body to watch; null to look where it pleases again.

Returns True when sent; false when the NPC is gone, the target is itself, or it looked at nobody and null was given.

stopUsing(): boolean

Drops the order `use` gave: the NPC gets up and goes back to its own business.

Returns True when it had one.

stopGoing(): boolean

Drops the order `goTo` gave: the NPC goes back to its own business.

Returns True when it had one.

attack(target: Player | Npc): boolean

Sets the NPC on someone, as FiveM's TaskCombatPed does a ped: the game that runs it starts combat with the target, as Actor.StartCombat does, and keeps its aim on it whatever its own target choice would be. It fights with what it carries, and the hits go through `npcAttack` as any other. The order ends when the target dies or leaves, or with `stopAttacking`.

target
Who to fight: a living player or NPC of its space.

Returns True when sent; false when it is dead, or the target is itself or no living player or NPC of its space.

getFactions(): { faction: number; rank: number }[]

The memberships scripts changed on the NPC, each with its rank, or -1 for a faction it was taken out of. The factions its record gives it and no script touched are not listed.

Returns One entry per faction, in the order they were first changed; empty when the NPC is gone.

setFactionRank(faction: number | string, rank?: number): boolean

Puts the NPC in a faction at a rank, or re-ranks it, as `Actor.SetFactionRank` does and FiveM's relationship groups do for a ped: every player's copy holds the membership, so the game's own hostility follows. A raider taken out of RaiderFaction and put in PlayerFaction (0x1C21C) treats players as its own. Up to 16 factions per NPC.

faction
A TESFaction form ID, as a number or hex string.
rank
0 to 127; 0 when left out.

Returns True when set; false when the NPC is gone or 16 of its factions are already changed.

removeFromFaction(faction: number | string): boolean

Takes the NPC out of a faction on every player's copy, as `Actor.RemoveFromFaction` does, whether its record or a script put it there.

faction
A TESFaction form ID, as a number or hex string.

Returns True when sent; false when the NPC is gone or 16 of its factions are already changed.

setName(name: string | null): boolean

Names the NPC on every player's copy, as a named ped in a FiveM resource: the crosshair, its health bar and its dialogue show the name in place of its record's ("Settler", "Raider"), as a reference's ExtraTextDisplayData does.

name
What it is called, up to 47 bytes of UTF-8; null or an empty string gives it back its record's own name.

Returns True when sent; false when the NPC is gone.

setActivationBlocked(blocked: boolean): boolean

Stops what the game does when a player activates the NPC (its greeting, its dialogue, a trade), as ObjectReference.BlockActivation does, on every player's copy: `npcActivate` is still raised, so a script answers with its own interaction, as FiveM resources do for a ped.

blocked
True to stop the game's own activation, false to give it back.

Returns True when sent; false when the NPC is gone.

setRespawnDelay(seconds?: number | null): boolean

Sets how long this NPC stays dead before it is back at its placement, whole, as the game's cell respawn does for an area and FiveM scripts do for their peds: a boss that returns in an hour, a guard back in ten seconds, a raider camp that stays cleared. `npcRespawn` follows each return. It is the NPC's own timer: one spawned by a script comes back only with one.

seconds
How long it lies dead before it is back, 0 to a year; null for never; left out, the server-wide delay again.

Returns True when set; false when the NPC is gone.

dismember(part: string, explode?: boolean): boolean

Takes a body part off the NPC, as Papyrus `Actor.Dismember` does: every player's game shows the stump and the severed piece, and the game's own limb losses replicate the same way. The game only dismembers the dead: on a living NPC it waits for the death.

part
The body part, as hits name them: "Head1", "LeftArm1", "RightArm1", "LeftLeg1", "RightLeg1" and the rest of the first 16 types; which ones come off is the creature's.
explode
Blown off in gore rather than cut off; false when left out.

Returns True when sent; false when the NPC is gone.

setEssential(essential: boolean): boolean

Makes the NPC essential, as Papyrus `Actor.SetEssential` and FiveM's protected quest peds do: it can be hurt, but what would kill it drops it to its knees, bleeding out, and it gets up on its own a while later. Every player's game holds it so, and one nobody runs keeps its last point of health. `npcHit` still hears each hit; `npcDeath` never comes. A quest-giver or a vendor scripts lean on stays alive this way while still reacting to a fight; `setInvulnerable` makes hits pass over it instead.

essential
True to make it essential, false to make it mortal, even one its records make essential.

Returns True when set; false when the NPC is gone.

setInvulnerable(invulnerable: boolean): boolean

Makes the NPC unhurtable by players and NPCs, as FiveM's SetEntityInvincible does a ped: every player's copy is a ghost (Actor.SetGhost), which shots, blows and explosions pass over, and the server drops any hit still reported on it. The script's own `damage` and `kill` still go through.

invulnerable
True to make it unhurtable, false to make it hurtable again.

Returns True when sent; false when the NPC is gone.

playIdle(idle: number | string): boolean

Plays an idle animation on the NPC, as FiveM's TaskPlayAnim does a ped and `Player.playIdle` a player: every player's copy plays it. The idle's own conditions apply, so one meant for another skeleton, a piece of furniture or a state the NPC is not in does nothing, and the NPC's own AI may cut it short. `stopIdle` ends it.

idle
An idle animation (IDLE) by editor ID, such as `"IdleWave"`, or form ID.

Returns True when sent; false when the NPC is dead or gone. Throws for a form no IDLE record has.

say(line: number | string): boolean

Has the NPC speak, voice and subtitle, as FiveM's PlayPedAmbientSpeechNative does a ped and Papyrus ObjectReference.Say an actor: every player near it hears the same line. A topic's line is picked by the game running the NPC among those whose conditions pass for it (its voice type, its faction), and the others say that one; a topic with no line for this NPC says nothing. Most generic topics have no editor ID: give their form ID.

line
A dialogue topic (DIAL) by form ID or editor ID, such as `0x47895`, a raider's idle chatter, or one line of a topic (INFO) by form ID.

Returns True when sent; false when the NPC is dead or gone. Throws for a form no DIAL or INFO record has.

stopIdle(): boolean

Ends the idle animation the NPC plays, on every player's copy.

Returns True when sent; false when the NPC is dead or gone.

setOutfit(armors: (number | string)[] | null): boolean

Dresses the NPC, as FiveM's SetPedComponentVariation does a ped: every player's copy wears the pieces, locked, each over what the NPC's record gives it in the same body slots. It lasts while the NPC does, through respawns.

armors
Up to 12 armor pieces or clothes (ARMO) by form ID or editor ID, such as `"Armor_Raider_Underarmor"`; null or an empty list gives it back its own clothes.

Returns True when sent; false when the NPC is gone. Throws for a piece no ARMO record has.

giveWeapon(weapon: number | string | null): boolean

Arms the NPC, as FiveM's GiveWeaponToPed does a ped: every player's copy carries the weapon with ammunition and wears it locked, so the game that runs it fights with it and everyone sees it. It lasts while the NPC does, through respawns.

weapon
A weapon (WEAP) by form ID or editor ID, such as `"Minigun"`; null hands the NPC back its own.

Returns True when sent; false when the NPC is gone. Throws for a form no WEAP record has.

stopAttacking(): boolean

Drops the order `attack` gave: the NPC stops fighting, as Actor.StopCombat does.

Returns True when it had one.

teleport(position: Vector3, heading?: number): boolean

Moves the NPC within its space. Left alone, it wanders back toward its placement over time.

position
Where to, in the NPC's own space.
heading
Facing in radians; the current one when left out.

Returns True when done. Throws for a position that is not a finite Vector3.

static getInRange(center: Vector3 | Player, radius: number, options?: { space?: { worldSpace: number } | { interiorCell: number }; limit?: number; includeDead?: boolean }): Npc[]

The NPCs around a point or a player, nearest first, as FiveM scripts walk the ped pool or ask GetClosestPed: where a script finds the shopkeeper by a door or the raiders near a camp. Positions are the ones the simulators last reported.

center
A point, or a player, whose position and space are then the search's.
radius
How far from it, in game units.
options
`space`: where a point is, the Commonwealth when left out. `limit`: how many at most, 32 by default, never more than 512. `includeDead`: count the dead too.

Returns Empty when none is in range, or the player is gone. Throws for a center that is neither, or a negative radius.

static spawn(base: number | string, position: Vector3, options?: { heading?: number; space?: { worldSpace: number } | { interiorCell: number } }): Npc | null

Makes a new NPC, as a FiveM script creates a ped: every player's game builds it, a client near it runs it with the game's own AI and the server walks it while nobody is near, as it does the placed ones. Unique, essential and quest actors are each player's own: spawn generic ones. It stays dead when killed (`npcDeath` is raised) until `respawn` puts it back where it was spawned.

base
What to make: an NPC record (NPC_) or a leveled list of them (LVLN, rolled here), by form ID or editor ID, such as `"LCharRaider"` or `"EncRaider01"`.
position
Where it stands, in game units.
options
`heading` in radians around Z (0 faces +Y); `space` the worldspace or interior cell, the Commonwealth when left out.

Returns The new NPC; null when a leveled list rolled to nothing. Throws for a base that is no NPC_ or LVLN record.

static setDefaultRespawnDelay(seconds: number | null)

Sets how long every placed NPC without a delay of its own (`setRespawnDelay`) stays dead before it is back at its placement, whole: the server's answer to the game's cell respawn time. Null leaves the dead where they fell until a script calls `respawn`, so cleared areas stay cleared.

seconds
How long a dead NPC lies before it is back, 0 to a year; null for never. Two minutes until set.
static all(): Npc[]

Every NPC the server took over.

Returns One handle per NPC; empty when the server could not read the game's data files.

static getById(id: number): Npc | null

Looks an NPC up by network ID.

id
Network entity identifier.

Returns The handle, or null when no NPC has that ID.

static getByRef(ref: number | string): Npc | null

Looks an NPC up by the placed reference it stands for.

ref
The placed reference's form ID.

Returns The handle, or null when the server did not take that reference over.

WorkshopItem

classextends Entity

An object built in a settlement, by a player or a script, linked to a workbench the data files place. It lasts the whole session, whoever built it, until a player scraps or stores it or a script destroys it. Setting `position` or `angle` moves it for everyone.

Constructor
new WorkshopItem(id: number)

Wraps an existing built object with this ID; it builds nothing. See `WorkshopItem.place`.

id
Network entity identifier.
Properties
form: numberread-only

The base object's form ID; 0 once it is gone.

workbench: numberread-only

The workbench reference it belongs to; 0 once it is gone.

angle: Vector3

Its rotation, radians, as the game stores it. Assigning turns it for everyone.

Methods
destroy(): boolean

Takes the object out of the settlement for everyone; nobody gets its components back.

Returns True when it was there to take.

toString(): string

Formats this handle for logging.

Returns The object's network ID, form and workbench.

getSpace(): PlayerSpace | null

Where the object stands.

Returns The worldspace or interior cell, or null once it is gone.

static place(form: number | string, workbench: number | string, position: Vector3, space: { worldSpace?: number | string; interiorCell?: number | string }, angle?: Vector3, wire?: { from: WorkshopItem | number | string; to: WorkshopItem | number | string; fromPoint?: number; toPoint?: number }): WorkshopItem | null

Builds an object for everyone, as if a player had at that workbench. Nothing is checked: not the recipe, its cost nor the buildable area. A wire is laid out between its two ends on every client once both are loaded, and linked into their power grid.

form
The base object to build.
workbench
The workbench reference it belongs to, placed by the data files.
position
Where it stands.
space
The worldspace, or the interior cell: exactly one of the two.
angle
Its rotation, radians.
wire
For a wire (the game's workshop spline), the two objects it joins: a built object, or a placed reference's form ID, each with the connect point the wire takes on it (0 by default).

Returns The object, or null when it could not be created.

static all(workbench?: number | string): WorkshopItem[]

Every object built this session.

workbench
Only the objects of this workbench.

Returns One handle per object.

Timeout

type

Node.js timer handle returned by setTimeout and setInterval.

Methods
ref(): Timeout

Keeps the event loop alive while this timer is pending.

Returns This timer.

unref(): Timeout

Lets the event loop exit while this timer is still pending.

Returns This timer.

hasRef(): boolean

Whether this timer keeps the event loop alive.

refresh(): Timeout

Restarts this timer's countdown from now, with its original delay.

Returns This timer.

Timers

Free functions, the same shape as the browser and Node ones.

Timers

global
Methods
setTimeout(handler: (...args: any[]) => void, milliseconds?: number, ...args: unknown[]): Timeout

Calls a function once after a delay.

handler
Function to call.
milliseconds
Delay before the call.
args
Arguments passed to the handler.

Returns Handle to pass to the matching clear function.

setInterval(handler: (...args: any[]) => void, milliseconds?: number, ...args: unknown[]): Timeout

Calls a function repeatedly, waiting the delay between calls.

handler
Function to call.
milliseconds
Delay before the call.
args
Arguments passed to the handler.

Returns Handle to pass to the matching clear function.

clearTimeout(handle?: Timeout)

Cancels a pending setTimeout.

handle
Handle returned when the timer was scheduled; anything else is ignored.
clearInterval(handle?: Timeout)

Cancels a setInterval.

handle
Handle returned when the timer was scheduled; anything else is ignored.
queueMicrotask(callback: () => void)

Queues a function on the microtask queue.

callback
Function to run once the current task completes.
The illuminated entrance to Vault 111

Your next chapter starts here

The vault door
is open

Find the latest builds, meet your future neighbours, and help shape what comes next. We’re building this Commonwealth together.

Join the Discord Bring your Pip-Boy, we’ll bring the company