Skip to content

setPedGoTo

Client-side

Send an NPC straight toward a nearby coordinate. GTA handles the walk or run, slows the NPC down, and stops it inside the arrival radius.

Complete example

-- client.lua
-- Sweet runs directly to a nearby point and stops there.
local sweet = createPed(270, 2495.2, -1687.4, 13.5)
local destination = Vector3(2520.0, -1672.0, 13.8)
if sweet then
assert(setPedGoTo(sweet, destination, "run", 0.75, 3.0))
end

Syntax

bool setPedGoTo(ped thePed, Vector3 target [, string movement = "walk", float radius = 0.5, float slowdownRadius = 2.0, int timeout = -2])

GTA task mapping

ORIGINAL GTA TASK 05D3
CTaskComplexGoToPointAndStandStillCTaskComplexGoToPointAndStandStillTimed

SCM equivalent: TASK_GO_STRAIGHT_TO_COORD

San Andreas Online selects the untimed task for timeout -2. Every other value uses the timed variant, with -1 normalized to GTA's 20-second SCM default.

Arguments

thePedped

Living streamed ped simulated by this client.

targetVector3

Finite destination.

movementstringoptional · default walk

walk, run, or sprint.

radiusfloatoptional · default 0.5

Positive arrival radius.

slowdownRadiusfloatoptional · default 2.0

Slowdown radius not smaller than radius.

timeoutintoptional · default -2

-2 for untimed, -1 for SCM-compatible 20 seconds, or a non-negative millisecond timeout.

Returns

true when the native task was installed; false when ownership, streaming, liveness, target, movement, radius, or timeout checks fail.

Ownership and lifecycle

Low-level ped task calls require the client that simulates the living, streamed ped. Driving tasks also require control of the streamed vehicle. They do not create lifecycle handles; the optional native-task-runtime adds server-owned route epochs and reconstruction for drive_to routes. Gang-tag ownership is resource-exclusive, survives object streaming and recreation, and is released automatically when the owner stops.

Important behavior
  • This is GTA's straight-to-coordinate task. For a route through GTA's pedestrian path network and around buildings, use setPedNavigateTo.

OOP aliases

  • ped:setGoTo(target, movement, radius, slowdownRadius, timeout)

Where this comes from

RELATED SA:O APIS

Continue exploring

Read the system guide →