-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_dependency.lua
More file actions
22 lines (22 loc) · 1.17 KB
/
server_dependency.lua
File metadata and controls
22 lines (22 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
local metadataKeys = { 'server_dependency', 'server_dependencie' --[[server_dependencies without s]] }
AddEventHandler('onResourceStarting', function (resource)
for _, metadataKey in ipairs(metadataKeys) do
for index = 0, GetNumResourceMetadata(resource, metadataKey) do
local dependencyResource = GetResourceMetadata(resource, metadataKey, index)
if not dependencyResource then goto nextIteration end
local dependencyState = GetResourceState(dependencyResource)
if dependencyState == "missing" then
print(("Could not find server dependency %s for resource %s."):format(dependencyResource, resource))
CancelEvent()
goto nextIteration
end
if not GetResourceMetadata(dependencyResource, 'server_only', 0) then
print(("^3%s is not a server-only resource, use dependency instead of server_dependency.^7"):format(dependencyResource))
end
if dependencyState ~= "started" and dependencyState ~= "starting" then
StartResource(dependencyResource)
end
::nextIteration::
end
end
end)