Skip to content

Commit

Permalink
refactor(init): add deferral for breaking errors
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Jul 6, 2023
1 parent 92ceb05 commit f57ee4c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
-- It takes a lot of skill to ignore the error telling you why lib is undefined.
-- Some people are that skilled. By skilled I mean blind and oblivious.
if not lib then return end
local function addDeferral(err)
err = err:gsub("%^%d", "")

lib.locale()
AddEventHandler('playerConnecting', function(_, _, deferrals)
deferrals.defer()
deferrals.done(err)
end)
end

-- Do not modify this file at all. This isn't a "config" file. You want to change
-- resource settings? Use convars like you were told in the documentation.
Expand Down Expand Up @@ -116,16 +119,18 @@ end

-- People like ignoring errors for some reason
local function spamError(err)
lib = nil
shared.ready = false

CreateThread(function()
while true do
Wait(2000)
Wait(10000)
CreateThread(function()
error(err, 0)
end)
end
end)

addDeferral(err)
error(err, 0)
end

Expand Down Expand Up @@ -174,6 +179,8 @@ if not lib then
return spamError('ox_inventory requires the ox_lib resource, refer to the documentation.')
end

lib.locale()

local success, msg = lib.checkDependency('oxmysql', '2.7.2')

if not success then return spamError(msg) end
Expand Down

0 comments on commit f57ee4c

Please sign in to comment.