GE Lua Documentation

Press F to search!

vehIdsToGroup

Definition


-- @/lua/ge/extensions/core/multiSpawn.lua:310

local function vehIdsToGroup(vehIds) -- converts a list of vehicle ids to a group array of vehicle data
  local res = {}
  if not vehIds then return res end

  for _, id in ipairs(vehIds) do
    local data = {}
    local vehData = core_vehicle_manager.getVehicleData(id)
    if vehData then
      local config = vehData.config
      data.model = config.model or string.match(config.partConfigFilename, 'vehicles/([%w|_|%-|%s]+)') -- model might be nil for some reason

      if data.model then
        data.config = string.match(config.partConfigFilename, '/*([%w_%-]+).pc')
        data.paint, data.paint2, data.paint3 = config.paints[1], config.paints[2], config.paints[3]
        data.paintName, data.paintName2, data.paintName3 = '(Custom)', '(Custom)', '(Custom)' -- assumes custom paints (can't assert paint names)
        table.insert(res, data)
      end
    end
  end

  return res
end

Callers

@/lua/ge/extensions/core/multiSpawn.lua

  return vehIdsToGroup(vehIds)
end