-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhelper.lua
53 lines (43 loc) · 1.13 KB
/
helper.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Migrant = {}
local isMigrantReady = false
local callbackDictionary = {}
local callbackConsumed = {}
local function isBothReady()
return isMigrantReady and (MySQL and isMySQLReady or true)
end
local function checkReady()
if isBothReady() then
for i, cb in ipairs(callbackDictionary) do
if not callbackConsumed[i] then
callbackConsumed[i] = true
cb()
end
end
end
end
AddEventHandler('fxmigrant:resourceDone', function(resourceName, success)
if resourceName == GetCurrentResourceName() then
isMigrantReady = true
checkReady()
end
end)
function Migrant.ready (callback)
if MySQL then
MySQL.ready(function()
isMySQLReady = true
checkReady()
end)
if exports['fxmigrant']:hasTicked() then
SetTimeout(150, function()
isMySQLReady = true
checkReady()
end)
end
end
if isBothReady() then
callback()
else
table.insert(callbackDictionary, callback)
table.insert(callbackConsumed, false)
end
end