local precache_tab = {
    "models/surrounded/mh53.mdl",
    "models/surrounded/mi24d.mdl",
    "models/surrounded/skilllem_radio.mdl",
    "models/surrounded/test/tcm_family.mdl",
    "models/surrounded/test/tcm_victim.mdl",
    "models/surrounded/test/tcm_misc.mdl",
    "models/surrounded/test/trials_executions.mdl",
    "models/surrounded/obj/QuestGenerator.mdl",
    "models/surrounded/obj/w_JerryCanBlue.mdl",
    "models/weapons/evildead_killer.mdl",
    "models/weapons/slasher_executions.mdl",
    "models/weapons/tcm_family.mdl",
    "models/slasher_victim.mdl",
    "models/tcm_victim.mdl",
    "models/evildead_killed.mdl",
    "models/exfil/mw22_crew_pm.mdl",
    "models/exfil/palfa.mdl",
    "models/surrounded/animations/evildead/evildead_killer_nmrih.mdl",
    "models/surrounded/animations/evildead/evildead_killed_nmrih.mdl",
}

for _, cat in pairs(SuR.Config.TierWeapons) do
    for _, class in pairs(cat) do
        local info = weapons.Get(class)
        if !info then continue end
        precache_tab[#precache_tab+1] = info.WorldModel
    end
end

local function precache_models(ply)
    if istable(ply) or IsValid(ply) then 
        net.Start("SuR.PrecacheModels")
        net.WriteTable(precache_tab)
        net.Send(ply)
    else
        for _, m in ipairs(precache_tab) do
            util.PrecacheModel(m)
        end
    end
end

hook.Add("PlayerInitialSpawn", "SuR.ErrorModels", function(ply)
    precache_models(ply)
end)

hook.Add("InitPostEntity", "SuR.Precache", precache_models)