getAmbientVehicleModelCandidate
Client-side
Ask GTA which civilian road vehicle naturally fits the current area and population settings—without creating it.
Syntax
table|false, string? getAmbientVehicleModelCandidate()Returns
A table with model, carGroup, and vehicleClass; or false plus a reason when GTA cannot select a road vehicle.
Ownership and lifecycle
Candidate queries create nothing. A multiplayer resource must validate each proposal, create and own the real NPCs and vehicles, assign one current syncer, handle ownership changes, and clean up every element. Native AI and event tokens belong to the calling resource and are revoked when that resource stops.
Important behavior
- The choice comes from GTA's current population and car-group state.
- The server still decides whether to accept the proposal and create the vehicle.
Where this comes from
SOURCECLuaWorldDefs.cppClient/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp INTRODUCED / EXTENDEDb23f57d74Read the commit and why the change was made TEST RESOURCE native-vehicle-traffic test-resources/native-vehicle-traffic
RELATED SA:O APIS
Read the system guide → Continue exploring
← Back to the SA:O Lua API · How Synchronized NPCs and road traffic works →