From 025ef8554016a2647f31244cf6413d80dba91847 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sun, 25 Mar 2018 12:58:22 -0400 Subject: Fix #3 Allows pacs that have been loaded on join to be removed Also loads player data much sooner after the player spawns in. --- gamemode/core/pac/cl_pac.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'gamemode/core/pac/cl_pac.lua') 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!") -- cgit v1.2.3-70-g09d2