Files
ND_Core/shared/functions.lua
2023-07-12 04:53:18 +02:00

27 lines
729 B
Lua

local startedResources = {}
local callbacks = {}
AddEventHandler("onResourceStart", function(resourceName)
startedResources[resourceName] = true
local callback = callbacks[resourceName]
if not callback then return end
callback(true)
end)
AddEventHandler("onResourceStop", function(resourceName)
startedResources[resourceName] = nil
local callback = callbacks[resourceName]
if not callback then return end
callback(false)
end)
function NDCore.isResourceStarted(resourceName, cb)
local started = GetResourceState(resourceName) == "started"
if cb then
startedResources[resourceName] = started
callbacks[resourceName] = cb
cb(started)
end
return started
end