Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
02248e2
NPC Callbacks
itsneufox Aug 31, 2025
7289b30
Wrong bold format
itsneufox Aug 31, 2025
1f10b5a
Mark ConnectNPC function as deprecated
itsneufox Sep 8, 2025
49b70e9
One Big Beautiful Commit for NPCs
itsneufox Sep 8, 2025
74ffe85
- begone magic numbers (thx TommyB)
itsneufox Sep 8, 2025
a3468be
Add npc-constants.md
itsneufox Sep 8, 2025
096bdfc
remove nonexisting npc callbacks
AmyrAhmady Sep 8, 2025
cad0f7f
grammatical changes, example fixes, content changes
AmyrAhmady Sep 8, 2025
86f2b4f
NPC node docs
AmyrAhmady Sep 8, 2025
b7c03ee
add GetVehicleRotation
AmyrAhmady Sep 8, 2025
9ab0630
Remove reference to non-existing NPC callback in NPC_SetRot documenta…
itsneufox Sep 8, 2025
76545b6
Remove references to non-existing NPC callbacks in NPC_SetFacingAngle…
itsneufox Sep 8, 2025
5777a79
Remove references to non-existing NPC callbacks in various documentat…
itsneufox Sep 8, 2025
f07ae51
Remove references to non-existing NPC callbacks in NPC_IsStreamedIn a…
itsneufox Sep 8, 2025
5f6a8de
Fix param names and other small stuff
itsneufox Sep 8, 2025
196440e
Remove note about NPC pathfinding
itsneufox Sep 8, 2025
1d9947e
NPC gear docs were more confused than a pilot trying to land without …
itsneufox Sep 9, 2025
97b7640
- Teach NPCs that INVALID_VEHICLE_ID exists
itsneufox Sep 9, 2025
6494d96
streamline example code for path creation
itsneufox Sep 9, 2025
f0f2928
add INVALID_OBJECT_ID to object related functions
itsneufox Sep 9, 2025
2e5a00d
Update NPC_GetVehicle and NPC_GetVehicleID documentation and example …
itsneufox Sep 9, 2025
676dc75
add INVALID_RECORD_ID
itsneufox Sep 9, 2025
8e48967
mistake 🔏
itsneufox Sep 9, 2025
788ee93
Add section for invalid constants, including INVALID_RECORD_ID
itsneufox Sep 9, 2025
f5e9c39
General NPC docs improvements
edgyaf Sep 9, 2025
a9ef88e
Merge latest master changes into NPC-Documentation branch
itsneufox Sep 12, 2025
afea781
Add documentation for Path Nodes
itsneufox Sep 12, 2025
216d096
fix npc related callbacks and functions
dockfries Oct 15, 2025
7458a84
fix GetVehicleRotation related link GetVehicleRotationQuat
dockfries Oct 15, 2025
bb2ea0a
fix npc_isValid, remove related OnNPCConnect/Disconnect
dockfries Oct 15, 2025
9e50a37
maybe fix npc recording path
dockfries Oct 15, 2025
7edb715
npc and more docs prettier format
dockfries Oct 15, 2025
0ea601b
replace OnNPCEnterVehicle with OnPlayerEnterVehicle
dockfries Oct 16, 2025
22c0a38
deprecate or delete the following files?
dockfries Oct 16, 2025
21048b2
Merge pull request #1 from dockfries/NPC-Upstream
itsneufox Oct 23, 2025
f92605d
Make better snippets, fix some of the texts
itsneufox Oct 24, 2025
cbcb71a
get all npcs, npc destroy, paths and enter/exit vehicles
itsneufox Oct 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions frontend/docs/scripting/callbacks/OnClientMessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ description: This callback gets called whenever the NPC sees a ClientMessage.
tags: []
---

:::warning

This callback is deprecated.

:::

## Description

