Skip to content

Commit

Permalink
tweak(es)extended/client/callback): merging style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Mycroft-Studios committed Dec 3, 2024
1 parent a9a4ff6 commit d23b7ce
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions [core]/es_extended/client/modules/callback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,23 @@ function ESX.AwaitServerCallback(eventName, ...)
return table.unpack(p.value)
end

ESX.RegisterClientCallback = function(eventName, callback)
function ESX.RegisterClientCallback(eventName, callback)
local invokingResource = GetInvokingResource()
local invoker = (invokingResource and invokingResource ~= "Unknown") and invokingResource or "es_extended"

Callbacks:Register(eventName, invoker, callback)
end

---@param eventName string
---@return boolean
function ESX.DoesClientCallbackExist(eventName)
return Callbacks.storage[eventName] ~= nil
end

-- =============================================
-- MARK: Events
-- =============================================

ESX.SecureNetEvent("esx:triggerClientCallback", function(...)
Callbacks:ClientRecieve(...)
end)
Expand All @@ -124,12 +134,6 @@ ESX.SecureNetEvent("esx:serverCallback", function(...)
Callbacks:ServerRecieve(...)
end)

---@param eventName string
---@return boolean
function ESX.DoesClientCallbackExist(eventName)
return Callbacks.storage[eventName] ~= nil
end

AddEventHandler("onResourceStop", function(resource)
for k, v in pairs(Callbacks.storage) do
if v.resource == resource then
Expand Down

0 comments on commit d23b7ce

Please sign in to comment.