Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 12 additions & 12 deletions frontend/docs/scripting/callbacks/OnNPCChangeNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ tags: ["npc", "node", "navigation"]

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 |
| 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

Expand All @@ -27,19 +27,19 @@ Return `true` to allow the node change, or `false` to deny it.
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
}
```
Expand All @@ -54,10 +54,10 @@ public OnNPCChangeNode(npcid, newnodeid, oldnodeid)

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

- [NPC_PlayNode](NPC_PlayNode): Start NPC node-based navigation
- [NPC_OpenNode](NPC_OpenNode): Open a navigation node file
- [NPC_CloseNode](NPC_CloseNode): Close a navigation node file
- [NPC_StopPlayingNode](NPC_StopPlayingNode): Stop NPC node navigation
- [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

Expand Down
15 changes: 7 additions & 8 deletions frontend/docs/scripting/callbacks/OnNPCCreate.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ tags: ["npc"]

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

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

## Examples
Expand All @@ -21,11 +21,11 @@ This callback is called when an NPC is successfully created and added to the ser
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;
}
```
Expand All @@ -39,12 +39,11 @@ public OnNPCCreate(npcid)

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

- [NPC_Create](NPC_Create): Create a new NPC
- [NPC_Destroy](NPC_Destroy): Destroy an existing NPC
- [NPC_Spawn](NPC_Spawn): Spawn the NPC in the game world
- [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
- [OnNPCConnect](OnNPCConnect): Called when an NPC connects to the server
20 changes: 10 additions & 10 deletions frontend/docs/scripting/callbacks/OnNPCDeath.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ tags: ["npc"]

This callback is called when an NPC dies.

| Name | Description |
| -------- | ----------------------------------------------------- |
| npcid | The ID of the NPC that died |
| 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) |
| reason | The reason for death (weapon ID or death cause) |

## Examples

Expand All @@ -30,10 +30,10 @@ public OnNPCDeath(npcid, killerid, reason)
{
printf("NPC %d died", npcid);
}

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

return true;
}

Expand All @@ -53,10 +53,10 @@ public RespawnNPC(npcid)

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

