51 lines
1.3 KiB
Lua
51 lines
1.3 KiB
Lua
settings = include("../sv_settings.lua")
|
|
config = include("../sv_config.lua")
|
|
infect = include("../sv_infect.lua")
|
|
|
|
util.AddNetworkString("get_diseases_name")
|
|
util.AddNetworkString("get_players_data")
|
|
util.AddNetworkString("infect")
|
|
|
|
net.Receive("get_diseases_name", function (len, ply)
|
|
local name_list = {}
|
|
for i, disease in ipairs(settings.diseases)
|
|
do
|
|
table.insert(name_list, disease.name)
|
|
end
|
|
net.Start("get_diseases_name")
|
|
net.WriteTable(name_list)
|
|
net.Send(ply)
|
|
end)
|
|
|
|
net.Receive("get_players_data", function (len, ply)
|
|
local files, _ = file.Find(config.save_path .. "*", "DATA")
|
|
local data = {}
|
|
for i, file_ in ipairs(files)
|
|
do
|
|
local ply_data = util.JSONToTable(file.Read(config.save_path .. file_))
|
|
local ret = {}
|
|
local ply = player.GetBySteamID64(ply_data.SteamID64)
|
|
if ply == false
|
|
then
|
|
ret.nick = ply_data.name
|
|
else
|
|
ret.nick = ply:Nick()
|
|
end
|
|
ret.SteamID64 = ply_data.SteamID64
|
|
table.insert(data, ret)
|
|
end
|
|
net.Start("get_players_data")
|
|
net.WriteTable(data)
|
|
net.Send(ply)
|
|
end)
|
|
|
|
net.Receive("infect", function (len, ply)
|
|
local data = net.ReadTable()
|
|
for _, infected in ipairs(data.infecteds)
|
|
do
|
|
print("1")
|
|
infect(infected, data.diseases)
|
|
end
|
|
end)
|
|
|
|
print("bozo") |