diff options
Diffstat (limited to 'gamemode/nrequire.lua')
| -rw-r--r-- | gamemode/nrequire.lua | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/gamemode/nrequire.lua b/gamemode/nrequire.lua index 702790c..d437a5e 100644 --- a/gamemode/nrequire.lua +++ b/gamemode/nrequire.lua @@ -179,12 +179,40 @@ local function doincludes() end end +local function refresh(filename) + local filepath = scan(ntbl,filename) + if filepath:match("/?sv_[%w_]+%.lua$") then + if SERVER then + reqtbl[filepath] = nil + nrequire(filepath) + end + elseif filepath:match("/?cl_[%w_]+%.lua$") then + if CLIENT then + reqtbl[filepath] = nil + nrequire(filepath) + end + else + reqtbl[filepath] = nil + nrequire(filepath) + end +end + doincludes() --Do it the first time through + +--Totaly refresh all files server and client side if SERVER then util.AddNetworkString("art_refresh") end if CLIENT then net.Receive("art_refresh",doincludes) end - concommand.Add("art_manualrefresh",function(ply,cmd,args) doincludes() net.Start("art_refresh") net.Broadcast() end) + +if SERVER then util.AddNetworkString("art_reffile") end +if CLIENT then net.Receive("art_reffile",function() refresh(net.ReadString()) end) end +concommand.Add("art_refreshfile", function(ply,cmd,args) + refresh(args[1]) + net.Start("art_reffile") + net.WriteString(args[1]) + net.Broadcast() +end) |
