Table of Contents

Class Npc

Namespace
Exiled.API.Features
Assembly
Exiled.API.dll

Wrapper class for handling NPC players.

public class Npc : Player, IEntity, IWorldSpace, IPosition, IRotation
Inheritance
Npc
Implements
Inherited Members
Extension Methods

Constructors

Npc(ReferenceHub)

Represents the in-game player, by encapsulating a ReferenceHub.

public Npc(ReferenceHub referenceHub)

Parameters

referenceHub ReferenceHub

Npc(GameObject)

Represents the in-game player, by encapsulating a ReferenceHub.

public Npc(GameObject gameObject)

Parameters

gameObject GameObject

Properties

FollowedPlayer

Gets or sets the player being followed.

public Player? FollowedPlayer { get; set; }

Property Value

Player

Remarks

The npc must have CommandSystem.Commands.RemoteAdmin.Dummies.PlayerFollower.

List

Gets a list of Npcs.

public static IReadOnlyCollection<Npc> List { get; }

Property Value

IReadOnlyCollection<Npc>

MaxDistance

Gets or sets the Max Distance of the npc.

public float? MaxDistance { get; set; }

Property Value

float?

Remarks

The npc must have CommandSystem.Commands.RemoteAdmin.Dummies.PlayerFollower.

MinDistance

Gets or sets the Min Distance of the npc.

public float? MinDistance { get; set; }

Property Value

float?

Remarks

The npc must have CommandSystem.Commands.RemoteAdmin.Dummies.PlayerFollower.

Position

Gets or sets the player's position.

public override Vector3 Position { get; set; }

Property Value

Vector3

Speed

Gets or sets the Speed of the npc.

public float? Speed { get; set; }

Property Value

float?

Remarks

The npc must have CommandSystem.Commands.RemoteAdmin.Dummies.PlayerFollower.

Methods

Destroy()

Destroys the NPC.

public void Destroy()

DestroyAll()

Destroys all NPCs currently spawned.

public static void DestroyAll()

Follow(Player)

Follow a specific player.

public void Follow(Player player)

Parameters

player Player

the Player to follow.

Follow(Player, float, float, float)

Follow a specific player.

public void Follow(Player player, float maxDistance, float minDistance, float speed = 30)

Parameters

player Player

the Player to follow.

maxDistance float

the max distance the npc will go.

minDistance float

the min distance the npc will go.

speed float

the speed the npc will go.

Get(CommandSender)

Retrieves the NPC associated with the specified CommandSender.

public static Npc? Get(CommandSender sender)

Parameters

sender CommandSender

The CommandSender to retrieve the NPC for.

Returns

Npc

The NPC associated with the CommandSender, or null if not found.

Get(ICommandSender)

Retrieves the NPC associated with the specified ICommandSender.

public static Npc? Get(ICommandSender sender)

Parameters

sender ICommandSender

The ICommandSender to retrieve the NPC for.

Returns

Npc

The NPC associated with the ICommandSender, or null if not found.

Get(Footprint)

Retrieves the NPC associated with the specified Footprint.

public static Npc? Get(Footprint footprint)

Parameters

footprint Footprint

The Footprint to retrieve the NPC for.

Returns

Npc

The NPC associated with the Footprint, or null if not found.

Get(NetworkConnection)

Retrieves the NPC associated with the specified NetworkConnection.

public static Npc? Get(NetworkConnection conn)

Parameters

conn NetworkConnection

The NetworkConnection to retrieve the NPC for.

Returns

Npc

The NPC associated with the NetworkConnection, or null if not found.

Get(ReferenceHub)

Retrieves the NPC associated with the specified ReferenceHub.

public static Npc? Get(ReferenceHub rHub)

Parameters

rHub ReferenceHub

The ReferenceHub to retrieve the NPC for.

Returns

Npc

The NPC associated with the ReferenceHub, or null if not found.

Get(int)

Retrieves the NPC associated with the specified ID.

public static Npc? Get(int id)

Parameters

id int

The ID to retrieve the NPC for.

Returns

Npc

The NPC associated with the ID, or null if not found.

Get(string)

Retrieves the NPC associated with the specified user ID.

public static Npc? Get(string userId)

Parameters

userId string

The user ID to retrieve the NPC for.

Returns

Npc

The NPC associated with the user ID, or null if not found.

Get(uint)

Retrieves the NPC associated with the specified net ID.

public static Npc? Get(uint netId)

Parameters

netId uint

The net ID to retrieve the NPC for.

Returns

Npc

The NPC associated with the net ID, or null if not found.

Get(Collider)

Retrieves the NPC associated with the specified Collider.

public static Npc? Get(Collider collider)

Parameters

collider Collider

The Collider to retrieve the NPC for.

Returns

Npc

The NPC associated with the Collider, or null if not found.

Get(GameObject)

Retrieves the NPC associated with the specified GameObject.

public static Npc? Get(GameObject gameObject)

Parameters

gameObject GameObject

The GameObject to retrieve the NPC for.

Returns

Npc

The NPC associated with the GameObject, or null if not found.

LateDestroy(float)

Schedules the destruction of the NPC after a delay.

public void LateDestroy(float time)

Parameters

time float

The delay in seconds before the NPC is destroyed.

Spawn(string, RoleTypeId, bool, Vector3?)

Spawns an NPC based on the given parameters.

public static Npc Spawn(string name, RoleTypeId role = RoleTypeId.None, bool ignored = false, Vector3? position = null)

Parameters

name string

The name of the NPC.

role RoleTypeId

The RoleTypeId of the NPC, defaulting to None.

ignored bool

Whether the NPC should be ignored by round ending checks.

position Vector3?

The position where the NPC should spawn. If null, the default spawn location is used.

Returns

Npc

The Npc spawned.

Spawn(string, RoleTypeId, Vector3)

Spawns an NPC based on the given parameters.

public static Npc Spawn(string name, RoleTypeId role, Vector3 position)

Parameters

name string

The name of the NPC.

role RoleTypeId

The RoleTypeId of the NPC.

position Vector3

The position where the NPC should spawn.

Returns

Npc

Docs4.