Compare commits
3 Commits
136847609f
...
88b07a6194
Author | SHA1 | Date | |
---|---|---|---|
88b07a6194 | |||
79b0f2d2ac | |||
a45536aeab |
@ -1,17 +1,7 @@
|
||||
utils = include("sv_utils.lua")
|
||||
config = include("../sh_config.lua")
|
||||
|
||||
local dirs = utils.split(config.config_path, "/")
|
||||
table.remove(dirs)
|
||||
local tmp = "";
|
||||
for i, dir in ipairs(dirs) do
|
||||
tmp = tmp .. dir
|
||||
if not file.Exists(tmp, "DATA")
|
||||
then
|
||||
file.CreateDir(tmp)
|
||||
end
|
||||
tmp = tmp .. "/"
|
||||
end
|
||||
utils.path_create(config.config_path)
|
||||
|
||||
if not file.Exists(config.config_path, "DATA")
|
||||
then
|
||||
|
14
lua/autorun/server/sv_hook.lua
Normal file
14
lua/autorun/server/sv_hook.lua
Normal file
@ -0,0 +1,14 @@
|
||||
config = include("../sh_config.lua")
|
||||
|
||||
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 default = {}
|
||||
default.diseases = {}
|
||||
file.Write(file_path, util.TableToJSON(default, true))
|
||||
end
|
||||
local data = file.Read(file_path)
|
||||
ply.diseases = util.JSONToTable(data)
|
||||
end)
|
4
lua/autorun/server/sv_saves.lua
Normal file
4
lua/autorun/server/sv_saves.lua
Normal file
@ -0,0 +1,4 @@
|
||||
utils = include("sv_utils.lua")
|
||||
config = include("../sh_config.lua")
|
||||
|
||||
utils.path_create(config.save_path .. "/ss")
|
18
lua/autorun/server/sv_symbtom.lua
Normal file
18
lua/autorun/server/sv_symbtom.lua
Normal file
@ -0,0 +1,18 @@
|
||||
Symbtom = {}
|
||||
|
||||
--- Disease class
|
||||
---@param side name string? the name of the symbtom (string)
|
||||
---@param side func function? the function called when symbtom
|
||||
---@param side delay number? delay time between two symbtoms
|
||||
---@param side level float? the level of the symbtom (between 0-1)
|
||||
function Symbtom:new(name, func, level, delay)
|
||||
local instance = {}
|
||||
setmetatable(instance, {__index = Disease})
|
||||
instance.name = name
|
||||
instance.func = func
|
||||
instance.level = level
|
||||
instance.delay = delay
|
||||
return instance
|
||||
end
|
||||
|
||||
return Symbtom
|
@ -1 +0,0 @@
|
||||
Symbtoms_list = {}
|
@ -8,4 +8,21 @@ function utils.split (str, sep)
|
||||
return new_table
|
||||
end
|
||||
|
||||
function utils.path_create(path)
|
||||
|
||||
local dirs = utils.split(path, "/")
|
||||
table.remove(dirs)
|
||||
local tmp = "";
|
||||
for i, dir in ipairs(dirs) do
|
||||
tmp = tmp .. dir
|
||||
print(tmp)
|
||||
if not file.Exists(tmp, "DATA")
|
||||
then
|
||||
file.CreateDir(tmp)
|
||||
end
|
||||
tmp = tmp .. "/"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return utils
|
@ -1,10 +1,11 @@
|
||||
include("autorun/server/sv_symbtoms.lua")
|
||||
symbtoms_list = include("sv_symbtoms.lua")
|
||||
|
||||
table.insert(Symbtoms_list, "cough" = cough_func)
|
||||
table.insert(symbtoms_list, "cough" = cough)
|
||||
|
||||
--- Send a packet to trigger cough animation to the player
|
||||
---@param side UID64 string? UID64 of the player
|
||||
---@param side level float? A float between 0 and 1
|
||||
---@return void
|
||||
function cough(UID64)
|
||||
function cough(UID64, level)
|
||||
|
||||
end
|
3
lua/autorun/server/symptoms/sv_symbtoms.lua
Normal file
3
lua/autorun/server/symptoms/sv_symbtoms.lua
Normal file
@ -0,0 +1,3 @@
|
||||
symbtoms_list = {}
|
||||
|
||||
return symbtoms_list
|
11
lua/autorun/server/symptoms/sv_vomit.lua
Normal file
11
lua/autorun/server/symptoms/sv_vomit.lua
Normal file
@ -0,0 +1,11 @@
|
||||
symbtoms_list = include("sv_symbtoms.lua")
|
||||
|
||||
table.insert(symbtoms_list, "vomit" = vomit)
|
||||
|
||||
--- Send a packet to trigger cough animation to the player
|
||||
---@param side UID64 string? UID64 of the player
|
||||
---@param side level float? A float between 0 and 1
|
||||
---@return void
|
||||
function vomit(UID64, level)
|
||||
|
||||
end
|
@ -3,4 +3,6 @@ config = {}
|
||||
-- the config file path location
|
||||
config.config_path = "disease/config.json"
|
||||
|
||||
config.save_path = "disease/saves"
|
||||
|
||||
return config
|
Loading…
Reference in New Issue
Block a user