mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-16 21:46:03 +01:00
Merge branch 'main' into wip-2.0.0
This commit is contained in:
1
shared/import.lua
Normal file
1
shared/import.lua
Normal file
@@ -0,0 +1 @@
|
||||
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||
30
shared/main.lua
Normal file
30
shared/main.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
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 isResourceStarted(resourceName, cb)
|
||||
local started = GetResourceState(resourceName) == "started"
|
||||
startedResources[resourceName] = started
|
||||
|
||||
if cb then
|
||||
callbacks[resourceName] = cb
|
||||
cb(started)
|
||||
end
|
||||
|
||||
return started
|
||||
end
|
||||
|
||||
exports("isResourceStarted", isResourceStarted)
|
||||
Reference in New Issue
Block a user