fix(init): prevent loading multiple instances of ox_lib

Resolves #545.
This commit is contained in:
Linden
2024-04-11 15:03:41 +10:00
parent e0e2bcfd45
commit 3e66dccb4b

View File

@@ -4,7 +4,7 @@
---LGPL-3.0-or-later <https://www.gnu.org/licenses/lgpl-3.0.en.html> ---LGPL-3.0-or-later <https://www.gnu.org/licenses/lgpl-3.0.en.html>
if not _VERSION:find('5.4') then if not _VERSION:find('5.4') then
error('^1Lua 5.4 must be enabled in the resource manifest!^0', 2) error('Lua 5.4 must be enabled in the resource manifest!', 2)
end end
local resourceName = GetCurrentResourceName() local resourceName = GetCurrentResourceName()
@@ -13,6 +13,10 @@ local ox_lib = 'ox_lib'
-- Some people have decided to load this file as part of ox_lib's fxmanifest? -- Some people have decided to load this file as part of ox_lib's fxmanifest?
if resourceName == ox_lib then return end if resourceName == ox_lib then return end
if lib and lib.name == ox_lib then
error(("Cannot load ox_lib more than once.\n\tRemove any duplicate entries from '@%s/fxmanifest.lua'"):format(resourceName))
end
local export = exports[ox_lib] local export = exports[ox_lib]
if GetResourceState(ox_lib) ~= 'started' then if GetResourceState(ox_lib) ~= 'started' then