Skip to content

Commit 7aad7a8

Browse files
committed
That's all Folks!
1 parent cf1a1ae commit 7aad7a8

17 files changed

+256
-139
lines changed

frontend/docs/scripting/callbacks/OnNPCChangeNode.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,20 @@ Return `true` to allow the node change, or `false` to deny it.
2626
```c
2727
public OnNPCChangeNode(npcid, newnodeid, oldnodeid)
2828
{
29-
printf("NPC %d is changing from node %d to node %d", npcid, oldnodeid, newnodeid);
29+
printf("[NPC] NPC %d changed from node %d to node %d", npcid, oldnodeid, newnodeid);
3030

31-
// Check if the new node is open
32-
if (!NPC_IsNodeOpen(newnodeid))
31+
// Notify players tracking this NPC
32+
for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
3333
{
34-
return false; // Deny change to closed node
35-
}
34+
if (!IsPlayerConnected(playerid))
35+
continue;
3636

37-
// Prevent NPCs from going to node 5
38-
if (newnodeid == 5)
39-
{
40-
return false; // Block access to node 5
37+
if (PlayerNPC[playerid] == npcid)
38+
{
39+
SendClientMessage(playerid, 0x00FF00FF, "NPC %d changed from node %d to node %d", npcid, oldnodeid, newnodeid);
40+
}
4141
}
42-
43-
return true; // Allow the change
42+
return 1;
4443
}
4544
```
4645

frontend/docs/scripting/callbacks/OnNPCCreate.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ This callback is called when an NPC is successfully created and added to the ser
2020
```c
2121
public OnNPCCreate(npcid)
2222
{
23-
printf("NPC %d has been created", npcid);
23+
printf("[NPC] NPC %d has been created", npcid);
2424

25-
// Set initial properties
26-
NPC_SetSkin(npcid, 23);
27-
NPC_SetPos(npcid, 1958.33, 1343.12, 15.36);
25+
// Notify all connected players
26+
for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
27+
{
28+
if (!IsPlayerConnected(playerid))
29+
continue;
2830

29-
return true;
31+
SendClientMessage(playerid, 0x00FF00FF, "NPC %d has been created", npcid);
32+
}
33+
return 1;
3034
}
3135
```
3236

frontend/docs/scripting/callbacks/OnNPCDeath.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,29 @@ This callback is called when an NPC dies.
2020
## Examples
2121

2222
```c
23-
public OnNPCDeath(npcid, killerid, reason)
23+
public OnNPCDeath(npcid, killerid, WEAPON:reason)
2424
{
25-
if (killerid != INVALID_PLAYER_ID)
26-
{
27-
printf("NPC %d was killed by %d with reason %d", npcid, killerid, reason);
28-
}
29-
else
25+
printf("[NPC] NPC %d died (killer: %d, weapon: %d)", npcid, killerid, _:reason);
26+
27+
// Notify players tracking this NPC
28+
for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
3029
{
31-
printf("NPC %d died", npcid);
30+
if (!IsPlayerConnected(playerid))
31+
continue;
32+
33+
if (PlayerNPC[playerid] == npcid)
34+
{
35+
if (killerid == INVALID_PLAYER_ID)
36+
{
37+
SendClientMessage(playerid, 0xFF0000FF, "Your tracked NPC %d died (weapon: %d)", npcid, _:reason);
38+
}
39+
else
40+
{
41+
SendClientMessage(playerid, 0xFF0000FF, "Your tracked NPC %d was killed by player %d (weapon: %d)", npcid, killerid, _:reason);
42+
}
43+
}
3244
}
33-
34-
// Respawn after 5 seconds
35-
SetTimerEx("RespawnNPC", 5000, false, "i", npcid);
36-
37-
return true;
38-
}
39-
40-
forward RespawnNPC(npcid);
41-
public RespawnNPC(npcid)
42-
{
43-
NPC_Respawn(npcid);
45+
return 1;
4446
}
4547
```
4648

