Sim eu utilizo ele, mas mesmo assim em outras resoluções ficam ruins.
Responsive.lua, e no client é onde está a hud em si
screen = {guiGetScreenSize ()}
resolution = {1366,768}
sx, sy = screen[1] / resolution[1], screen[2] / resolution[2]
function setScreenPosition (x, y, w, h)
return ((x / resolution[1]) * screen[1]), ((y / resolution[2]) * screen[2]), ((w / resolution[1]) * screen[1]), ((h / resolution[2]) * screen[2])
end
function isCursorOnElement (x, y, w, h)
if isCursorShowing () then
local cursor = {getCursorPosition ()}
local mx, my = cursor[1] * screen[1], cursor[2] * screen[2]
return mx > x and mx < x + w and my > y and my < y + h
end
return false
end
function dxDrawTextOnElement(TheElement, text, height, distance, R, G, B, alpha, size, font, ...)
local x, y, z = getElementPosition(TheElement)
local x2, y2, z2 = getCameraMatrix()
local distance = distance or 20
local height = height or 1
if (isLineOfSightClear(x, y, z+2, x2, y2, z2, ...)) then
local sx, sy = getScreenFromWorldPosition(x, y, z+height)
if(sx) and (sy) then
local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)
if(distanceBetweenPoints < distance) then
dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center")
end
end
end
end
_dxCreateFont = dxCreateFont
function dxCreateFont (path, scale, ...)
local _, scale, _, _ = setScreenPosition (0, scale, 0, 0)
return _dxCreateFont (path, scale, ...)
end
_dxDrawRectangle = dxDrawRectangle
function dxDrawRectangle (x, y, w, h, ...)
local x, y, w, h = setScreenPosition (x, y, w, h)
return _dxDrawRectangle (x, y, w, h, ...)
end
_dxDrawImage = dxDrawImage
function dxDrawImage (x, y, w, h, ...)
local x, y, w, h = setScreenPosition (x, y, w, h)
return _dxDrawImage (x, y, w, h, ...)
end
_dxDrawImageSection = dxDrawImageSection
function dxDrawImageSection (x, y, w, h, ...)
local x, y, w, h = setScreenPosition (x, y, w, h)
return _dxDrawImageSection (x, y, w, h, ...)
end
_svgCreate = svgCreate
function svgCreate(w,h,...)
local _,_,w,h = setScreenPosition(0,0,w,h)
return _svgCreate(w,h,...)
end
_dxDrawText = dxDrawText
function dxDrawText (text, x, y, w, h, ...)
local x, y, w, h = setScreenPosition (x, y, w, h)
return _dxDrawText (text, x, y, (x + w), (y + h), ...)
end
_isCursorOnElement = isCursorOnElement
function isCursorOnElement (x, y, w, h)
local x, y, w, h = setScreenPosition (x, y, w, h)
return _isCursorOnElement (x, y, w, h)
end
local svgList = {}
function drawRoundRect(id, x, y, width, height, color, border_radius)
border_radius = border_radius or 0
color = color or tocolor(255,255,255)
if (not svgList[id]) then
local rawData = string.format([[
<svg width="%s" height="%s" xmlns="http://www.w3.org/2000/svg">
<rect rx="%s" ry="%s" width="%s" height="%s" style="fill:#FFFFFF"/>
</svg>
]], width, height,
border_radius, border_radius,
width, height)
svgList[id] = svgCreate(width, height, rawData)
end
if (svgList[id]) then
dxSetBlendMode('add')
dxDrawImage(x, y, width, height, svgList[id], 0, 0, 0, color, false)
dxSetBlendMode('blend')
end
end