Skip to content

Commit 24a62d5

Browse files
committed
NPC_GetPosMovingTo.md
1 parent a3a5160 commit 24a62d5

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: NPC_GetPosMovingTo
3+
sidebar_label: NPC_GetPosMovingTo
4+
description: Gets the position that the NPC is currently moving toward.
5+
tags: ["npc", "position", "movement"]
6+
---
7+
8+
<VersionWarn version='omp v1.1.0.changemelater' />
9+
10+
## Description
11+
12+
Gets the position that the NPC is currently moving toward.
13+
14+
| Name | Description |
15+
| -------- | ------------------------------------------------------------------ |
16+
| npcid | The ID of the NPC |
17+
| &Float:x | Variable to store the X coordinate of the target position, passed by reference |
18+
| &Float:y | Variable to store the Y coordinate of the target position, passed by reference |
19+
| &Float:z | Variable to store the Z coordinate of the target position, passed by reference |
20+
21+
## Returns
22+
23+
Returns `true` on success, `false` on failure.
24+
25+
## Examples
26+
27+
```c
28+
public OnPlayerCommandText(playerid, cmdtext[])
29+
{
30+
if (!strcmp(cmdtext, "/checkposmovingto", true))
31+
{
32+
new npcid = PlayerNPC[playerid];
33+
if (npcid == INVALID_NPC_ID)
34+
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");
35+
36+
if (!NPC_IsValid(npcid))
37+
return SendClientMessage(playerid, 0xFF0000FF, "Invalid NPC.");
38+
39+
if (!NPC_IsMoving(npcid))
40+
return SendClientMessage(playerid, 0xFF0000FF, "NPC %d is not moving", npcid);
41+
42+
new Float:x, Float:y, Float:z;
43+
NPC_GetPosMovingTo(npcid, x, y, z);
44+
45+
SendClientMessage(playerid, 0x00FF00FF, "NPC %d target position: %.2f, %.2f, %.2f", npcid, x, y, z);
46+
return 1;
47+
}
48+
return 0;
49+
}
50+
```
51+
52+
## Notes
53+
54+
:::warning
55+
56+
- All coordinate parameters are passed by reference and will be modified.
57+
- This function returns the target position the NPC is moving toward, not the current position.
58+
- Use [NPC_IsMoving](NPC_IsMoving) to check if the NPC is currently moving before calling this function.
59+
60+
:::
61+
62+
## Related Functions
63+
64+
- [NPC_Move](NPC_Move): Makes an NPC move to a specific position.
65+
- [NPC_IsMoving](NPC_IsMoving): Check if NPC is moving.
66+
- [NPC_GetPos](NPC_GetPos): Get NPC's current position.
67+
- [NPC_StopMove](NPC_StopMove): Stop NPC movement.
68+
69+
## Related Callbacks
70+
71+
- [OnNPCFinishMove](../callbacks/OnNPCFinishMove): Called when NPC finishes movement.

0 commit comments

Comments
 (0)