From a22cbeddc5f8fb61e87a30aa14ba354de5cf4431 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sat, 18 Feb 2017 21:55:55 -0500 Subject: Updates --- gamemode/nrequire.lua | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'gamemode/nrequire.lua') 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) -- cgit v1.2.3-70-g09d2