Jump to content

Screen size all players


Zcraks

Recommended Posts

A long time ago i was suffering with this issue too. I figured it out, and since that, i'm using this.

This will put the dx on the center of the screen always.

local screenSize = {guiGetScreenSize()}
local panelW, panelH = 300, 150	--// panelW = panel Widht | panelH = panelHeight
local panelX, panelY = screenSize[1]/2-panelW/2, screenSize[2]/2-panelH/2

--// use
addEventHandler('onClientRender', root, function()
    dxDrawRectangle(panelX, panelY, panelW, panelH, tocolor(0, 0, 0, 200) )
    
    --// if you want to make a button of course smaller, you can do like this
    dxDrawRectangle(panelX, panelY, panelW, panelH - 125, tocolor(0, 0, 0, 200) )
end)

 

Edited by itHyperoX
Link to comment

@Zcraks you can also use this

local screX, screY = guiGetScreenSize()
local px,py = 1366,768 -- your resolution where everything fits perfect
local x,y =  (screX/px), (screY/py)

simple example:

dxDrawText('Hello guys!', x*450, y*300, x*300, y*100)

OR you can make it happen for everything on one go by replacing the original function. Example:

function all_dxDrawText(...)
	local arr = {...} -- get arguments
	arr[1] = x*arr[1] -- do some magic stuff
	arr[2] = y*arr[2]
	arr[3] = x*arr[3]
	arr[4] = y*arr[4]
	return dxDrawText(unpack(arr)) -- use modified arguments
end

all_dxDrawText('Hello guys!', x*450, y*300, x*300, y*100)

 

Link to comment
  • Moderators
On 09/06/2019 at 02:37, Zcraks said:

I have a problem with rendering DX at different screen size. If 1980x1920 then it works and if 1366x768 it does not work.

How about you scale over the Y axis only?

That solved all my problems. Because in most cases scaling shouldn't include the ration, but the pixel density only. (With some exceptions)

 

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