refactor(init): throw an error if ox_lib is not started

This commit is contained in:
Linden
2022-03-10 15:54:13 +11:00
parent 55c32d91f4
commit 3c7cd3dc6b
3 changed files with 201 additions and 199 deletions

View File

@@ -23,7 +23,7 @@ game 'gta5'
--[[ Resource Information ]]-- --[[ Resource Information ]]--
name 'ox_lib' name 'ox_lib'
author 'Linden' author 'Linden'
version '2.0.1' version '2.0.2'
repository 'https://github.com/overextended/ox_lib' repository 'https://github.com/overextended/ox_lib'
description 'A library of shared functions to utilise in other resources.' description 'A library of shared functions to utilise in other resources.'

View File

@@ -1,7 +1,7 @@
local callback = {} local callback = {}
---@param name string ---@param name string
---@param callback function ---@param cb function
--- Registers an event handler and callback function to respond to client requests. --- Registers an event handler and callback function to respond to client requests.
function callback.register(name, cb) function callback.register(name, cb)
name = ('__cb_%s'):format(name) name = ('__cb_%s'):format(name)

View File

@@ -16,17 +16,19 @@
-- along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html> -- along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.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', 3) error('^1Lua 5.4 must be enabled in the resource manifest!^0', 2)
end
local lualib = 'ox_lib'
if not GetResourceState(lualib):find('start') then
error('^1ox_lib should be started before this resource^0', 2)
end end
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
-- Module -- Module
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
-- env
local lualib = 'ox_lib'
-- micro-optimise
local LoadResourceFile = LoadResourceFile local LoadResourceFile = LoadResourceFile
local file = IsDuplicityVersion() and 'server' or 'client' local file = IsDuplicityVersion() and 'server' or 'client'
local rawset = rawset local rawset = rawset