mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 23:46:03 +01:00
refactor(init): throw an error if ox_lib is not started
This commit is contained in:
@@ -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.'
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
12
init.lua
12
init.lua
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user