1. Unzip the cd_drawtextui.zip folder and place this folder in your server's 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 resources would be to use one of the examples below as a template and copy and paste your code into it.
Example 1 : This is how to implement the UI for a single location.
Citizen.CreateThread(function()local alreadyEnteredZone =falselocal text ='<b>Title</b></p>[E] Press E to be bald'whiletruedo wait =5local ped = PlayerPedId()local inZone =falselocal dist =#(GetEntityCoords(ped)-vector3(0,0,0))if dist <=5.0then wait =5 inZone =trueif IsControlJustReleased(0, 38) then TriggerEvent('add your event here')endelse wait =1000endif inZone andnot alreadyEnteredZone then alreadyEnteredZone =true TriggerEvent('cd_drawtextui:ShowUI', 'show', text)endifnot inZone and alreadyEnteredZone then alreadyEnteredZone =false TriggerEvent('cd_drawtextui:HideUI')end Citizen.Wait(wait)endend)
Example 2 : This is how to implement the UI while doing a for loop for multiple locations in 1 thread.
Config = {}Config.Example = { [1] = vector3(1.1, 1.1, 1.1), [2] = vector3(2.2, 2.2, 2.2), [3] = vector3(3.3, 3.3, 3.3),}Citizen.CreateThread(function()local alreadyEnteredZone =falselocal text ='<b>Title</b></p>[E] Press E to be bald'whiletruedo wait =5local ped = PlayerPedId()local inZone =falsefor cd =1, #Config.Example dolocal dist =#(GetEntityCoords(ped)-vector3(Config.Example[cd].x, Config.Example[cd].y, Config.Example[cd].z))if dist <=5.0then wait =5 inZone =trueif IsControlJustReleased(0, 38) then TriggerEvent('add your event here')endbreakelse wait =2000endendif inZone andnot alreadyEnteredZone then alreadyEnteredZone =true TriggerEvent('cd_drawtextui:ShowUI', 'show', text)endifnot inZone and alreadyEnteredZone then alreadyEnteredZone =false TriggerEvent('cd_drawtextui:HideUI')end Citizen.Wait(wait)endend)
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.
Config = {}Config.Example = { [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'},
[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'},
[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'},
}Citizen.CreateThread(function()local alreadyEnteredZone =falselocal text =nilwhiletruedo wait =5local ped = PlayerPedId()local inZone =falsefor cd =1, #Config.Example do local dist = #(GetEntityCoords(ped)-vector3(Config.Example[cd].coords.x, Config.Example[cd].coords.y, Config.Example[cd].coords.z))
if dist <= Config.Example[cd].distance then wait =5 inZone =true text = Config.Example[cd].textif IsControlJustReleased(0, Config.Example[cd].key) then TriggerEvent(Config.Example[cd].eventname)endbreakelse wait =2000endendif inZone andnot alreadyEnteredZone then alreadyEnteredZone =true TriggerEvent('cd_drawtextui:ShowUI', 'show', text)endifnot inZone and alreadyEnteredZone then alreadyEnteredZone =false TriggerEvent('cd_drawtextui:HideUI')end Citizen.Wait(wait)endend)
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.