forked from qbcore-framework/qb-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawtext.lua
60 lines (50 loc) · 1.29 KB
/
drawtext.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
local function hideText()
SendNUIMessage({
action = 'HIDE_TEXT',
})
end
local function drawText(text, position)
if type(position) ~= "string" then position = "left" end
SendNUIMessage({
action = 'DRAW_TEXT',
data = {
text = text,
position = position
}
})
end
local function changeText(text, position)
if type(position) ~= "string" then position = "left" end
SendNUIMessage({
action = 'CHANGE_TEXT',
data = {
text = text,
position = position
}
})
end
local function keyPressed()
CreateThread(function() -- Not sure if a thread is needed but why not eh?
SendNUIMessage({
action = 'KEY_PRESSED',
})
Wait(500)
hideText()
end)
end
RegisterNetEvent('qb-core:client:DrawText', function(text, position)
drawText(text, position)
end)
RegisterNetEvent('qb-core:client:ChangeText', function(text, position)
changeText(text, position)
end)
RegisterNetEvent('qb-core:client:HideText', function()
hideText()
end)
RegisterNetEvent('qb-core:client:KeyPressed', function()
keyPressed()
end)
exports('DrawText', drawText)
exports('ChangeText', changeText)
exports('HideText', hideText)
exports('KeyPressed', keyPressed)