TaskWanderInArea
DocsTaskWanderInArea(ped, x, y, z, radius, minimalLength, timeBetweenWalks)Description
Makes a ped wander/patrol around the specified area.
The ped will continue to wander after getting distracted, but only if this additional task is temporary, ie. killing a target, after killing the target it will continue to wander around.
Use GetIsTaskActive(ped, 222) to check if the ped is still wandering the area.
Parameters
| Name | Type | Description |
|---|---|---|
ped | Ped | The ped which will wander the area. |
x | float | The X coordinate. |
y | float | The Y coordinate |
z | float | The Z coordinate |
radius | float | The radius of the area to wander around in |
minimalLength | int | The minimal length it will wander before waiting timeBetweenWalks seconds before continuing |
timeBetweenWalks | float | The length of time the ped will stand still/rest between walks |
Quick Snippet: Get Coordinatesxyz
xyzAdd this command to your client script to retrieve precise locations in-game.
-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)
print(output)
TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)Quick Snippet: Get Ped Handleped
pedUse this to get the player ped handle for this native.
-- Get the player's ped handle (client-side)
local ped = PlayerPedId()
print("Ped handle: " .. ped)
-- For a specific player's ped (server-side):
-- local targetPed = GetPlayerPed(source)Ped Models

mp_m_freemode_01
player_zero
ig_agatha
s_m_y_cop_01
s_m_m_gaffer_01
g_m_m_armboss_01
a_c_boar
a_m_m_bevhills_01Returns
voidThis native does not return a value.
Examples
Official
-- Load model for panther
local model = `a_c_panther`
RequestModel(model)
while not HasModelLoaded(model) do
Citizen.Wait(0)
end
-- Spawn a panther at current coordinates
local coords = GetEntityCoords(PlayerPedId())
local ped = CreatePed(0, model, coords.x, coords.y, coords.z, 0.0, true)
-- Make sure the ped doesn't flee or gets distracted
SetBlockingOfNonTemporaryEvents(ped, true)
-- Make ped wander in spawned area with radius of 100 meters, will wander at least 2 meters and wait for around 10 seconds between patrols
TaskWanderInArea(ped, coords.x, coords.y, coords.z, 100.0, 2, 10.0)
-- Check if the ped is wandering
-- Tasks don't trigger instantly, so wait a bit before checking
Citizen.Wait(1000)
print(GetIsTaskActive(ped, 222)) -- 1