Skip to content
This repository was archived by the owner on Apr 19, 2025. It is now read-only.

Commit f57ee4c

Browse files
committed
refactor(init): add deferral for breaking errors
1 parent 92ceb05 commit f57ee4c

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

init.lua

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
-- It takes a lot of skill to ignore the error telling you why lib is undefined.
2-
-- Some people are that skilled. By skilled I mean blind and oblivious.
3-
if not lib then return end
1+
local function addDeferral(err)
2+
err = err:gsub("%^%d", "")
43

5-
lib.locale()
4+
AddEventHandler('playerConnecting', function(_, _, deferrals)
5+
deferrals.defer()
6+
deferrals.done(err)
7+
end)
8+
end
69

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

117120
-- People like ignoring errors for some reason
118121
local function spamError(err)
119-
lib = nil
120122
shared.ready = false
123+
121124
CreateThread(function()
122125
while true do
123-
Wait(2000)
126+
Wait(10000)
124127
CreateThread(function()
125128
error(err, 0)
126129
end)
127130
end
128131
end)
132+
133+
addDeferral(err)
129134
error(err, 0)
130135
end
131136

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

182+
lib.locale()
183+
177184
local success, msg = lib.checkDependency('oxmysql', '2.7.2')
178185

179186
if not success then return spamError(msg) end

0 commit comments

Comments
 (0)