ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server events
  3. onPedReachedTarget

Event

onPedReachedTarget

ServerPedsTrilogy Hub only

The NPC reached the target set by setPedWalkTo (within radius). The walk has already ended, so the handler can send it on right away.

Handler

addEventHandler("onPedReachedTarget", root, function(x, y, z) ... end)

Parameters

xfloat
Target X.
yfloat
Target Y.
zfloat
Target Z.

Source

source is the NPC.

Example

local route = { { 1540, -1675, 16 }, { 1540, -1690, 16 }, { 1550, -1690, 16 } }
local guard = createPed(280, 1550, -1675, 16)
local step = 1
setPedWalkTo(guard, unpack(route[step]))
addEventHandler("onPedReachedTarget", guard, function()
    step = step % #route + 1
    setPedWalkTo(source, unpack(route[step]))
end)

See also