Skip to content

Commit ed36ae4

Browse files
committed
Use the upcoming GM:OnDuplicated hook.
Removes the need for the "OnEntityCreated" hack. Requires these pull request to be merged: - Facepunch/garrysmod#2408 - wiremod/advdupe2#528
1 parent bacfa0a commit ed36ae4

1 file changed

Lines changed: 2 additions & 16 deletions

File tree

lua/sligwolf_addons/base_library/duplicator.lua

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,34 +240,20 @@ function LIB.Load()
240240
LIBMeta = SligWolf_Addons.Meta
241241

242242
if SERVER then
243-
local function onDuplicated(ent, ...)
243+
local function OnDuplicated(ent, ...)
244244
if not IsValid(ent) then return end
245245

246246
local entTable = ent:SligWolf_GetTable()
247-
local oldOnDuplicated = entTable._oldOnDuplicated
248247

249248
entTable.isDuped = true
250249

251-
if isfunction(oldOnDuplicated) then
252-
oldOnDuplicated(ent, ...)
253-
end
254-
255250
local swOnDuplicated = entTable.OnDuplicated
256251
if isfunction(swOnDuplicated) then
257252
swOnDuplicated(ent, ...)
258253
end
259254
end
260255

261-
local function OnEntityCreated(ent)
262-
if not IsValid(ent) then return end
263-
264-
local entTable = ent:SligWolf_GetTable()
265-
entTable._oldOnDuplicated = entTable._oldOnDuplicated or ent.OnDuplicated
266-
267-
ent.OnDuplicated = onDuplicated
268-
end
269-
270-
LIBHook.Add("OnEntityCreated", "Library_Duplicator_OnEntityCreated", OnEntityCreated, 1000)
256+
LIBHook.Add("OnDuplicated", "Library_Duplicator_OnDuplicated", OnDuplicated, 1000)
271257
end
272258
end
273259

0 commit comments

Comments
 (0)