How to fix font flashing when add font into server?

When I add font into the sever it got flashing
How to fix it ?

bottle 2

Hello, this is a friendly reminder because this is your first time creating a topic (or it has been a while since your last topic) in this category.

Please note that most of the support is provided by the FiveM community on a voluntary basis. We ask you to be patient; there is no guarantee we have a solution to your problem(s). To avoid unnecessary/duplicate topics, please browse the forums before creating a topic.

To improve your chances of your issue(s) being solved, please provide as much information as possible about the issue(s) you are having. Also —whenever possible— please use the template given to you when creating a topic.

Thanks for keeping these forums tidy!
:mascot:

What is the script you use?

This isn’t probably a bug from FiveM it is a script you are using, if this flashing appears everythere, then it could actually be one, otherwise go to the main topic of the resource you got there.

I hope I could help, have a nice day :hamburger: :mascot:

I do the same thing which this forum to add font

Probably a loop running slow

Where do i need to fix ?

Just say us, have you done it by yourself or do you use any resource from otherones for it?

Wether or not, you will have something like this somewhere:

Citizen.CreateThread(function()
   while true do
       Citizen.Wait(number)

        -- some code

   end
end)

If the number is not 0 set it to it, otherwise check for other wait functions, and if there are any, get rid of them, cause this function needs to be called every tick.

If this all does not help, send us the code you’re on.

Thanks :hamburger: :mascot:

In my folder resource/font in client.lua I use this code to register the font

Citizen.CreateThread(function()
    RegisterFontFile('dog') -- the name of your .gfx, without .gfx
end)

when I want to add font to any script i just

local fontId
fontId = RegisterFontId('dog')

you are doing this only once, and not in a loop, right?

Like this

ESX.Game.Utils.DrawText3D = function(coords, text, size)
	local onScreen, x, y = World3dToScreen2d(coords.x, coords.y, coords.z)
	local camCoords      = GetGameplayCamCoords()
	local dist           = GetDistanceBetweenCoords(camCoords, coords.x, coords.y, coords.z, true)
	local size           = size

	if size == nil then
		size = 1
	end

	local scale = (size / dist) * 2
	local fov   = (1 / GetGameplayCamFov()) * 100
	local scale = scale * fov
	local fontId
	fontId = RegisterFontId('dog')

	if onScreen then
		SetTextScale(0.0 * scale, 0.55 * scale)
		SetTextFont(fontId)
		SetTextColour(255, 255, 255, 255)
		SetTextDropshadow(0, 0, 0, 0, 255)
		SetTextDropShadow()
		SetTextOutline()
		SetTextEntry('STRING')
		SetTextCentre(1)

		AddTextComponentString(text)
		DrawText(x, y)
	end
end

You should only do this once, not for every text.

Thank you , sir . Do you know how to fix font flashing in game ?

Show us the code where you call DrawText3d()

In es_extend\client\main.lua
------------- I want to change font when I drop the item -----------

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)

		local playerPed = PlayerPedId()
		local coords = GetEntityCoords(playerPed)
		
		-- if there's no nearby pickups we can wait a bit to save performance
		if next(pickups) == nil then
			Citizen.Wait(500)
		end

		for k,v in pairs(pickups) do
			local distance = GetDistanceBetweenCoords(coords, v.coords.x, v.coords.y, v.coords.z, true)
			local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()

			if distance <= 5.0 then
				ESX.Game.Utils.DrawText3D({
					x = v.coords.x,
					y = v.coords.y,
					z = v.coords.z + 0.25
				}, v.label)
			end

			if (closestDistance == -1 or closestDistance > 3) and distance <= 1.0 and not v.inRange and IsPedOnFoot(playerPed) then
				TriggerServerEvent('esx:onPickup', v.id)
				PlaySoundFrontend(-1, 'PICK_UP', 'HUD_FRONTEND_DEFAULT_SOUNDSET', false)
				v.inRange = true
			end
		end
	end
end)
if next(pickups) == nil then
	Citizen.Wait(500)
end

This is probably what causes your problem. Try to remove it temporarily to see if it works as expected and then find a workaround.

anyone know how to change font for blip text ?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.