frontend/docs/scripting/callbacks/OnNPCDestroy.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,27 @@ This callback is called when an NPC is destroyed and removed from the server.
2020
```c
2121
public OnNPCDestroy(npcid)
2222
{
23-
printf("NPC %d has been destroyed", npcid);
23+
printf("[NPC] NPC %d has been destroyed", npcid);
2424

25-
// Clean up timers
26-
if (g_NPCTimer[npcid] != -1)
25+
// Clear any player tracking this NPC and notify
26+
for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
2727
{
28-
KillTimer(g_NPCTimer[npcid]);
29-
g_NPCTimer[npcid] = -1;
28+
if (!IsPlayerConnected(playerid))
29+
continue;
30+
31+
if (PlayerNPC[playerid] == npcid)
32+
{
33+
PlayerNPC[playerid] = INVALID_NPC_ID;
34+
SendClientMessage(playerid, 0xFF0000FF, "Your tracked NPC %d has been destroyed", npcid);
35+
}
36+
else
37+
{
38+
SendClientMessage(playerid, 0xFFFF00FF, "NPC %d has been destroyed", npcid);
39+
}
3040
}
31-
32-
return true;
41+
return 1;
3342
}
43+
3444
```
3545
3646
## Notes

frontend/docs/scripting/callbacks/OnNPCFinishMove.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,20 @@ This callback is called when an NPC finishes moving to its target destination.
2020
```c
2121
public OnNPCFinishMove(npcid)
2222
{
23-
printf("NPC %d has reached its destination", npcid);
24-
25-
// Move to next destination
26-
new Float:x, Float:y, Float:z;
27-
NPC_GetPos(npcid, x, y, z);
28-
NPC_Move(npcid, x + 10.0, y + 10.0, z, NPC_MOVE_TYPE_WALK);
29-
30-
return true;
23+
// Find all players tracking this NPC
24+
for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
25+
{
26+
if (!IsPlayerConnected(playerid))
27+
continue;
28+
29+
if (PlayerNPC[playerid] == npcid)
30+
{
31+
new Float:x, Float:y, Float:z;
32+
NPC_GetPos(npcid, x, y, z);
33+
SendClientMessage(playerid, 0x00FF00FF, "NPC %d finished moving to position (%.2f, %.2f, %.2f)", npcid, x, y, z);
34+
}
35+
}
36+
return 1;
3137
}
3238
```
3339

frontend/docs/scripting/callbacks/OnNPCFinishMovePath.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@ This callback is called when an NPC finishes moving along a predefined path.
2121
```c
2222
public OnNPCFinishMovePath(npcid, pathid)
2323
{
24-
printf("NPC %d finished moving along path %d", npcid, pathid);
25-
26-
// Start moving on another path
27-
NPC_MoveByPath(npcid, pathid + 1, NPC_MOVE_TYPE_WALK);
28-
29-
return true;
24+
// Find all players tracking this NPC
25+
for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
26+
{
27+
if (!IsPlayerConnected(playerid))
28+
continue;
29+
30+
if (PlayerNPC[playerid] == npcid)
31+
{
32+
SendClientMessage(playerid, 0x00FF00FF, "NPC %d finished moving along path %d", npcid, pathid);
33+
}
34+
}
35+
return 1;
3036
}
37+
3138
```
3239
3340
## Notes

frontend/docs/scripting/callbacks/OnNPCFinishMovePathPoint.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ This callback is called when an NPC finishes moving to a specific point in a pat
1919

2020
## Examples
2121

22+
```c
23+
public OnNPCFinishMovePathPoint(npcid, pathid, pointid)
24+
{
25+
// Find all players tracking this NPC
26+
for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
27+
{
28+
if (!IsPlayerConnected(playerid))
29+
continue;
30+
31+
if (PlayerNPC[playerid] == npcid)
32+
{
33+
SendClientMessage(playerid, 0xFFFF00FF, "NPC %d reached point %d on path %d", npcid, pointid, pathid);
34+
}
35+
}
36+
return 1;
37+
}
38+
39+
```
40+
2241
## Notes
2342
2443
- This callback is triggered for each point in the path

