Skip to content

Commit

Permalink
refactor: error conditions and bridge compat (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
solareon authored Aug 14, 2024
1 parent c57386f commit 76f47ce
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
6 changes: 2 additions & 4 deletions bridge/qb/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ if GetConvar('qbx:enablebridge', 'true') == 'false' then return end
require 'bridge.qb.server.debug'
require 'bridge.qb.server.events'

CreateThread(function()
local convertItems = require 'bridge.qb.shared.compat'.convertItems
convertItems(require '@ox_inventory.data.items', require 'shared.items')
end)
local convertItems = require 'bridge.qb.shared.compat'.convertItems
convertItems(require '@ox_inventory.data.items', require 'shared.items')

qbCoreCompat = {}

Expand Down
7 changes: 5 additions & 2 deletions bridge/qb/shared/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ return {
file[fileSize+1] = '}'

SaveResourceFile('ox_inventory', 'data/items.lua', table.concat(file), -1)
print('^2[warning]^7 '..count..' items have been added to ox_inventory')
print('^2[warning]^7 You MUST restart the resource to load the new items.')
CreateThread(function()
Wait(1000)
print('^2[warning]^7 '..count..' items have been added to ox_inventory')
print('^2[warning]^7 You MUST restart the resource to load the new items.')
end)
end
end
}
17 changes: 16 additions & 1 deletion server/main.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
lib.versionCheck('Qbox-project/qbx_core')
assert(lib.checkDependency('ox_lib', '3.20.0', true))
local startupErrors, errorMessage
if not lib.checkDependency('ox_lib', '3.20.0', true) then
startupErrors, errorMessage = true, 'ox_lib version 3.20.0 or higher is required'
elseif not lib.checkDependency('ox_inventory', '2.42.0', true) then
startupErrors, errorMessage = true, 'ox_inventory version 2.42.0 or higher is required'
elseif GetConvar('inventory:framework', '') ~= 'qbx' then
startupErrors, errorMessage = true, 'inventory:framework must be set to "qbx" in order to use qbx_core'
end
if startupErrors then
lib.print.error('Startup errors detected, shutting down server...')
ExecuteCommand('quit immediately')
for _ = 1, 100 do
lib.print.error(errorMessage)
end
error(errorMessage)
end

---@type 'strict'|'relaxed'|'inactive'
local bucketLockDownMode = GetConvar('qbx:bucketlockdownmode', 'inactive')
Expand Down

0 comments on commit 76f47ce

Please sign in to comment.