Jump to content

dxDrawText position


Recommended Posts

Hello, i'm trying to draw a text next to the 'watermark' that shows fps and ping

Ns55S.png

In my resolution (1440x900) its normal

But when i test at 800x600 ...

9pS.png

Thas my code

local sx_, sy_ = guiGetScreenSize()
local sx, sy = sx_/1440, sy_/900

addEventHandler("onClientRender", root,
    function()
		local a = string.format("FPS: %d  PING: %d", fps, getPlayerPing(localPlayer))
		dxDrawText(a, 1250*sx, 885*sy, 1359*sx, 900*sy, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
	end
)

I followed the methods described in this topic

https://forum.multitheftauto.com/topic/96776-tut-scaling-drawinggui-elements-for-all-resolutions/

If anyone can help me, I'd appreciate it

Link to comment

Not tested 

addEventHandler("onClientRender", root,
    function()
		local a = string.format("FPS: %d  PING: %d", 51, getPlayerPing(localPlayer))
        local c_version = "MTA:SA"..getVersion().mta.."*"
		dxDrawText(a, 0, 0, sx-dxGetTextWidth(c_version), sy, tocolor(255, 255, 255, 255), 1, "default", "right", "bottom", false, false, false, false, false)
	end
)

 

Edited by Overkillz
Link to comment
On 09/07/2022 at 01:09, Modafinil said:

Hello, i'm trying to draw a text next to the 'watermark' that shows fps and ping

Ns55S.png

In my resolution (1440x900) its normal

But when i test at 800x600 ...

9pS.png

Thas my code

local sx_, sy_ = guiGetScreenSize()
local sx, sy = sx_/1440, sy_/900

addEventHandler("onClientRender", root,
    function()
		local a = string.format("FPS: %d  PING: %d", fps, getPlayerPing(localPlayer))
		dxDrawText(a, 1250*sx, 885*sy, 1359*sx, 900*sy, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
	end
)

I followed the methods described in this topic

https://forum.multitheftauto.com/topic/96776-tut-scaling-drawinggui-elements-for-all-resolutions/

If anyone can help me, I'd appreciate it

local sx, sy = guiGetScreenSize()
local px = math.min(1, math.max(sx/1920, sy/1080))

addEventHandler("onClientRender", root,
    function()
		local a = string.format("FPS: %d  PING: %d", fps, getPlayerPing(localPlayer))
		dxDrawText(a, sx - 190*px, sy - 15*px, sx, sy, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
	end
)

Try this

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