onTrafficStarted
Definition
-- @/lua/ge/extensions/gameplay/traffic.lua:1044
local function onTrafficStarted()
state = 'on'
mapNodes = map.getMap().nodes
auxiliaryData.queuedVehicle = 0
auxiliaryData.dynamicSpawnDist = 0
auxiliaryData.dynamicSpawnDir = 0
if not vehPool then
createTrafficPool(trafficAiVehsList)
end
vehPool._updateFlag = true -- acts like a frame delay for the vehicle pooling system
focus.auto = true -- this flag is used to enable the focus to change modes
if vars.aiMode ~= 'traffic' then -- forces vehicles to refresh their AI modes and roles
setTrafficVars({aiMode = vars.aiMode})
end
if gameplay_walk.isWalking() then -- check for player unicycle
checkPlayer(be:getPlayerVehicleID(0))
end
for _, veh in ipairs(getAllVehiclesByType()) do -- check for player vehicles to insert into traffic
checkPlayer(veh:getId())
end
local amount, activeAmount = getTrafficAmount(), getTrafficAmount(true)
log('I', logTag, string.format('Traffic system started with %d active / %d total vehicles', activeAmount, amount))
if not next(mapNodes) then
log('I', logTag, 'Traffic is ready, but currently no road network exists; this is normal if the level just loaded')
end
end
Callers
@/lua/ge/extensions/career/modules/playerDriving.lua
local function onTrafficStarted()
if not career_career.tutorialEnabled and not gameplay_missions_missionManager.getForegroundMissionId() then
@/lua/ge/extensions/gameplay/police.lua
local function onTrafficStarted()
local policeAmount, propAmount = tableSize(policeVehs), #policePropIds