GE Lua Documentation

Press F to search!

removeTraffic

Definition


-- @/lua/ge/extensions/gameplay/traffic.lua:507

local function removeTraffic(id, stopAi) -- remove a vehicle from the traffic table
  if traffic[id] then
    local obj = getObjectByID(id)
    local idx = arrayFindValueIndex(trafficAiVehsList, id)
    if idx then table.remove(trafficAiVehsList, idx) end

    if obj then
      traffic[id].role:resetAction()
      obj:setMeshAlpha(1, '')
      obj.playerUsable = true
      obj.uiState = 1

      if stopAi and traffic[id].isAi then
        obj:queueLuaCommand('ai.setMode("stop")')
      end
      if vehPool then
        vehPool:removeVeh(id)
      end
    end

    traffic[id] = nil
    trafficIdsSorted = tableKeysSorted(traffic)
    auxiliaryData.activeChanged = true
    extensions.hook('onTrafficVehicleRemoved', id)
  end

  if vehPool and not trafficAiVehsList[1] then
    deleteTrafficPool()
  end
end

Callers

@/lua/ge/extensions/gameplay/traffic.lua
local function onVehicleDestroyed(id)
  removeTraffic(id)
  if vehPool then vehPool._updateFlag = true end
    if traffic[id] and (traffic[id].isAi or tonumber(veh.isTraffic) == 1) then
      removeTraffic(id)
      veh:delete()
  for _, id in ipairs(tableKeysSorted(traffic)) do
    removeTraffic(id, stopAi)
  end
@/lua/ge/extensions/flowgraph/modules/trafficModule.lua

function C:removeTraffic(id)
  gameplay_traffic.removeTraffic(id)
function C:removeTraffic(id)
  gameplay_traffic.removeTraffic(id)
  self:updateTrafficState()
@/lua/ge/extensions/flowgraph/nodes/gameplay/traffic/removeVehicle.lua
  if self.pinIn.vehId.value then
    self.mgr.modules.traffic:removeTraffic(self.pinIn.vehId.value)
  end
@/lua/ge/extensions/editor/trafficManager.lua
  elseif trafficData[sessionData.id] and not aiData.enableTraffic then
    gameplay_traffic.removeTraffic(sessionData.id)
  end
  veh:queueLuaCommand('ai.setMode("stop")')
  gameplay_traffic.removeTraffic(sessionData.id)
end