Jump to content

[HELP] How to fix this dx issue?


Turbesz

Recommended Posts

Posted

My dx elements appear perfectly on my FHD resolution, but on smaller resolutions they do not look very good :/

This is my problem: 

On my resolution:

spacer.png

On a smaller (1366x768) resolution:

spacer.png

 

The dx elements slip a little... this is my code:

local sx_, sy_ = guiGetScreenSize()
local sx, sy = sx_/1920, sy_/1080

local scale = sy

function teszt()
	dxDrawRectangle(140*sx, 200*sy, 500 * scale, 685 * scale,tocolor(0,0,0,145))
	dxDrawRectangle(150*sx, 235*sy, 480 * scale, 600 * scale,tocolor(0,0,0,145))
	dxDrawImage(595*sx, 845*sy, 30 * scale, 30 * scale,"kuld.png",0,0,0,(isMouseInPosition(595*sx, 845*sy, 30 * scale, 30 * scale) and tocolor(255,181,64,255) or tocolor(255,255,255,255)))
	dxDrawText("Lobby Chat",283*sx, 205*sy, 500 * scale, 700 * scale,tocolor(255,255,255,255),0.7*sy,vekony,"center")

	local x = 0

	for k, v in ipairs(uzenetek) do
		x = x + 1
		if getElementData(getPlayerFromPartialName(v[2]),"adminrang") == false then
			dxDrawText(v[1],160*sx, 210*sy+(x*30), 500 * scale, 700 * scale,tocolor(255,255,255,255),0.7*sy,vastag,"left",_,_,_,_,true)
		else 
			dxDrawImage(160*sx, 209*sy+(x*30), 20 * scale, 20 * scale,"moderator.png",0,0,0,tocolor(255,255,255,255))
			dxDrawText(v[1],190*sx, 210*sy+(x*30), 500 * scale, 700 * scale,tocolor(255,255,255,255),0.7*sy,vastag,"left",_,_,_,_,true)
		end
	end
end
addEventHandler("onClientRender",root,teszt)

What wrong with the calculations? How to fix this?

Posted (edited)

Hello, you should look in the MTA wiki for the syntax of the functions that you are using (dxDrawRectangle, dxDrawImage, 

dxDrawText) to understand how they are drawn on the screen (x and y positions, width, height, etc).
Edited by FernandoMTA

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