This callback gets called whenever the NPC sees a ClientMessage. This will be everytime a [SendClientMessageToAll](../functions/SendClientMessageToAll) function is used and everytime a [SendClientMessage](../functions/SendClientMessage) function is sent towards the NPC. This callback won't be called when someone says something. For a version of this with player text, see [NPC:OnPlayerText](OnPlayerText).
Expand Down
65 changes: 65 additions & 0 deletions frontend/docs/scripting/callbacks/OnNPCChangeNode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: OnNPCChangeNode
sidebar_label: OnNPCChangeNode
description: This callback is called when an NPC attempts to change from one navigation node to another during node-based movement.
tags: ["npc", "node", "navigation"]
---

<VersionWarn version='omp v1.1.0.changemelater' />

## Description

This callback is called when an NPC attempts to change from one navigation node to another during node-based movement. This allows you to control whether the node change should be allowed or denied.

| Name | Description |
| --------- | ----------------------------------------------- |
| npcid | The ID of the NPC attempting to change nodes |
| newnodeid | The ID of the new node the NPC wants to move to |
| oldnodeid | The ID of the current node the NPC is on |

## Returns

Return `true` to allow the node change, or `false` to deny it.

## Examples

```c
public OnNPCChangeNode(npcid, newnodeid, oldnodeid)
{
printf("NPC %d is changing from node %d to node %d", npcid, oldnodeid, newnodeid);

// Check if the new node is open
if (!NPC_IsNodeOpen(newnodeid))
{
return false; // Deny change to closed node
}

// Prevent NPCs from going to node 5
if (newnodeid == 5)
{
return false; // Block access to node 5
}

return true; // Allow the change
}
```

## Notes

- This callback is only called when NPCs are using node-based navigation via `NPC_PlayNode`
- Returning `false` will prevent the NPC from changing nodes and may cause it to stop navigation
- Node files must be loaded using `NPC_OpenNode` before NPCs can navigate between them

## Related Functions

The following functions might be useful, as they're related to this callback in one way or another.

- [NPC_PlayNode](../functions/NPC_PlayNode): Start NPC node-based navigation
- [NPC_OpenNode](../functions/NPC_OpenNode): Open a navigation node file
- [NPC_CloseNode](../functions/NPC_CloseNode): Close a navigation node file
- [NPC_StopPlayingNode](../functions/NPC_StopPlayingNode): Stop NPC node navigation

## Related Callbacks

- [OnNPCFinishNode](OnNPCFinishNode): Called when NPC finishes navigating a complete node
- [OnNPCFinishNodePoint](OnNPCFinishNodePoint): Called when NPC reaches a specific point in a node
31 changes: 0 additions & 31 deletions frontend/docs/scripting/callbacks/OnNPCConnect.md

This file was deleted.

49 changes: 49 additions & 0 deletions frontend/docs/scripting/callbacks/OnNPCCreate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: OnNPCCreate
sidebar_label: OnNPCCreate
description: This callback is called when an NPC is successfully created.
tags: ["npc"]
---

<VersionWarn version='omp v1.1.0.changemelater' />

## Description

This callback is called when an NPC is successfully created and added to the server.

| Name | Description |
| ----- | ---------------------------------- |
| npcid | The ID of the NPC that was created |

## Examples

```c
public OnNPCCreate(npcid)
{
printf("NPC %d has been created", npcid);

// Set initial properties
NPC_SetSkin(npcid, 23);
NPC_SetPos(npcid, 1958.33, 1343.12, 15.36);

return true;
}
```

## Notes

- This callback is called immediately after the NPC is created but before it's spawned
- The NPC will need to be spawned using `NPC_Spawn` to become visible in the game world

## Related Functions

The following functions might be useful, as they're related to this callback in one way or another.

- [NPC_Create](../functions/NPC_Create): Create a new NPC
- [NPC_Destroy](../functions/NPC_Destroy): Destroy an existing NPC
- [NPC_Spawn](../functions/NPC_Spawn): Spawn the NPC in the game world

## Related Callbacks

