ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. setPedTask

Function

setPedTask

ServerPedsTrilogy Hub only

Stores a "task" for a ped in a chosen layer, e.g. primary = "enterVehicle", together with any data. It is a mechanism for scripts (e.g. your own NPC AI): the game does not carry out stored tasks by itself, but other scripts can read them with getPedTask, getPedTasks, isPedDoingTask and getPedSimplestTask. Passing nil as the name clears the task from the layer.

Syntax

bool setPedTask(ped ped, string priority [, string name = nil, any data = nil])

Arguments

pedped
A player or an NPC.
prioritystring
Layer name, e.g. "primary", "secondary" (any string).
namestring, optional = nil
Task name, e.g. "patrol". nil = clear this layer.
dataany, optional = nil
Any task data (number, string, table, element).

Returns

true on success.

Example

setPedTask(guard, "primary", "patrol", { 2490, -1670, 13.3 })

See also