-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.lua
84 lines (70 loc) · 2.14 KB
/
main.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
local QBCore = exports['qb-core']:GetCoreObject()
local isDisplaying = false
local currentIndex = 1
RegisterNUICallback('getConfig', function(data, cb)
cb({
style = Config.Style
})
end)
local function ShowInfoBar()
Citizen.CreateThread(function()
while true do
if not isDisplaying and Config.Messages and #Config.Messages > 0 then
isDisplaying = true
if currentIndex > #Config.Messages then
currentIndex = 1
end
local message = Config.Messages[currentIndex]
SendNUIMessage({
type = 'showMessage',
text = message.text,
scrollSpeed = message.scrollSpeed or 180
})
Citizen.Wait(message.pause or 2000)
currentIndex = currentIndex + 1
isDisplaying = false
end
Citizen.Wait(50)
end
end)
end
RegisterNUICallback('scrollComplete', function(data, cb)
isDisplaying = false
cb('ok')
end)
RegisterNUICallback('enableNUI', function(data, cb)
SetNuiFocus(true, true)
cb('ok')
end)
RegisterCommand('infob', function(_, _, _)
SetNuiFocus(true, true)
SendNUIMessage({
type = 'toggleMove',
state = true
})
end, false)
Citizen.CreateThread(function()
ShowInfoBar()
end)
RegisterNUICallback('disableNUI', function(data, cb)
SetNuiFocus(false, false)
cb('ok')
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Wait(10000)
ShowInfoBar()
end)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
LocalPlayer.state:set('isLoggedIn', false, false)
isDisplaying = false
end)
AddEventHandler('onResourceStart', function(resourceName)
if GetCurrentResourceName() ~= resourceName then return end
if LocalPlayer.state['isLoggedIn'] then
ShowInfoBar()
end
end)
AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() ~= resourceName then return end
isDisplaying = false
end)