Jump to content

Help with screen resolution


MAB

Recommended Posts

hi i am trying to draw a text that displays the vehicle health and make it fits all screens with that but it didn't work.

local sx,sy = guiGetScreenSize() 
local px,py = 1600,900 
local x,y =  (sx/px), (sy/py) 
local car = getPedOccupiedVehicle ( localPlayer ) 
local health = getElementHealth ( car ) 
local currenthealth = math.floor( health/10 ) 
dxDrawText(tostring(currenthealth).." % ", x*1090, y*635, x*1226, y*549, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) 

Link to comment

Consider make that using addition (or subtraction) instead of multiplication.

Example:

  
    -- Left top corner 
    local car = getPedOccupiedVehicle ( localPlayer ) 
    local health = getElementHealth ( car ) 
    local currenthealth = math.floor( health/10 ) 
    dxDrawText(tostring(currenthealth).." % ", 100, 50, 200, 50, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) 
  
    -- Right bottom corner 
    local sx,sy = guiGetScreenSize() 
    local car = getPedOccupiedVehicle ( localPlayer ) 
    local health = getElementHealth ( car ) 
    local currenthealth = math.floor( health/10 ) 
    dxDrawText(tostring(currenthealth).." % ", sx-100, sy-50, x, y, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) 
  

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