lua Auto inclusion

I wrote this script





strRootPath = string.Replace(GM.Folder, "gamemodes/", "")


function SearchPaths(originalPath, initial)
    initial = initial or false
    originalPath = originalPath .. "/"
    local files, directories = file.Find(originalPath .. "*", "lsv")
    if !initial then
        for _, strPath in pairs(files) do
            local prefix = string.sub(strPath, 1, 3)
            local correctedPath = string.gsub(originalPath .. strPath, strRootPath .. "/".. "gamemode/", "")


            print(correctedPath)


            if string.find(strPath, "sv_") then
                if SERVER then
                    include(correctedPath)
                end
            elseif string.find(strPath, "cl_") then
                if SERVER then
                    AddCSLuaFile("" .. correctedPath)
                    --print("AddCSLuaFile('"..correctedPath.."')")
                else
                    include(correctedPath)
                    --print("include('"..correctedPath.."')")        
                end
            else
                if SERVER then
                    include(correctedPath)
                    AddCSLuaFile("" .. correctedPath)
                    --print("AddCSLuaFile('"..correctedPath.."')")
                else
                    include(correctedPath)        
                    --print("include('"..correctedPath.."')")
                end
            end
        end
    end
    
    for _, strPath in pairs(directories) do
        SearchPaths(originalPath .. strPath)
    end
  
end
-- BEGINS THE INCLUDER
SearchPaths(strRootPath .. "/".. "gamemode", true)




But my clients aren’t downloading their correct lua files. I was wondering if there is an issue with AddCSLuaFile, or with how I am using it.

Thanks in advance

Hello Noobulater, log time no see.

Anyway, I see your debug is commented out, one would imagine that with debugging it is picking up the correct files for server-side and client side?

Also if you do a file.Exists on the file in question with that given path does it return true?

yea they work fine, I literally took the debug output code and ran it manually with AddCSFileLua and it worked.

-url die-