frontend/docs/scripting/callbacks/OnNPCFinishNode.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ This callback is called when an NPC finishes navigating a complete node during n
1919
## Examples
2020

2121
```c
22-
public OnNPCFinishNode(npcid, nodeid)
22+
public OnNPCFinishNodePoint(npcid, nodeid, pointid)
2323
{
24-
printf("NPC %d finished navigating node %d", npcid, nodeid);
25-
26-
// Start navigation on next node
27-
NPC_PlayNode(npcid, nodeid + 1, NPC_MOVE_TYPE_WALK, 1.0, 2.0, true);
28-
29-
return true;
24+
// Notify players tracking this NPC
25+
for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
26+
{
27+
if (!IsPlayerConnected(playerid))
28+
continue;
29+
30+
if (PlayerNPC[playerid] == npcid)
31+
{
32+
SendClientMessage(playerid, 0xFFFF00FF, "NPC %d reached node %d point %d", npcid, nodeid, pointid);
33+
}
34+
}
35+
return 1;
3036
}
3137
```
3238

frontend/docs/scripting/callbacks/OnNPCFinishNodePoint.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,22 @@ This callback is called when an NPC reaches a specific point during node-based n
2020
## Examples
2121

2222
```c
23-
public OnNPCFinishNodePoint(npcid, nodeid, pointid)
23+
public OnNPCFinishNode(npcid, nodeid)
2424
{
25-
printf("NPC %d reached point %d in node %d", npcid, pointid, nodeid);
25+
printf("[NPC] NPC %d finished node %d", npcid, nodeid);
2626

27-
// Pause at specific point
28-
if (pointid == 10)
27+
// Notify players tracking this NPC
28+
for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
2929
{
30-
NPC_PausePlayingNode(npcid);
31-
SetTimerEx("ResumeNavigation", 3000, false, "i", npcid);
32-
}
33-
34-
return true;
35-
}
30+
if (!IsPlayerConnected(playerid))
31+
continue;
3632

37-
forward ResumeNavigation(npcid);
38-
public ResumeNavigation(npcid)
39-
{
40-
NPC_ResumePlayingNode(npcid);
33+
if (PlayerNPC[playerid] == npcid)
34+
{
35+
SendClientMessage(playerid, 0x00FF00FF, "NPC %d finished node %d", npcid, nodeid);
36+
}
37+
}
38+
return 1;
4139
}
4240
```
4341

frontend/docs/scripting/callbacks/OnNPCGiveDamage.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,21 @@ Return `false` to prevent the damage from being applied, or `true` to allow it.
2626
## Examples
2727

2828
```c
29-
public OnNPCGiveDamage(npcid, damagedid, Float:amount, weaponid, bodypart)
29+
public OnNPCGiveDamage(npcid, damagedid, Float:amount, WEAPON:weaponid, bodypart)
3030
{
31-
printf("NPC %d gave %.2f damage to player %d", npcid, amount, damagedid);
32-
33-
// Prevent NPCs from killing admins
34-
if (IsPlayerAdmin(damagedid))
31+
// Only notify players tracking this NPC
32+
for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
3533
{
36-
return false; // Block the damage
34+
if (!IsPlayerConnected(playerid))
35+
continue;
36+
37+
if (PlayerNPC[playerid] == npcid)
38+
{
39+
SendClientMessage(playerid, 0xFF8800FF, "NPC %d dealt %.1f damage to player %d (weapon: %d, bodypart: %d)",
40+
npcid, amount, damagedid, _:weaponid, bodypart);
41+
}
3742
}
38-
39-
return true; // Allow the damage
43+
return 1;
4044
}
4145
```
4246

0 commit comments

Comments
 (0)