Npc
Defined in: server/api.d.ts:2518
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.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Npc(
id):Npc
Defined in: server/api.d.ts:2523
Wraps an existing NPC with this ID; it spawns nothing.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”Npc
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”attack()
Section titled “attack()”attack(
target):boolean
Defined in: server/api.d.ts:2829
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.
Parameters
Section titled “Parameters”target
Section titled “target”Player | Npc
Who to fight: a living player or NPC of its space.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead, or the target is itself or no living player or NPC of its space.
carryInMouth()
Section titled “carryInMouth()”carryInMouth(
item,to?):boolean
Defined in: server/api.d.ts:2692
Has a dog carry an item in its mouth to someone, as Dogmeat brings the player what he found: the game that runs it sets off on the command-mode trip toward them and takes the item in its mouth (Papyrus Actor.DogPlaceInMouth), and every player sees it carried. The game keeps an item in a dog’s mouth only for such a trip: once it arrives, the item is gone and npcMouthChange reports null, the moment for a script to hand it over (player.giveItem). Only actors with Dogmeat’s keyword (DogmeatKeyword_DO) take one, and never an item the game marks as one a dog cannot carry, weapons among them. Null drops what it holds, as Actor.DogDropItems does: a fetched item falls to the ground.
Parameters
Section titled “Parameters”string | number | null
A base object (a misc item, a bone, a teddy bear), by form ID; null drops what it holds.
string | number | Player | Npc
Whom it carries it to: a player, an NPC, or a placed reference by form ID. Left out, its leader (setLeader).
Returns
Section titled “Returns”boolean
True when sent; false when it is dead or gone, or it has no leader and no to.
command()
Section titled “command()”command(
command,target?):boolean
Defined in: server/api.d.ts:2684
Gives the NPC a companion command, as its leader does in the game’s command mode and FiveM’s TaskGoToEntity and friends task a ped: the game that runs it carries it out with the companion’s own command packages. retrieve sends a dog to fetch an item, attack sends it at a target, inspect has it use a door or a terminal, stay holds it in place. Meant for a companion (setLeader); npcCommand tells of the ones its leader gives.
Parameters
Section titled “Parameters”command
Section titled “command”string
"call", "follow", "move", "attack", "inspect", "retrieve", "stay", "release", "heal", "assign", "ride" or "enter".
target?
Section titled “target?”string | number | Player | Npc | Item
Who or what it is aimed at: a player, an NPC, a loose item (Item.spawn), or a placed reference by form ID (an item to fetch, a door, a workbench). Left out, the NPC itself: stay waits where it is, follow goes back to following.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead or gone.
damage()
Section titled “damage()”damage(
amount):boolean
Defined in: server/api.d.ts:2655
Hits the NPC from nobody, as a shot would; npcHit is not raised.
Parameters
Section titled “Parameters”amount
Section titled “amount”number
Health to take, above 0.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead.
dismember()
Section titled “dismember()”dismember(
part,explode?):boolean
Defined in: server/api.d.ts:2879
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.
Parameters
Section titled “Parameters”string
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?
Section titled “explode?”boolean
Blown off in gore rather than cut off; false when left out.
Returns
Section titled “Returns”boolean
True when sent; false when the NPC is gone.
flee()
Section titled “flee()”flee(
from):boolean
Defined in: server/api.d.ts:2777
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.
Parameters
Section titled “Parameters”Player | Npc
The body it runs from.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead or gone, or the body is not alive in its space.
getCombatTarget()
Section titled “getCombatTarget()”getCombatTarget():
Player|Npc|null
Defined in: server/api.d.ts:2635
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
Section titled “Returns”Player | Npc | null
Null while it fights nobody, or is dead.
getFactions()
Section titled “getFactions()”getFactions():
object[]
Defined in: server/api.d.ts:2835
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
Section titled “Returns”object[]
One entry per faction, in the order they were first changed; empty when the NPC is gone.
getLeader()
Section titled “getLeader()”getLeader():
Player|null
Defined in: server/api.d.ts:2641
The player the NPC follows as a companion.
Returns
Section titled “Returns”Player | null
Null when it follows nobody.
getMouthItem()
Section titled “getMouthItem()”getMouthItem():
number|null
Defined in: server/api.d.ts:2698
The base object a dog holds in its mouth, by form ID, as the game that runs it has it: what carryInMouth gave it, or what it fetched.
Returns
Section titled “Returns”number | null
Null when it holds nothing.
getSimulator()
Section titled “getSimulator()”getSimulator():
Player|null
Defined in: server/api.d.ts:2629
The player whose game runs the NPC.
Returns
Section titled “Returns”Player | null
Null while nobody near does and the server walks it.
getSpace()
Section titled “getSpace()”getSpace():
PlayerSpace|null
Defined in: server/api.d.ts:2623
Where the NPC is.
Returns
Section titled “Returns”PlayerSpace | null
The worldspace or interior cell.
getValue()
Section titled “getValue()”getValue(
value):number|null
Defined in: server/api.d.ts:2727
The base setValue gave one of the NPC’s actor values.
Parameters
Section titled “Parameters”string | number
An actor value by editor ID, such as "SpeedMult", "Aggression" or "Confidence", or by form ID. Not Health: setMaxHealth sets that.
Returns
Section titled “Returns”number | null
Null when the script set none; the record’s own is in each player’s game alone.
giveWeapon()
Section titled “giveWeapon()”giveWeapon(
weapon):boolean
Defined in: server/api.d.ts:2927
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.
Parameters
Section titled “Parameters”weapon
Section titled “weapon”string | number | null
A weapon (WEAP) by form ID or editor ID, such as "Minigun"; null hands the NPC back its own.
Returns
Section titled “Returns”boolean
True when sent; false when the NPC is gone. Throws for a form no WEAP record has.
goTo()
Section titled “goTo()”goTo(
target):boolean
Defined in: server/api.d.ts:2669
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.
Parameters
Section titled “Parameters”target
Section titled “target”A point of the NPC’s space, or a player or NPC to walk up to.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead or the target is itself.
heal()
Section titled “heal()”heal(
amount):boolean
Defined in: server/api.d.ts:2662
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.
Parameters
Section titled “Parameters”amount
Section titled “amount”number
Health to give back, above 0; the NPC stops at its maximum.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead or gone.
kill()
Section titled “kill()”kill():
boolean
Defined in: server/api.d.ts:2599
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
Section titled “Returns”boolean
True when sent; false when it is already dead.
knockDown()
Section titled “knockDown()”knockDown(
force?,from?):boolean
Defined in: server/api.d.ts:2763
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.
Parameters
Section titled “Parameters”force?
Section titled “force?”number
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.
The point it is thrown away from; where it stands by default.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead, gone, or no player’s game runs it.
lookAt()
Section titled “lookAt()”lookAt(
target):boolean
Defined in: server/api.d.ts:2810
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.
Parameters
Section titled “Parameters”target
Section titled “target”Player | Npc | null
Whose body to watch; null to look where it pleases again.
Returns
Section titled “Returns”boolean
True when sent; false when the NPC is gone, the target is itself, or it looked at nobody and null was given.
playIdle()
Section titled “playIdle()”playIdle(
idle):boolean
Defined in: server/api.d.ts:2900
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.
Parameters
Section titled “Parameters”string | number
An idle animation (IDLE) by editor ID, such as "IdleWave", or form ID.
Returns
Section titled “Returns”boolean
True when sent; false when the NPC is dead or gone. Throws for a form no IDLE record has.
remove()
Section titled “remove()”remove():
boolean
Defined in: server/api.d.ts:2605
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
Section titled “Returns”boolean
True when it goes; false for one that stands for a placed reference, which lives for the whole session.
removeFromFaction()
Section titled “removeFromFaction()”removeFromFaction(
faction):boolean
Defined in: server/api.d.ts:2850
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.
Parameters
Section titled “Parameters”faction
Section titled “faction”string | number
A TESFaction form ID, as a number or hex string.
Returns
Section titled “Returns”boolean
True when sent; false when the NPC is gone or 16 of its factions are already changed.
resetValue()
Section titled “resetValue()”resetValue(
value):boolean
Defined in: server/api.d.ts:2734
Gives every copy its own base for one actor value back.
Parameters
Section titled “Parameters”string | number
An actor value by editor ID, such as "SpeedMult", "Aggression" or "Confidence", or by form ID. Not Health: setMaxHealth sets that.
Returns
Section titled “Returns”boolean
True when sent; false when the NPC is gone or the value was not set.
respawn()
Section titled “respawn()”respawn():
boolean
Defined in: server/api.d.ts:2611
Puts it back at its placement, whole, dead or alive; npcRespawn follows.
Returns
Section titled “Returns”boolean
True when done.
say(
line):boolean
Defined in: server/api.d.ts:2907
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.
Parameters
Section titled “Parameters”string | number
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
Section titled “Returns”boolean
True when sent; false when the NPC is dead or gone. Throws for a form no DIAL or INFO record has.
setActivationBlocked()
Section titled “setActivationBlocked()”setActivationBlocked(
blocked):boolean
Defined in: server/api.d.ts:2864
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.
Parameters
Section titled “Parameters”blocked
Section titled “blocked”boolean
True to stop the game’s own activation, false to give it back.
Returns
Section titled “Returns”boolean
True when sent; false when the NPC is gone.
setAlpha()
Section titled “setAlpha()”setAlpha(
alpha):boolean
Defined in: server/api.d.ts:2770
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.
Parameters
Section titled “Parameters”number
0, invisible, to 1, solid.
Returns
Section titled “Returns”boolean
True when sent; false when it is gone.
setCollision()
Section titled “setCollision()”setCollision(
enabled):boolean
Defined in: server/api.d.ts:2748
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.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
False to take its collision away, true to give it back.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead or gone.
setEssential()
Section titled “setEssential()”setEssential(
essential):boolean
Defined in: server/api.d.ts:2886
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.
Parameters
Section titled “Parameters”essential
Section titled “essential”boolean
True to make it essential, false to make it mortal, even one its records make essential.
Returns
Section titled “Returns”boolean
True when set; false when the NPC is gone.
setFactionRank()
Section titled “setFactionRank()”setFactionRank(
faction,rank?):boolean
Defined in: server/api.d.ts:2843
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.
Parameters
Section titled “Parameters”faction
Section titled “faction”string | number
A TESFaction form ID, as a number or hex string.
number
0 to 127; 0 when left out.
Returns
Section titled “Returns”boolean
True when set; false when the NPC is gone or 16 of its factions are already changed.
setInvulnerable()
Section titled “setInvulnerable()”setInvulnerable(
invulnerable):boolean
Defined in: server/api.d.ts:2893
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.
Parameters
Section titled “Parameters”invulnerable
Section titled “invulnerable”boolean
True to make it unhurtable, false to make it hurtable again.
Returns
Section titled “Returns”boolean
True when sent; false when the NPC is gone.
setLeader()
Section titled “setLeader()”setLeader(
player):boolean
Defined in: server/api.d.ts:2648
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.
Parameters
Section titled “Parameters”player
Section titled “player”Player | null
Who it follows; null lets it go.
Returns
Section titled “Returns”boolean
True when done; false for a dead NPC or a player who is gone. Throws for anything but a Player or null.
setMaxHealth()
Section titled “setMaxHealth()”setMaxHealth(
value):boolean
Defined in: server/api.d.ts:2705
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.
Parameters
Section titled “Parameters”number
Health at full, at least 1.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead or gone.
setName()
Section titled “setName()”setName(
name):boolean
Defined in: server/api.d.ts:2857
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.
Parameters
Section titled “Parameters”string | null
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
Section titled “Returns”boolean
True when sent; false when the NPC is gone.
setOutfit()
Section titled “setOutfit()”setOutfit(
armors):boolean
Defined in: server/api.d.ts:2920
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.
Parameters
Section titled “Parameters”armors
Section titled “armors”(string | number)[] | null
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
Section titled “Returns”boolean
True when sent; false when the NPC is gone. Throws for a piece no ARMO record has.
setRespawnDelay()
Section titled “setRespawnDelay()”setRespawnDelay(
seconds?):boolean
Defined in: server/api.d.ts:2871
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.
Parameters
Section titled “Parameters”seconds?
Section titled “seconds?”number | null
How long it lies dead before it is back, 0 to a year; null for never; left out, the server-wide delay again.
Returns
Section titled “Returns”boolean
True when set; false when the NPC is gone.
setRestrained()
Section titled “setRestrained()”setRestrained(
restrained):boolean
Defined in: server/api.d.ts:2803
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.
Parameters
Section titled “Parameters”restrained
Section titled “restrained”boolean
True to freeze it where it stands, false to let it go.
Returns
Section titled “Returns”boolean
True when sent; false when the NPC is gone.
setScale()
Section titled “setScale()”setScale(
scale):boolean
Defined in: server/api.d.ts:2712
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.
Parameters
Section titled “Parameters”number
1 for its record’s size, from 0.01 to 10: 1.5 a hulking boss, 0.5 a runt.
Returns
Section titled “Returns”boolean
True when sent; false when it is gone.
setSneaking()
Section titled “setSneaking()”setSneaking(
sneaking):boolean
Defined in: server/api.d.ts:2755
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.
Parameters
Section titled “Parameters”sneaking
Section titled “sneaking”boolean
True to crouch into sneak, false to stand up.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead or gone.
setValue()
Section titled “setValue()”setValue(
value,base):boolean
Defined in: server/api.d.ts:2720
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.
Parameters
Section titled “Parameters”string | number
An actor value by editor ID, such as "SpeedMult", "Aggression" or "Confidence", or by form ID. Not Health: setMaxHealth sets that.
number
The base every copy holds.
Returns
Section titled “Returns”boolean
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.
setVirtualWorld()
Section titled “setVirtualWorld()”setVirtualWorld(
world):void
Defined in: server/api.d.ts:4292
Moves this entity into another virtual world.
Parameters
Section titled “Parameters”number
Virtual-world identifier used to partition replication and visibility.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setVisibleTo()
Section titled “setVisibleTo()”setVisibleTo(
player):void
Defined in: server/api.d.ts:4298
Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.
Parameters
Section titled “Parameters”player
Section titled “player”Entity | null
Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setWeaponDrawn()
Section titled “setWeaponDrawn()”setWeaponDrawn(
drawn):boolean
Defined in: server/api.d.ts:2741
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.
Parameters
Section titled “Parameters”boolean | null
True to hold its weapon out, false to keep it away, null to leave it to its AI.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead or gone.
stopAttacking()
Section titled “stopAttacking()”stopAttacking():
boolean
Defined in: server/api.d.ts:2933
Drops the order attack gave: the NPC stops fighting, as Actor.StopCombat does.
Returns
Section titled “Returns”boolean
True when it had one.
stopFleeing()
Section titled “stopFleeing()”stopFleeing():
boolean
Defined in: server/api.d.ts:2783
Ends a flee order: the NPC’s fight ends and its own Confidence comes back.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead, gone or not fleeing.
stopGoing()
Section titled “stopGoing()”stopGoing():
boolean
Defined in: server/api.d.ts:2822
Drops the order goTo gave: the NPC goes back to its own business.
Returns
Section titled “Returns”boolean
True when it had one.
stopIdle()
Section titled “stopIdle()”stopIdle():
boolean
Defined in: server/api.d.ts:2913
Ends the idle animation the NPC plays, on every player’s copy.
Returns
Section titled “Returns”boolean
True when sent; false when the NPC is dead or gone.
stopUsing()
Section titled “stopUsing()”stopUsing():
boolean
Defined in: server/api.d.ts:2816
Drops the order use gave: the NPC gets up and goes back to its own business.
Returns
Section titled “Returns”boolean
True when it had one.
stopWandering()
Section titled “stopWandering()”stopWandering():
boolean
Defined in: server/api.d.ts:2796
Ends a wander order: the NPC goes back to its own packages.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead, gone or not wandering.
teleport()
Section titled “teleport()”teleport(
position,heading?):boolean
Defined in: server/api.d.ts:2941
Moves the NPC within its space. Left alone, it wanders back toward its placement over time.
Parameters
Section titled “Parameters”position
Section titled “position”Where to, in the NPC’s own space.
heading?
Section titled “heading?”number
Facing in radians; the current one when left out.
Returns
Section titled “Returns”boolean
True when done. Throws for a position that is not a finite Vector3.
toString()
Section titled “toString()”toString():
string
Defined in: server/api.d.ts:2617
Formats this handle for logging.
Returns
Section titled “Returns”string
The NPC’s network ID, reference and form.
Inherited from
Section titled “Inherited from”use(
ref):boolean
Defined in: server/api.d.ts:2676
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.
Parameters
Section titled “Parameters”string | number
A placed piece of furniture, by its reference’s form ID: a chair, a bench, a workstation.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead or gone.
wander()
Section titled “wander()”wander(
center?):boolean
Defined in: server/api.d.ts:2790
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.
Parameters
Section titled “Parameters”center?
Section titled “center?”The middle of the area, in the NPC’s space; where it stands when left out.
Returns
Section titled “Returns”boolean
True when sent; false when it is dead or gone.
staticall():Npc[]
Defined in: server/api.d.ts:2971
Every NPC the server took over.
Returns
Section titled “Returns”Npc[]
One handle per NPC; empty when the server could not read the game’s data files.
getById()
Section titled “getById()”
staticgetById(id):Npc|null
Defined in: server/api.d.ts:2978
Looks an NPC up by network ID.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”Npc | null
The handle, or null when no NPC has that ID.
getByRef()
Section titled “getByRef()”
staticgetByRef(ref):Npc|null
Defined in: server/api.d.ts:2985
Looks an NPC up by the placed reference it stands for.
Parameters
Section titled “Parameters”string | number
The placed reference’s form ID.
Returns
Section titled “Returns”Npc | null
The handle, or null when the server did not take that reference over.
getInRange()
Section titled “getInRange()”
staticgetInRange(center,radius,options?):Npc[]
Defined in: server/api.d.ts:2950
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.
Parameters
Section titled “Parameters”center
Section titled “center”A point, or a player, whose position and space are then the search’s.
radius
Section titled “radius”number
How far from it, in game units.
options?
Section titled “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.
includeDead?
Section titled “includeDead?”boolean
limit?
Section titled “limit?”number
space?
Section titled “space?”{ worldSpace: number; } | { interiorCell: number; }
Returns
Section titled “Returns”Npc[]
Empty when none is in range, or the player is gone. Throws for a center that is neither, or a negative radius.
setDefaultRespawnDelay()
Section titled “setDefaultRespawnDelay()”
staticsetDefaultRespawnDelay(seconds):void
Defined in: server/api.d.ts:2965
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.
Parameters
Section titled “Parameters”seconds
Section titled “seconds”number | null
How long a dead NPC lies before it is back, 0 to a year; null for never. Two minutes until set.
Returns
Section titled “Returns”void
spawn()
Section titled “spawn()”
staticspawn(base,position,options?):Npc|null
Defined in: server/api.d.ts:2959
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.
Parameters
Section titled “Parameters”string | number
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
Section titled “position”Where it stands, in game units.
options?
Section titled “options?”heading in radians around Z (0 faces +Y); space the worldspace or interior cell, the Commonwealth when left out.
heading?
Section titled “heading?”number
space?
Section titled “space?”{ worldSpace: number; } | { interiorCell: number; }
Returns
Section titled “Returns”Npc | null
The new NPC; null when a leveled list rolled to nothing. Throws for a base that is no NPC_ or LVLN record.
Properties
Section titled “Properties”editorId
Section titled “editorId”
readonlyeditorId:string
Defined in: server/api.d.ts:2538
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.
readonlyform:number
Defined in: server/api.d.ts:2533
The TESNPC every client builds it from; the server rolled any leveled list.
heading
Section titled “heading”
readonlyheading:number
Defined in: server/api.d.ts:2593
Facing, in radians around Z.
health
Section titled “health”
readonlyhealth:number
Defined in: server/api.d.ts:2548
Current health, as its simulator last measured it. 0 until a client has run it: the server cannot work it out from the records.
readonlyid:number
Defined in: server/api.d.ts:4260
Immutable network entity identifier.
Inherited from
Section titled “Inherited from”isActivationBlocked
Section titled “isActivationBlocked”
readonlyisActivationBlocked:boolean
Defined in: server/api.d.ts:2573
Whether setActivationBlocked stopped the game’s own activation of it.
isDead
Section titled “isDead”
readonlyisDead:boolean
Defined in: server/api.d.ts:2558
Whether it is dead.
isEssential
Section titled “isEssential”
readonlyisEssential:boolean
Defined in: server/api.d.ts:2583
Whether setEssential made it essential. One only its records make essential reads false.
isInvulnerable
Section titled “isInvulnerable”
readonlyisInvulnerable:boolean
Defined in: server/api.d.ts:2588
Whether setInvulnerable made it unhurtable.
isRestrained
Section titled “isRestrained”
readonlyisRestrained:boolean
Defined in: server/api.d.ts:2563
Whether setRestrained froze it in place.
isSneaking
Section titled “isSneaking”
readonlyisSneaking:boolean
Defined in: server/api.d.ts:2568
Whether the game that runs it has it in the sneak stance, as its last report says.
readonlylevel:number
Defined in: server/api.d.ts:2543
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.
maxHealth
Section titled “maxHealth”
readonlymaxHealth:number
Defined in: server/api.d.ts:2553
Health at full; 0 until a client has run it.
readonlyname:string
Defined in: server/api.d.ts:2578
The name setName gave it; empty while it shows its record’s own.
position
Section titled “position”position:
Vector3
Defined in: server/api.d.ts:4270
Authoritative world-space position; assignment forces replicated state.
Inherited from
Section titled “Inherited from”
readonlyref:number
Defined in: server/api.d.ts:2528
The form ID of the placed reference (ACHR) it stands for; 0 for one a script spawned.
rotation
Section titled “rotation”rotation:
Vector3|Quaternion
Defined in: server/api.d.ts:4275
Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.
Inherited from
Section titled “Inherited from”
readonlystate:StateBag
Defined in: server/api.d.ts:4280
Arbitrary key/value state carried by this entity. The server writes it and every client that can see the entity receives it; see StateBag.
Inherited from
Section titled “Inherited from”virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: server/api.d.ts:4265
Current virtual-world identifier.