lua/lua/autorun/gmod_integration.lua

94 lines
3.3 KiB
Lua
Raw Normal View History

2023-09-09 11:21:14 +00:00
if game.SinglePlayer() then return end
2023-08-09 05:04:43 +00:00
//
// Variables
//
2023-09-26 17:10:46 +00:00
gmInte = {}
2024-01-15 03:40:41 +00:00
gmInte.version = "0.2.1"
2023-12-16 12:42:40 +00:00
gmInte.config = {
["redownloadMaterials"] = false,
}
gmInte.materials = {}
2023-08-09 05:04:43 +00:00
//
2023-09-20 13:15:20 +00:00
// Functions
2023-08-09 05:04:43 +00:00
//
2023-09-26 16:07:20 +00:00
local function loadConfig()
if (SERVER) then
print(" | Loading File | gmod_integration/sv_config.lua")
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
2023-09-26 17:10:46 +00:00
if (oldConfig.version && (oldConfig.version < "0.1.2")) then
2023-09-26 16:07:20 +00:00
gmInte.config.id = oldConfig.id
gmInte.config.token = oldConfig.token
else
2023-09-26 17:10:46 +00:00
print(" | Merging Config | gmod_integration/sv_config.lua")
2023-09-26 16:07:20 +00:00
table.Merge(gmInte.config, oldConfig)
end
gmInte.config.version = gmInte.version
file.Write("gm_integration/config.json", util.TableToJSON(gmInte.config, true))
else
gmInte.config = oldConfig
end
end
end
end
2023-09-20 13:15:20 +00:00
local function loadAllFiles(folder)
local files, folders = file.Find(folder .. "/*", "LUA")
for k, v in SortedPairs(files) do
local path = folder .. "/" .. v
2023-09-23 12:44:26 +00:00
print(" | Loading File | " .. path)
2023-09-20 13:15:20 +00:00
if string.StartWith(v, "cl_") then
if SERVER then
AddCSLuaFile(path)
else
include(path)
end
elseif string.StartWith(v, "sv_") then
if SERVER then
include(path)
end
elseif string.StartWith(v, "sh_") then
if SERVER then
AddCSLuaFile(path)
end
include(path)
end
2023-09-27 01:05:08 +00:00
if (path == "gmod_integration/sv_config.lua") then loadConfig() continue end
2023-09-20 13:15:20 +00:00
end
for k, v in SortedPairs(folders, true) do
loadAllFiles(folder .. "/" .. v, name)
end
end
2023-08-09 05:04:43 +00:00
2023-09-26 16:07:20 +00:00
2023-09-20 13:15:20 +00:00
//
// Load Files
//
2023-08-09 05:04:43 +00:00
2023-09-20 13:15:20 +00:00
print(" ")
print(" ")
print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ")
print(" - - ")
print(" - Gmod Integration v" .. gmInte.version .. " - ")
print(" - - ")
print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ")
print(" - - ")
print(" - Thanks for using Gmod Integration ! - ")
print(" - If you have any questions, please contact us on Discord! - ")
print(" - https://gmod-integration.com/discord - ")
print(" - - ")
print(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ")
print(" ")
loadAllFiles("gmod_integration")
2023-09-26 16:07:20 +00:00
print(" ")