Drawtext UI
Step by step installation guide, common issues & solutions, troubleshooting guide, code snippets, common error codes, config previews, locales previews and changelogs; all in 1 easily accessible place

Translate

INSTALLATION GUIDE

1. Unzip the cd_drawtextui.zip folder and place this folder in your servers resource folder.
2. Add the resource to your server start config: ensure cd_drawtextui. The name of the folder must not be changed or the resource will not function correctly.

How to use it?

  • This can be triggered from the server or client. But this is a client event.
  • Multiple examples are posted below, choose one best suited to your experience level. The easiest way for you to implement this into your resource's, would be to use one of the examples below as a template and copy and paste your code into it.
Show the UI
Hide the UI
TriggerEvent('cd_drawtextui:ShowUI', 'show', TEXT_HERE)
TriggerEvent('cd_drawtextui:HideUI')
Example 1 : This is how to implement the UI for a single location.
1
Citizen.CreateThread(function()
2
local alreadyEnteredZone = false
3
local text = '<b>Title</b></p>[E] Press E to be bald'
4
while true do
5
wait = 5
6
local ped = PlayerPedId()
7
local inZone = false
8
local dist = #(GetEntityCoords(ped)-vector3(0,0,0))
9
if dist <= 5.0 then
10
wait = 5
11
inZone = true
12
13
if IsControlJustReleased(0, 38) then
14
TriggerEvent('add your event here')
15
end
16
else
17
wait = 1000
18
end
19
20
if inZone and not alreadyEnteredZone then
21
alreadyEnteredZone = true
22
TriggerEvent('cd_drawtextui:ShowUI', 'show', text)
23
end
24
25
if not inZone and alreadyEnteredZone then
26
alreadyEnteredZone = false
27
TriggerEvent('cd_drawtextui:HideUI')
28
end
29
Citizen.Wait(wait)
30
end
31
end)
Copied!
Example 2 : This is how to implement the UI while doing a for loop for multiple locations in 1 thread.
1
Config = {}
2
Config.Example = {
3
[1] = vector3(1.1, 1.1, 1.1),
4
[2] = vector3(2.2, 2.2, 2.2),
5
[3] = vector3(3.3, 3.3, 3.3),
6
}
7
8
Citizen.CreateThread(function()
9
local alreadyEnteredZone = false
10
local text = '<b>Title</b></p>[E] Press E to be bald'
11
while true do
12
wait = 5
13
local ped = PlayerPedId()
14
local inZone = false
15
for cd = 1, #Config.Example do
16
local dist = #(GetEntityCoords(ped)-vector3(Config.Example[cd].x, Config.Example[cd].y, Config.Example[cd].z))
17
if dist <= 5.0 then
18
wait = 5
19
inZone = true
20
21
if IsControlJustReleased(0, 38) then
22
TriggerEvent('add your event here')
23
end
24
break
25
else
26
wait = 2000
27
end
28
end
29
30
if inZone and not alreadyEnteredZone then
31
alreadyEnteredZone = true
32
TriggerEvent('cd_drawtextui:ShowUI', 'show', text)
33
end
34
35
if not inZone and alreadyEnteredZone then
36
alreadyEnteredZone = false
37
TriggerEvent('cd_drawtextui:HideUI')
38
end
39
Citizen.Wait(wait)
40
end
41
end)
Copied!
Example 3 : This is a more advanced method of the example 2 above. This is more customisable and can handle all of the keypresses in said resource in a single thread.
1
Config = {}
2
Config.Example = {
3
[1] = {coords = vector3(1.1, 1.1, 1.1), distance = 5, key = 38, eventname = 'example:testevent', text = '<b>Title</b></p>[E] Press E to be bald'},
4
[2] = {coords = vector3(2.2, 2.2, 2.2), distance = 5, key = 47, eventname = 'example:testevent', text = '<b>Title</b></p>[E] Press E to be bald'},
5
[3] = {coords = vector3(3.3, 3.3, 3.3), distance = 5, key = 74, eventname = 'example:testevent', text = '<b>Title</b></p>[E] Press E to be bald'},
6
}
7
8
Citizen.CreateThread(function()
9
local alreadyEnteredZone = false
10
local text = nil
11
while true do
12
wait = 5
13
local ped = PlayerPedId()
14
local inZone = false
15
for cd = 1, #Config.Example do
16
local dist = #(GetEntityCoords(ped)-vector3(Config.Example[cd].coords.x, Config.Example[cd].coords.y, Config.Example[cd].coords.z))
17
if dist <= Config.Example[cd].distance then
18
wait = 5
19
inZone = true
20
text = Config.Example[cd].text
21
22
if IsControlJustReleased(0, Config.Example[cd].key) then
23
TriggerEvent(Config.Example[cd].eventname)
24
end
25
break
26
else
27
wait = 2000
28
end
29
end
30
31
if inZone and not alreadyEnteredZone then
32
alreadyEnteredZone = true
33
TriggerEvent('cd_drawtextui:ShowUI', 'show', text)
34
end
35
36
if not inZone and alreadyEnteredZone then
37
alreadyEnteredZone = false
38
TriggerEvent('cd_drawtextui:HideUI')
39
end
40
Citizen.Wait(wait)
41
end
42
end)
Copied!

Is the resource not working as expected?

  • Make sure the name of the folder is cd_drawtextui.
  • Check the server console and the in-game F8 console for errors.
  • If all else fails, contact the Codesign Team in the Codesign Discord.