Jump to content

Font size from dxDrawText


Enargy,

Recommended Posts

Hi guys, I'm working on a point system but when do the work of rendering the following emerges:

local screenW, screenH = guiGetScreenSize() 
local x, y = (screenW/1024), (screenH/768) 
  
  
local size = 1.50 --- the size of the text font 
  
addEventHandler("onClientRender", root, 
function() 
     
        local playerCoins = getPlayerCoins(getLocalPlayer()) 
        dxDrawText("C"..gPlayerCoins(playerCoins), x*795, y*170, x*973, 198, tocolor(0, 0, 0, 255), size, "pricedown", "left", "top", false, false, false, false, false) 
        dxDrawText("C"..gPlayerCoins(playerCoins), x*795, y*166, x*973, 198, tocolor(0, 0, 0, 255), size, "pricedown", "left", "top", false, false, false, false, false) 
        dxDrawText("C"..gPlayerCoins(playerCoins), x*800, y*166, x*973, 196, tocolor(0, 0, 0, 255), size, "pricedown", "left", "top", false, false, false, false, false) 
        dxDrawText("C"..gPlayerCoins(playerCoins), x*795, y*171, x*971, 198, tocolor(0, 0, 0, 255), size, "pricedown", "left", "top", false, false, false, false, false) 
        dxDrawText("C"..gPlayerCoins(playerCoins), x*800, y*171, x*971, 198, tocolor(0, 0, 0, 255), size, "pricedown", "left", "top", false, false, false, false, false) 
        dxDrawText("C"..gPlayerCoins(playerCoins), x*796, y*168, x*971, 196, tocolor(0, 0, 0, 255), size, "pricedown", "left", "top", false, false, false, false, false) 
        dxDrawText("C"..gPlayerCoins(playerCoins), x*797, y*169, x*972, 197, tocolor(100, 100, 255, 200), size, "pricedown", "left", "top", false, false, false, false, false) 
     
end) 

the script works totally fine but when a player has a higher or lower resolution than the acquiree as text size varies with different ones. I was thinking of doing the calculations using the font size of the text but I have no idea how to calculate the size of the font for all resolutions.

ty.

Link to comment

Try/

local screenW, screenH = guiGetScreenSize() 
local x, y = (screenW/1024), (screenH/768) 
  
local size = y*1.50 --- the size of the text font 
  
addEventHandler("onClientRender", root, 
function() 
    local playerCoins = getPlayerCoins(getLocalPlayer()) 
    dxDrawText("C"..gPlayerCoins(playerCoins), x*795, y*170, x*973, y*198, tocolor(0, 0, 0, 255), size, "pricedown", "left", "top", false, false, false, false, false) 
    dxDrawText("C"..gPlayerCoins(playerCoins), x*795, y*166, x*973, y*198, tocolor(0, 0, 0, 255), size, "pricedown", "left", "top", false, false, false, false, false) 
    dxDrawText("C"..gPlayerCoins(playerCoins), x*800, y*166, x*973, y*196, tocolor(0, 0, 0, 255), size, "pricedown", "left", "top", false, false, false, false, false) 
    dxDrawText("C"..gPlayerCoins(playerCoins), x*795, y*171, x*971, y*198, tocolor(0, 0, 0, 255), size, "pricedown", "left", "top", false, false, false, false, false) 
    dxDrawText("C"..gPlayerCoins(playerCoins), x*800, y*171, x*971, y*198, tocolor(0, 0, 0, 255), size, "pricedown", "left", "top", false, false, false, false, false) 
    dxDrawText("C"..gPlayerCoins(playerCoins), x*796, y*168, x*971, y*196, tocolor(0, 0, 0, 255), size, "pricedown", "left", "top", false, false, false, false, false) 
    dxDrawText("C"..gPlayerCoins(playerCoins), x*797, y*169, x*972, y*197, tocolor(100, 100, 255, 200), size, "pricedown", "left", "top", false, false, false, false, false) 
end) 

  • Thanks 1
Link to comment

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