Skip to content

getAmbientPedSpawnCandidate

Client-side

Available in Neon, not standard MTA

Asks GTA's native civilian and path rules for one read-only ambient-ped proposal.

Syntax

table|false, string? getAmbientPedSpawnCandidate(Vector3 origin)

Arguments

originVector3

Finite player or population-manager origin used for native distance and visibility rules.

Returns

A table containing model, pedType, x, y, z, direction, and pathLerp; or false plus invalid-origin, no-model, unsupported-model, no-path, path-density, visible-too-close, or blocked.

Ownership and lifecycle

The model-residency pass retains GTA's eight stock zone-ped slots until reset or game teardown. Candidate queries create no element; a multiplayer resource must validate proposals, create and own peds, assign one syncer, advance owner epochs, and clean up every element. Native-event tokens belong to the calling resource, activate only on the current syncer, and are revoked on resource shutdown.

Important behavior
  • The candidate uses GTA's loaded civilian models, path-node density, path width, collision query, camera visibility, and population distance multipliers.
  • This function creates no native or MTA ped and grants no authority. The server must validate the proposal against other players and its own caps before creating a synchronized element.

Example

local candidate, reason = getAmbientPedSpawnCandidate(localPlayer.position)
if candidate then
triggerServerEvent("traffic:candidate", resourceRoot, candidate)
end

Where this comes from

RELATED NEON APIS

Continue exploring

Read the system guide →