GMOD_disease/lua/autorun/server/sv_saves.lua
camille lechauve 4f255b2f43 core: rebuild infect function
fix: a disease cannot be add in multiple time
2023-09-14 19:23:54 +02:00

22 lines
722 B
Lua

utils = include("sv_utils.lua")
config = include("sv_config.lua")
settings = include("sv_settings.lua")
utils.path_create(config.save_path .. "/ss")
hook.Add("PlayerInitialSpawn", "reAddDisease", function (ply)
local file_path = config.save_path .. ply:SteamID64() .. ".json"
print(file_path)
if not file.Exists(file_path, "DATA")
then
local data = {}
data.diseases = {}
data.SteamID64 = ply:SteamID64()
data.name = ply:Nick()
file.Write(file_path, util.TableToJSON(data, true))
end
local data = util.JSONToTable(file.Read(file_path))
data.name = ply:Nick()
file.Write(file_path, util.TableToJSON(data, true))
ply.diseases = data.diseases
end)