diff --git a/lua/autorun/gmod_integration.lua b/lua/autorun/gmod_integration.lua index 4be2ce5..e5ea6ee 100644 --- a/lua/autorun/gmod_integration.lua +++ b/lua/autorun/gmod_integration.lua @@ -1,65 +1,67 @@ -if game.SinglePlayer() then return end +if (game.SinglePlayer()) then return print("Gmod Integration is not supported in Singleplayer!") end // // Variables // gmInte = gmInte || {} + gmInte.version = "0.3.0" -gmInte.config = gmInte.config || { - ["redownloadMaterials"] = false, -} +gmInte.config = {} gmInte.materials = {} // // Functions // -local function loadConfig() - if (SERVER) then - RunConsoleCommand("sv_hibernate_think", "1") - if (!file.Exists("gm_integration", "DATA") || !file.Exists("gm_integration/config.json", "DATA")) then - file.CreateDir("gm_integration") +local function loadServerConfig() + RunConsoleCommand("sv_hibernate_think", "1") + + if (!file.Exists("gm_integration", "DATA") || !file.Exists("gm_integration/config.json", "DATA")) then + file.CreateDir("gm_integration") + file.Write("gm_integration/config.json", util.TableToJSON(gmInte.config, true)) + else + if (gmInte.config.id && gmInte.config.id != "") then return end + + local oldConfig = util.JSONToTable(file.Read("gm_integration/config.json", "DATA")) + if (!oldConfig.version || (oldConfig.version < gmInte.version)) then + print(" | Merging Config | gmod_integration/sv_config.lua") + table.Merge(gmInte.config, oldConfig) + gmInte.config.version = gmInte.version file.Write("gm_integration/config.json", util.TableToJSON(gmInte.config, true)) else - if (gmInte.config.id && gmInte.config.id != "") then return end - - local oldConfig = util.JSONToTable(file.Read("gm_integration/config.json", "DATA")) - if (!oldConfig.version || (oldConfig.version < gmInte.version)) then - print(" | Merging Config | gmod_integration/sv_config.lua") - table.Merge(gmInte.config, oldConfig) - gmInte.config.version = gmInte.version - file.Write("gm_integration/config.json", util.TableToJSON(gmInte.config, true)) - else - gmInte.config = oldConfig - end + gmInte.config = oldConfig end end end local function loadAllFiles(folder) local files, folders = file.Find(folder .. "/*", "LUA") - for k, v in SortedPairs(files) do - local path = folder .. "/" .. v + + for k, fileName in SortedPairs(files) do + local path = folder .. "/" .. fileName print(" | Loading File | " .. path) - if string.StartWith(v, "cl_") then + + if (string.StartWith(fileName, "cl_")) then if SERVER then AddCSLuaFile(path) else include(path) end - elseif string.StartWith(v, "sv_") then + elseif (string.StartWith(fileName, "sv_")) then if SERVER then include(path) end - elseif string.StartWith(v, "sh_") then + elseif (string.StartWith(fileName, "sh_")) then if SERVER then AddCSLuaFile(path) end include(path) end - if (path == "gmod_integration/sv_config.lua") then loadConfig() continue end + + if (fileName == "sv_config.lua") then loadServerConfig() continue end end + for k, v in SortedPairs(folders, true) do loadAllFiles(folder .. "/" .. v, name) end diff --git a/lua/gmod_integration/sv_config.lua b/lua/gmod_integration/sv_config.lua index b365912..a578054 100644 --- a/lua/gmod_integration/sv_config.lua +++ b/lua/gmod_integration/sv_config.lua @@ -70,6 +70,12 @@ gmInte.config.filterOnBan = true // If true, the addon will filter the players a // Will disable the features of the addon gmInte.config.sendLog = false // Disable the logs +// +// Materials +// + +gmInte.config.redownloadMaterials = false // If true, the addon will redownload the materials of the addon (useful if you have a problem with the materials) + // // Debug & Development //