- [OnNPCDestroy](OnNPCDestroy): Called when an NPC is destroyed
- [OnNPCSpawn](OnNPCSpawn): Called when an NPC is spawned
66 changes: 66 additions & 0 deletions frontend/docs/scripting/callbacks/OnNPCDeath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: OnNPCDeath
sidebar_label: OnNPCDeath
description: This callback is called when an NPC dies.
tags: ["npc"]
---

<VersionWarn version='omp v1.1.0.changemelater' />

## Description

This callback is called when an NPC dies.

| Name | Description |
| -------- | --------------------------------------------------------------------------- |
| npcid | The ID of the NPC that died |
| killerid | The ID of the player/NPC that killed the NPC (or INVALID_PLAYER_ID if none) |
| reason | The reason for death (weapon ID or death cause) |

## Examples

```c
public OnNPCDeath(npcid, killerid, reason)
{
if (killerid != INVALID_PLAYER_ID)
{
printf("NPC %d was killed by %d with reason %d", npcid, killerid, reason);
}
else
{
printf("NPC %d died", npcid);
}

// Respawn after 5 seconds
SetTimerEx("RespawnNPC", 5000, false, "i", npcid);

return true;
}

forward RespawnNPC(npcid);
public RespawnNPC(npcid)
{
NPC_Respawn(npcid);
}
```

## Notes

- The `killerid` parameter will be `INVALID_PLAYER_ID` if the NPC death was not player inflicted
- The `reason` parameter contains the weapon ID that caused the death (255 for unknown/other causes)

## Related Functions

The following functions might be useful, as they're related to this callback in one way or another.

- [NPC_Kill](../functions/NPC_Kill): Kill an NPC
- [NPC_Respawn](../functions/NPC_Respawn): Respawn a dead NPC
- [NPC_GetHealth](../functions/NPC_GetHealth): Get NPC's health
- [NPC_SetHealth](../functions/NPC_SetHealth): Set NPC's health

## Related Callbacks

- [OnNPCSpawn](OnNPCSpawn): Called when an NPC spawns
- [OnNPCRespawn](OnNPCRespawn): Called when an NPC respawns
- [OnNPCTakeDamage](OnNPCTakeDamage): Called when an NPC takes damage
- [OnPlayerDeath](OnPlayerDeath): Called when a player dies
51 changes: 51 additions & 0 deletions frontend/docs/scripting/callbacks/OnNPCDestroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: OnNPCDestroy
sidebar_label: OnNPCDestroy
description: This callback is called when an NPC is destroyed.
tags: ["npc"]
---

<VersionWarn version='omp v1.1.0.changemelater' />

## Description

This callback is called when an NPC is destroyed and removed from the server.

| Name | Description |
| ----- | ------------------------------------ |
| npcid | The ID of the NPC that was destroyed |

## Examples

```c
public OnNPCDestroy(npcid)
{
printf("NPC %d has been destroyed", npcid);

// Clean up timers
if (g_NPCTimer[npcid] != -1)
{
KillTimer(g_NPCTimer[npcid]);
g_NPCTimer[npcid] = -1;
}

return true;
}
```

## Notes

- This callback is called immediately before the NPC is removed from the server
- The NPC will be disconnected and its player slot freed after this callback

## Related Functions

The following functions might be useful, as they're related to this callback in one way or another.

- [NPC_Create](../functions/NPC_Create): Create a new NPC
- [NPC_Destroy](../functions/NPC_Destroy): Destroy an existing NPC
- [NPC_IsValid](../functions/NPC_IsValid): Check if NPC ID is valid

## Related Callbacks

- [OnNPCCreate](OnNPCCreate): Called when an NPC is created
31 changes: 0 additions & 31 deletions frontend/docs/scripting/callbacks/OnNPCDisconnect.md

This file was deleted.

31 changes: 0 additions & 31 deletions frontend/docs/scripting/callbacks/OnNPCEnterVehicle.md

This file was deleted.

26 changes: 0 additions & 26 deletions frontend/docs/scripting/callbacks/OnNPCExitVehicle.md

This file was deleted.

Loading