[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)

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


Check out our other paid scripts:

Expand

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

Check out our free scripts:

Expand

[FREE RELEASE] Easytime - Time and weather management by Codesign
[FREE RELEASE] Devtools - LUA / JSON Table viewer by Codesign
[FREE RELEASE] Draw text UI
[FREE RELEASE] Keymaster minigame by Codesign


18 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

1 Like

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)
2 Likes

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

1 Like

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

1 Like

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

1 Like

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)
1 Like

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.

1 Like

Read the read meā€™s, there are copy and paste templates you can use

1 Like

This is exactly what this script does because I donā€™t really understand it?

3 Likes