Jump to content

Custom font


Blinker.

Recommended Posts

Posted

Hello folks,

i'm using a custom font to draw a vehicle's health ,but i got 2 problems ,

1 - it lags when the number changes like if i had 99% hp and i hit someone it will go down to 90 % and here it lags for 1 sec

2 - when the number changes also , a line is drawn under the number like in this photo :

http://imgur.com/9PlrSfz

nothing more to say.. i've tried bangothic font and it works with 0 lag.

any help would be greatly appreciated.

Posted

Show us the code, how else can we help you?

My first guess, is that you are creating the font on every render.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
  
local font = dxCreateFont( "font.ttf",19 ) 
  
function render() 
  
local vehicle = getPedOccupiedVehicle(localPlayer) 
local health = math.round(((getElementHealth(vehicle)-250)/750*100),0) 
local speed = getElementSpeed(vehicle) 
  
if health <= 0 then 
health = 0 
end 
  
  
dxDrawImage ( sw-118, sh/1.15,110,70, 'progress_health_bg.png') 
dxDrawImage ( sw-118, sh/1.15,speed,70, 'progress_speed.png') 
    dxDrawText(health.."%", sw-118, (sh/1.15)+5,sw-6,1,tocolor(r,g,b,255),1,font,"right") 
  
  
  
  
end 
addEventHandler("onClientRender",root,render) 
  

Posted

I don't know why, but some font files have bad performance. You could try with a different font, or a different format of this font.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...