mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
feat: isResourceStarted function
This commit is contained in:
28
shared/functions.lua
Normal file
28
shared/functions.lua
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
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"
|
||||||
|
startedResources[resourceName] = started
|
||||||
|
|
||||||
|
if cb then
|
||||||
|
callbacks[resourceName] = cb
|
||||||
|
cb(started)
|
||||||
|
end
|
||||||
|
|
||||||
|
return started
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user