NPC_AddPointToPath
注意
This function was added in omp v1.5.8.3079 and will not work in earlier versions!
Description
Adds a waypoint to an NPC path.
| Name | Description |
|---|---|
| pathid | The ID of the path to add the point to |
| x | The X coordinate of the waypoint |
| y | The Y coordinate of the waypoint |
| z | The Z coordinate of the waypoint |
| stopRange | The distance from point at which to consider it reached |
Returns
Returns true on success, false on failure.
Examples
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/addpatrolpos", true))
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
// Try to add patrol point
if (NPC_AddPointToPath(PlayerPatrolPath[playerid], x, y, z, 1.5))
{
SendClientMessage(playerid, 0x00FF00FF, "Added point to path %d at your current location", PlayerPatrolPath[playerid]);
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "Failed add point to path");
}
return 1;
}
return 0;
}
Notes
- Points are added sequentially to form the path route
- The
stopRangeparameter defines how close the NPC needs to get before moving to the next point - A smaller
stopRangemakes the NPC follow the path more precisely - The path must be created with
NPC_CreatePathbefore adding points
Related Functions
- NPC_CreatePath: Create a new path
- NPC_RemovePointFromPath: Remove a point from a path
- NPC_GetPathPoint: Get details about a specific point
- NPC_MoveByPath: Make NPC follow a path
- NPC_GetPathPointCount: Get number of points in a path
Related Callbacks
- OnNPCFinishMovePathPoint: Called when NPC reaches each path point
- OnNPCFinishMovePath: Called when NPC finishes moving along a path
- OnNPCFinishMove: Called when NPC finishes any movement