TasksClient

taskPatrol

TASK_PATROL0xBDA5DF49D080FE4E

The GTA V native TASK_PATROL of the TASK namespace, as LS:MP client scripts call it: the global function taskPatrol, in JavaScript and in Lua.

SignatureJavaScript
taskPatrol(
  ped: Ped,
  patrolRouteName: string,
  alertState: number,
  canChatToPeds: boolean,
  useHeadLookAt: boolean
): void
SignatureLua
taskPatrol(
  ped: Ped,
  patrolRouteName: string,
  alertState: integer,
  canChatToPeds: boolean,
  useHeadLookAt: boolean
)

Usage

JavaScript
taskPatrol(ped, patrolRouteName, alertState, canChatToPeds, useHeadLookAt);
Lua
taskPatrol(ped, patrolRouteName, alertState, canChatToPeds, useHeadLookAt)

Parameters

ParameterTypeJavaScriptLua
pedPednumberinteger
patrolRouteNamestringstringstring
alertStateintnumberinteger
canChatToPedsBOOLbooleanboolean
useHeadLookAtBOOLbooleanboolean

Returns

Nothing. In JavaScript the call evaluates to undefined.

Notes

From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.

After looking at some scripts the second parameter seems to be an id of some kind. Here are some I found from some R* scripts:

"miss_Tower_01" (this went from 01 - 10)
"miss_Ass0" (0, 4, 6, 3)
"MISS_PATROL_8"

I think they're patrol routes, but I'm not sure. And I believe the 3rd parameter is a BOOL, but I can't confirm other than only seeing 0 and 1 being passed.

As far as I can see the patrol routes names such as "miss_Ass0" have been defined earlier in the scripts. This leads me to believe we can defined our own new patrol routes by following the same approach.
From the scripts

openPatrolRoute("miss_Ass0");
addPatrolRouteNode(0, "WORLD_HUMAN_GUARD_STAND", l_738[0/*3*/], -139.4076690673828, -993.4732055664062, 26.2754, getRandomIntInRange(5000, 10000));
addPatrolRouteNode(1, "WORLD_HUMAN_GUARD_STAND", l_738[1/*3*/], -116.1391830444336, -987.4984130859375, 26.38541030883789, getRandomIntInRange(5000, 10000));
addPatrolRouteNode(2, "WORLD_HUMAN_GUARD_STAND", l_738[2/*3*/], -128.46847534179688, -979.0340576171875, 26.2754, getRandomIntInRange(5000, 10000));
addPatrolRouteLink(0, 1);
addPatrolRouteLink(1, 2);
addPatrolRouteLink(2, 0);
closePatrolRoute();
createPatrolRoute();

Reference

Namespace
Tasks TASK
In the game
void TASK_PATROL(Ped ped, const char* patrolRouteName, int alertState, BOOL canChatToPeds, BOOL useHeadLookAt)
Hash
0xBDA5DF49D080FE4E

Open in the interactive natives reference