Preskoči na vsebino

NPC_AddPointToPath

opozorilo

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.

NameDescription
pathidThe ID of the path to add the point to
xThe X coordinate of the waypoint
yThe Y coordinate of the waypoint
zThe Z coordinate of the waypoint
stopRangeThe 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 stopRange parameter defines how close the NPC needs to get before moving to the next point
  • A smaller stopRange makes the NPC follow the path more precisely
  • The path must be created with NPC_CreatePath before adding points