From 499d1d00ef95807bc0834363ab98dfbd7284894a Mon Sep 17 00:00:00 2001 From: Lorraxs Date: Sun, 10 Dec 2023 04:56:28 +0700 Subject: [PATCH] Update impl.lua --- impl.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/impl.lua b/impl.lua index 134c896..24ce5b9 100644 --- a/impl.lua +++ b/impl.lua @@ -114,11 +114,18 @@ end function Impl:Destroy() self.destroyed = true main:LogInfo("%s destroyed", self.name) + for k, v in pairs(self.eventHandlers) do + RemoveEventHandler(v) + end + self:OnDestroy() end function Impl:OnReady(...) end +function Impl:OnDestroy(...) +end + function Impl:HookMethod(method, hookFn) local oldMethod = self[method] if not oldMethod then @@ -196,6 +203,14 @@ function Impl:Off(name, handler) main:LogError("Event %s:%s not registered", self.name, name) end +function Impl:AddEventHandler(eventName, ...) + self.eventHandlers[eventName] = AddEventHandler(eventName, ...) +end + +function Impl:RegisterNetEvent(eventName, ...) + self.eventHandlers[eventName] = RegisterNetEvent(eventName, ...) +end + if env == 'sv' then function Impl:Callback(impl, name, source, ...) if type(impl) == "object" then