[FREE RELEASE] Draw text UI

DrawtextUI

This is a more optimised replacement for the standard 3Dtext.


INSTALLATION GUIDE

1. Clone the repository or Code > Download zip

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.

Dependencies and Compatibility

Expand

Framework Dependencies
none

Sql Resource Dependencies
none

Resource Dependencies
none

OneSync Compatibility
:white_check_mark:

How to use?

  • 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.
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.

Expand
Citizen.CreateThread(function()
    local alreadyEnteredZone = false
    local text = '<b>Title</b></p>[E] Press E to be bald'
    while true do
        wait = 5
        local ped = PlayerPedId()
        local inZone = false
        local dist = #(GetEntityCoords(ped)-vector3(0,0,0))
        if dist <= 5.0 then
            wait = 5
            inZone  = true

            if IsControlJustReleased(0, 38) then
                TriggerEvent('add your event here')
            end
        else
            wait = 1000
        end
        
        if inZone and not alreadyEnteredZone then
            alreadyEnteredZone = true
            TriggerEvent('cd_drawtextui:ShowUI', 'show', text)
        end

        if not inZone and alreadyEnteredZone then
            alreadyEnteredZone = false
            TriggerEvent('cd_drawtextui:HideUI')
        end
        Citizen.Wait(wait)
    end
end)

Example 2 : This is how to implement the UI while doing a for loop for multiple locations in 1 thread.

Expand
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 = false
    local text = '<b>Title</b></p>[E] Press E to be bald'
    while true do
	wait = 5
	local ped = PlayerPedId()
	local inZone = false
	for cd = 1, #Config.Example do
	    local dist = #(GetEntityCoords(ped)-vector3(Config.Example[cd].x, Config.Example[cd].y, Config.Example[cd].z))
	    if dist <= 5.0 then
		wait = 5
		inZone  = true

		if IsControlJustReleased(0, 38) then
		    TriggerEvent('add your event here')
		end
		break
	    else
		wait = 2000
	    end
	end

	if inZone and not alreadyEnteredZone then
	    alreadyEnteredZone = true
	    TriggerEvent('cd_drawtextui:ShowUI', 'show', text)
	end

	if not inZone and alreadyEnteredZone then
	    alreadyEnteredZone = false
	    TriggerEvent('cd_drawtextui:HideUI')
	end
	Citizen.Wait(wait)
    end
end)

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.

Expand
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 = false
    local text = nil
    while true do
        wait = 5
        local ped = PlayerPedId()
        local inZone = false
        for 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].text

                if IsControlJustReleased(0, Config.Example[cd].key) then
                    TriggerEvent(Config.Example[cd].eventname)
                end
                break
            else
                wait = 2000
            end
        end
        
        if inZone and not alreadyEnteredZone then
            alreadyEnteredZone = true
            TriggerEvent('cd_drawtextui:ShowUI', 'show', text)
        end

        if not inZone and alreadyEnteredZone then
            alreadyEnteredZone = false
            TriggerEvent('cd_drawtextui:HideUI')
        end
        Citizen.Wait(wait)
    end
end)

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.

Check out our Tebex store at https://codesign.pro


Check out our other paid scripts:

Expand

[PAID] Codesign Player HUD - Smartwatch
[PAID] Codesign Vehicle Garage
[PAID] Codesign Highly customisable Car HUD
[PAID] Codesign Police Dispatch
[PAID] Codesign Prop placer
[PAID] Spawn selector by Codesign
[PAID] Codesign Multicharacter
[PAID] Codesign Terminal Hacker - Minigame

Check out our free scripts:

Expand

[FREE RELEASE] Easytime - Time and weather management by Codesign
[FREE RELEASE] Keymaster minigame by Codesign


15 Likes

Thank you for sharing this for free

4 Likes

Hope you like it. :smiley:

We also hope to see some images of sick css redesigns :grinning:

2 Likes

Amazing.

2 Likes

Not bad.

2 Likes

Thanks for share, its amazing, btw whats that HUd you are using?

2 Likes

If you mean carhud it’s this: [RELEASE] [PAID] Codesign highly customisable Car HUD - Releases - Cfx.re Community

By the way, good job @Codesign

3 Likes

I use this notification system, on my server and it works perfectly, super fast and hardly consumes

2 Likes

May i Ask is there a video explaining how to do it… as i use grp core i dont know if i can use it on there doorlocking system

There’s no video. We do have a readme file you can check out Drawtext UI - Codesign Scripts

heyy bro
good job bro

can u help me for this plz ?

heey 

