aboutsummaryrefslogtreecommitdiff
path: root/gamemode/core/pac
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2018-03-25 12:58:22 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2018-03-25 12:58:22 -0400
commit025ef8554016a2647f31244cf6413d80dba91847 (patch)
tree32280de04737bf4a90f96cfe3120c3fd10a06a76 /gamemode/core/pac
parent563f3e3960221fd9144e9adbde53c09392f772dd (diff)
downloadartery-025ef8554016a2647f31244cf6413d80dba91847.tar.gz
artery-025ef8554016a2647f31244cf6413d80dba91847.tar.bz2
artery-025ef8554016a2647f31244cf6413d80dba91847.zip
Fix #3
Allows pacs that have been loaded on join to be removed Also loads player data much sooner after the player spawns in.
Diffstat (limited to 'gamemode/core/pac')
-rw-r--r--gamemode/core/pac/cl_pac.lua18
-rw-r--r--gamemode/core/pac/sv_pac.lua10
2 files changed, 18 insertions, 10 deletions
diff --git a/gamemode/core/pac/cl_pac.lua b/gamemode/core/pac/cl_pac.lua
index 490ad31..477d65d 100644
--- a/gamemode/core/pac/cl_pac.lua
+++ b/gamemode/core/pac/cl_pac.lua
@@ -19,22 +19,28 @@ if pac == nil then
return --Don't execute this file!
end
-timer.Simple(0,function()
- net.Start("artery_getworldpacs")
- net.SendToServer()
-end)
-
local CLIENT_PAC_DIR = "artery/client/pacs"
file.CreateDir(CLIENT_PAC_DIR)
local function loadpac(ent,name,hash)
+ if (not ent) or (not ent:IsValid()) then
+ timer.Simple(1,function()
+ loadpac(ent,name,hash)
+ end)
+ return
+ end
print("Told to apply pac", name, "to ent", ent)
local filepath = string.format(CLIENT_PAC_DIR .. "/%s.txt",name)
local filetext = file.Read(filepath,"DATA")
if ent.AttachPACPart == nil then
pac.SetupENT(ent)
- assert(ent.AttachPACPart ~= nil,"Failed to set up ent",ent)
+ if ent.AttachPACPart == nil then
+ timer.Simple(1,function()
+ loadpac(ent,name,hash)
+ end)
+ return
+ end
end
if filetext and (tonumber(util.CRC(filetext)) == hash) then
print("The file on our local system is up to date, applying!")
diff --git a/gamemode/core/pac/sv_pac.lua b/gamemode/core/pac/sv_pac.lua
index 916430c..6c9a731 100644
--- a/gamemode/core/pac/sv_pac.lua
+++ b/gamemode/core/pac/sv_pac.lua
@@ -140,10 +140,12 @@ function p3.GetPacs(what)
end
--If a player joins the server, tell them all about the pacs that are applied
-net.Receive("artery_getworldpacs",function(ln,ply)
- net.Start("artery_giveworldpacs")
- net.WriteTable(appliedpacs)
- net.Send(ply)
+hook.Add("PlayerLoadout","send_world_pacs",function(ply)
+ timer.Simple(1,function()
+ net.Start("artery_giveworldpacs")
+ net.WriteTable(appliedpacs)
+ net.Send(ply)
+ end)
end)
local max_pacs_in_cache = 10