- [NPC_Kill](NPC_Kill): Kill an NPC
- [NPC_Respawn](NPC_Respawn): Respawn a dead NPC
- [NPC_GetHealth](NPC_GetHealth): Get NPC's health
- [NPC_SetHealth](NPC_SetHealth): Set NPC's health
- [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

Expand Down
16 changes: 7 additions & 9 deletions frontend/docs/scripting/callbacks/OnNPCDestroy.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ tags: ["npc"]

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

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

## Examples
Expand All @@ -21,14 +21,14 @@ This callback is called when an NPC is destroyed and removed from the server.
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;
}
```
Expand All @@ -42,12 +42,10 @@ public OnNPCDestroy(npcid)

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

- [NPC_Create](NPC_Create): Create a new NPC
- [NPC_Destroy](NPC_Destroy): Destroy an existing NPC
- [IsValidNPC](IsValidNPC): Check if NPC ID is valid
- [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
- [OnNPCConnect](OnNPCConnect): Called when an NPC connects to the server
- [OnNPCDisconnect](OnNPCDisconnect): Called when an NPC disconnects from the server
18 changes: 9 additions & 9 deletions frontend/docs/scripting/callbacks/OnNPCFinishMove.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ tags: ["npc", "movement"]

This callback is called when an NPC finishes moving to its target destination.

| Name | Description |
| ----- | --------------------------------------------- |
| npcid | The ID of the NPC that finished moving |
| Name | Description |
| ----- | -------------------------------------- |
| npcid | The ID of the NPC that finished moving |

## Examples

```c
public OnNPCFinishMove(npcid)
{
printf("NPC %d has reached its destination", npcid);

// Move to next destination
new Float:x, Float:y, Float:z;
NPC_GetPos(npcid, x, y, z);
NPC_Move(npcid, x + 10.0, y + 10.0, z, NPC_MOVE_TYPE_WALK);

return true;
}
```
Expand All @@ -42,10 +42,10 @@ public OnNPCFinishMove(npcid)

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

- [NPC_Move](NPC_Move): Make NPC move to a position
- [NPC_MoveToPlayer](NPC_MoveToPlayer): Make NPC follow a player
- [NPC_StopMove](NPC_StopMove): Stop NPC movement
- [NPC_IsMoving](NPC_IsMoving): Check if NPC is currently moving
- [NPC_Move](../functions/NPC_Move): Make NPC move to a position
- [NPC_MoveToPlayer](../functions/NPC_MoveToPlayer): Make NPC follow a player
- [NPC_StopMove](../functions/NPC_StopMove): Stop NPC movement
- [NPC_IsMoving](../functions/NPC_IsMoving): Check if NPC is currently moving

## Related Callbacks

Expand Down
18 changes: 9 additions & 9 deletions frontend/docs/scripting/callbacks/OnNPCFinishMovePath.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ tags: ["npc", "movement", "path"]

This callback is called when an NPC finishes moving along a predefined path.

| Name | Description |
| ------ | ---------------------------------------------- |
| npcid | The ID of the NPC that finished the path |
| pathid | The ID of the path that was completed |
| Name | Description |
| ------ | ---------------------------------------- |
| npcid | The ID of the NPC that finished the path |
| pathid | The ID of the path that was completed |

## Examples

```c
public OnNPCFinishMovePath(npcid, pathid)
{
printf("NPC %d finished moving along path %d", npcid, pathid);

// Start moving on another path
NPC_MoveByPath(npcid, pathid + 1, NPC_MOVE_TYPE_WALK);

return true;
}
```
Expand All @@ -37,9 +37,9 @@ public OnNPCFinishMovePath(npcid, pathid)

## Related Functions

- [NPC_MoveByPath](NPC_MoveByPath): Make NPC follow a path
- [NPC_CreatePath](NPC_CreatePath): Create a new movement path
- [NPC_IsValidPath](NPC_IsValidPath): Check if path is valid
- [NPC_MoveByPath](../functions/NPC_MoveByPath): Make NPC follow a path
- [NPC_CreatePath](../functions/NPC_CreatePath): Create a new movement path
- [NPC_IsValidPath](../functions/NPC_IsValidPath): Check if path is valid

## Related Callbacks

Expand Down
20 changes: 10 additions & 10 deletions frontend/docs/scripting/callbacks/OnNPCFinishNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ tags: ["npc", "node", "navigation"]

This callback is called when an NPC finishes navigating a complete node during node-based movement.

| Name | Description |
| ------ | ---------------------------------------------- |
| npcid | The ID of the NPC that finished the node |
| nodeid | The ID of the node that was completed |
| Name | Description |
| ------ | ---------------------------------------- |
| npcid | The ID of the NPC that finished the node |
| nodeid | The ID of the node that was completed |

## Examples

```c
public OnNPCFinishNode(npcid, nodeid)
{
printf("NPC %d finished navigating node %d", npcid, nodeid);

// Start navigation on next node
NPC_PlayNode(npcid, nodeid + 1, NPC_MOVE_TYPE_WALK, 1.0, 2.0, true);

return true;
}
```
Expand All @@ -40,10 +40,10 @@ public OnNPCFinishNode(npcid, nodeid)

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

- [NPC_PlayNode](NPC_PlayNode): Start NPC node-based navigation
- [NPC_StopPlayingNode](NPC_StopPlayingNode): Stop NPC node navigation
- [NPC_IsPlayingNode](NPC_IsPlayingNode): Check if NPC is navigating a node
- [NPC_OpenNode](NPC_OpenNode): Open a navigation node file
- [NPC_PlayNode](../functions/NPC_PlayNode): Start NPC node-based navigation
- [NPC_StopPlayingNode](../functions/NPC_StopPlayingNode): Stop NPC node navigation
- [NPC_IsPlayingNode](../functions/NPC_IsPlayingNode): Check if NPC is navigating a node
- [NPC_OpenNode](../functions/NPC_OpenNode): Open a navigation node file

## Related Callbacks

Expand Down
22 changes: 11 additions & 11 deletions frontend/docs/scripting/callbacks/OnNPCFinishNodePoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ tags: ["npc", "node", "navigation"]

This callback is called when an NPC reaches a specific point during node-based navigation.

| Name | Description |
| ------- | ------------------------------------------------ |
| npcid | The ID of the NPC that reached the node point |
| nodeid | The ID of the node being navigated |
| pointid | The ID of the specific point that was reached |
| Name | Description |
| ------- | --------------------------------------------- |
| npcid | The ID of the NPC that reached the node point |
| nodeid | The ID of the node being navigated |
| pointid | The ID of the specific point that was reached |

## Examples

```c
public OnNPCFinishNodePoint(npcid, nodeid, pointid)
{
printf("NPC %d reached point %d in node %d", npcid, pointid, nodeid);

// Pause at specific point
if (pointid == 10)
{
NPC_PausePlayingNode(npcid);
SetTimerEx("ResumeNavigation", 3000, false, "i", npcid);
}

return true;
}

Expand All @@ -51,10 +51,10 @@ public ResumeNavigation(npcid)

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

- [NPC_PlayNode](NPC_PlayNode): Start NPC node-based navigation
- [NPC_PausePlayingNode](NPC_PausePlayingNode): Pause NPC node navigation
- [NPC_ResumePlayingNode](NPC_ResumePlayingNode): Resume paused node navigation
- [NPC_StopPlayingNode](NPC_StopPlayingNode): Stop NPC node navigation
- [NPC_PlayNode](../functions/NPC_PlayNode): Start NPC node-based navigation
- [NPC_PausePlayingNode](../functions/NPC_PausePlayingNode): Pause NPC node navigation
- [NPC_ResumePlayingNode](../functions/NPC_ResumePlayingNode): Resume paused node navigation
- [NPC_StopPlayingNode](../functions/NPC_StopPlayingNode): Stop NPC node navigation

## Related Callbacks

Expand Down
Loading