Citizen.CreateThread(function()

    while true do

        Citizen.Wait(0)

        local playerCoords, awayFromDoors = GetEntityCoords(GetPlayerPed(-1)), true

        for k,doorID in ipairs(QB.Doors) do

            local distance

            if doorID.doors then

                distance = #(playerCoords - doorID.doors[1].objCoords)

            else

                distance = #(playerCoords - doorID.objCoords)

            end

            if doorID.distance then

                maxDistance = doorID.distance

            end

            if distance < 50 then

                awayFromDoors = false

                if doorID.doors then

                    for _,v in ipairs(doorID.doors) do

                        FreezeEntityPosition(v.object, doorID.locked)

                        if doorID.locked and v.objYaw and GetEntityRotation(v.object).z ~= v.objYaw then

                            SetEntityRotation(v.object, 0.0, 0.0, v.objYaw, 2, true)

                        end

                    end

                else

                    FreezeEntityPosition(doorID.object, doorID.locked)

                    if doorID.locked and doorID.objYaw and GetEntityRotation(doorID.object).z ~= doorID.objYaw then

                        SetEntityRotation(doorID.object, 0.0, 0.0, doorID.objYaw, 2, true)

                    end

                end

            end

            if distance < maxDistance then

                awayFromDoors = false

                if doorID.size then

                    size = doorID.size

                end

                local isAuthorized = IsAuthorized(doorID)

                if isAuthorized then

                    if doorID.locked then

                        displayText = "[E] - closed   "   .. k

                    elseif not doorID.locked then

                        displayText = "[E] - opened   "   .. k

                    end

                elseif not isAuthorized then

                    if doorID.locked then

                        displayText = "press e   "   .. k

                    elseif not doorID.locked then

                        displayText = "press e   "   .. k

                    end

                end

                if doorID.locking then

                    if doorID.locked then

                        displayText = ".opening"

                    else

                        displayText = ".opening"

                    end

                end

                if doorID.objCoords == nil then

                    doorID.objCoords = doorID.textCoords

                end

                DrawText3Ds(doorID.objCoords.x, doorID.objCoords.y, doorID.objCoords.z, displayText)

                --print(k)

                if IsControlJustReleased(0, 38) then

                    if isAuthorized then

                        setDoorLocking(doorID, k)

                    end

                end

            end

        end

        if awayFromDoors then

            Citizen.Wait(1000)

        end

    end

end)

10/10 very optimized and it is free can’t get any better :slight_smile:

2 Likes

Sooo Amazinnng !! Thank you

2 Likes

@C4_Peerless the easiest way to use this, is just to copy one of the example templates and paste your code into it

Hey bro, im having a problem, i can set up everything and the notification shows all good , but if i stand there i keeps like popping up ( flashing ), appreciate any help thanks

@Joao_Gargalo Id recommend using the templates provided in the read me and then adding your code to it - Drawtext UI - Codesign Scripts

I’ve tryied everything now, could you help me pls

Citizen.CreateThread(function()
	local sleep = 500
	while true do
		Citizen.Wait(sleep)
		local playerCoords = GetEntityCoords(PlayerPedId())

		for i=1, #Config.DoorList do
			local doorID   = Config.DoorList[i]
			local distance = GetDistanceBetweenCoords(playerCoords, doorID.objCoords.x, doorID.objCoords.y, doorID.objCoords.z, true)

			local maxDistance = 1.25
			if doorID.distance then
				maxDistance = doorID.distance
			end

			if (distance < (maxDistance+55)) then
				--if (distance < (maxDistance+25)) then
					--if (distance < (maxDistance+5)) then

						sleep = 5
						local isAuthorized = IsAuthorized(doorID)
						ApplyStateLock(doorID)
						local size = 1

						if doorID.size then
							size = doorID.size
						end
						if (distance < maxDistance) then
							if  IsControlJustReleased(1,  38) and isAuthorized then
								if doorID.locked == true then
									local active = true
									local swingcount = 0
									TriggerEvent("dooranim")
									doorID.locked = false
									while active do
										Citizen.Wait(7)

										locked, heading = GetStateOfClosestDoorOfType(GetHashKey(doorID.objName, doorID.objCoords.x, doorID.objCoords.y, doorID.objCoords.z)) 
										heading = math.ceil(heading * 100) 
										DrawText3DTest(doorID.textCoords, "A Destrancar", size)
										
										local dist = GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), doorID.objCoords.x, doorID.objCoords.y, doorID.objCoords.z, true)
										local dst2 = GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), 1830.45, 2607.56, 45.59,true)

										if heading < 1.5 and heading > -1.5 then
											swingcount = swingcount + 1
										end             
										if dist > 150.0 or swingcount > 100 or dst2 < 200.0 then
											active = false
										end
									end

								elseif doorID.locked == false then

									local active = true
									local swingcount = 0
									TriggerEvent("dooranim")
									doorID.locked = true
									while active do
										Citizen.Wait(1)
										DrawText3DTest(doorID.textCoords, "A Trancar", size)
										swingcount = swingcount + 1
										if swingcount > 100 then
											active = false
										end
									end

								end
								TriggerServerEvent('irp_doorlock:updateState', i, doorID.locked)
							end

							if doorID.locked and isAuthorized then 
								closestString = "[~g~E~w~] - ~r~TRANCADA"
								DrawText3DTest(doorID.textCoords, closestString, size) 
							elseif doorID.locked == false and isAuthorized then 
								closestString = "[~g~E~w~] - ~g~DESTRANCADA"
								DrawText3DTest(doorID.textCoords, closestString, size) 
							end
							break
						end
					--else
					--	sleep = 500
					--end
			---	else
			--		sleep = 1500
			--	end
			else
				sleep = 2500
			end
		end
	end
end)

Hi, can i ask where i must code paste like: client.lua, _resource or server.lua? and how event must be in here TriggerEvent(‘add your event here’) for open bank. Script new_banking.

Read the read me’s, there are copy and paste templates you can use

This is exactly what this script does because I don’t really understand it?