refactor: load file & moving 1 conf val

This commit is contained in:
Linventif 2024-02-16 15:22:50 +01:00
parent 40f7bb8079
commit 00880889bf
No known key found for this signature in database
GPG Key ID: FAC0CA60F9AEEC24
2 changed files with 34 additions and 26 deletions

View File

@ -1,23 +1,22 @@
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
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))
@ -34,32 +33,35 @@ local function loadConfig()
gmInte.config = oldConfig
end
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

View File

@ -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
//