getAmbientPedSpawnCandidate
Asks GTA's native civilian and path rules for one read-only ambient-ped proposal.
Syntax
table|false, string? getAmbientPedSpawnCandidate(Vector3 origin)Arguments
originVector3Finite 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.
- 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)endWhere this comes from
Continue exploring
← Back to the Neon Lua API · How Synchronized ambient pedestrians works →