Table of Contents

Interface INpcService

Namespace
SampSharp.Entities.SAMP
Assembly
SampSharp.OpenMp.Entities.dll

Provides access to global NPC infrastructure: path containers, movement recordings, and node navigation.

public interface INpcService

Methods

AddPointToPath(int, Vector3, float)

Appends a waypoint to an existing path container.

bool AddPointToPath(int pathId, Vector3 position, float stopRange)

Parameters

pathId int

The path ID.

position Vector3

The waypoint position.

stopRange float

The radius within which the NPC is considered to have reached this waypoint.

Returns

bool

true on success.

ClearPath(int)

Removes all waypoints from a path container.

bool ClearPath(int pathId)

Parameters

pathId int

The path ID.

Returns

bool

true on success.

CloseNode(int)

Closes a previously opened node file.

void CloseNode(int nodeId)

Parameters

nodeId int

The node ID.

CreatePath()

Creates a new (empty) NPC path container.

int CreatePath()

Returns

int

The newly allocated path ID.

DestroyAllPaths()

Destroys all path containers.

void DestroyAllPaths()

DestroyPath(int)

Destroys a previously created path container.

bool DestroyPath(int pathId)

Parameters

pathId int

The path ID.

Returns

bool

true on success.

GetNodeInfo(int, out uint, out uint, out uint)

Gets information about vehicle nodes, pedestrian nodes, and navigation nodes in a node file.

bool GetNodeInfo(int nodeId, out uint vehicleNodes, out uint pedNodes, out uint naviNodes)

Parameters

nodeId int

The node ID.

vehicleNodes uint

The number of vehicle nodes.

pedNodes uint

The number of pedestrian nodes.

naviNodes uint

The number of navigation nodes.

Returns

bool

true on success.

GetNodePointCount(int)

Gets the total number of points in a node.

int GetNodePointCount(int nodeId)

Parameters

nodeId int

The node ID.

Returns

int

GetNodePointPosition(int, out Vector3)

Gets the position of the current point in a node.

bool GetNodePointPosition(int nodeId, out Vector3 position)

Parameters

nodeId int

The node ID.

position Vector3

The position of the current point.

Returns

bool

true on success.

GetNodeType(int)

Gets the type of a node.

byte GetNodeType(int nodeId)

Parameters

nodeId int

The node ID.

Returns

byte

GetPathCount()

Gets the total number of active path containers.

Size GetPathCount()

Returns

Size

GetPathPoint(int, Size, out Vector3, out float)

Gets the position and stop range of a specific waypoint in a path.

bool GetPathPoint(int pathId, Size pointIndex, out Vector3 position, out float stopRange)

Parameters

pathId int

The path ID.

pointIndex Size

The zero-based index of the waypoint.

position Vector3

The position of the waypoint.

stopRange float

The stop range of the waypoint.

Returns

bool

true on success.

GetPathPointCount(int)

Gets the number of waypoints in a path container.

Size GetPathPointCount(int pathId)

Parameters

pathId int

The path ID.

Returns

Size

GetRecordCount()

Gets the total number of loaded recordings.

Size GetRecordCount()

Returns

Size

HasPathPointInRange(int, Vector3, float)

Checks whether any waypoint in the path is within the given radius of the position.

bool HasPathPointInRange(int pathId, Vector3 position, float radius)

Parameters

pathId int

The path ID.

position Vector3

The reference position.

radius float

The search radius.

Returns

bool

true if a matching waypoint exists.

IsNodeOpen(int)

Checks whether the specified node file is currently open.

bool IsNodeOpen(int nodeId)

Parameters

nodeId int

The node ID.

Returns

bool

true if open.

IsValidPath(int)

Checks whether the given path ID refers to a live path container.

bool IsValidPath(int pathId)

Parameters

pathId int

The path ID.

Returns

bool

true if valid.

IsValidRecord(int)

Checks whether the given record ID is valid.

bool IsValidRecord(int recordId)

Parameters

recordId int

The record ID.

Returns

bool

true if valid.

LoadRecord(string)

Loads a recorded movement file (.rec) for playback by NPCs.

int LoadRecord(string filePath)

Parameters

filePath string

The path to the recording file (relative to scriptfiles).

Returns

int

The record ID, or -1 on failure.

OpenNode(int)

Opens a node file for NPC path navigation.

bool OpenNode(int nodeId)

Parameters

nodeId int

The node ID.

Returns

bool

true on success.

RemovePointFromPath(int, Size)

Removes the waypoint at the specified index from a path container.

bool RemovePointFromPath(int pathId, Size pointIndex)

Parameters

pathId int

The path ID.

pointIndex Size

The zero-based index of the waypoint to remove.

Returns

bool

true on success.

SetNodePoint(int, ushort)

Sets the current point within a node.

bool SetNodePoint(int nodeId, ushort pointId)

Parameters

nodeId int

The node ID.

pointId ushort

The point ID to set.

Returns

bool

true on success.

UnloadAllRecords()

Unloads all loaded recordings.

void UnloadAllRecords()

UnloadRecord(int)

Unloads a previously loaded recording.

bool UnloadRecord(int recordId)

Parameters

recordId int

The record ID returned by LoadRecord(string).

Returns

bool

true on success.