Jump to content

LUA Resolution Problem


Veo

Recommended Posts

Posted

Dear MTA:SA Community

 

 

I have the issue, that i want do with

dxGetTextWidth & dxDrawRectangle 

a Background, for the Map Text, it looks like that.

https://i.imgur.com/HjwgkeY.png

It works fine in 1920x1080, but if i Change it to 1360x768, then it looks like this

https://i.imgur.com/dFflYj5.png

 

Heres some Code:

 

===============

function resY(value)
    return (value/1080) * y
end

function resX(value)
    return (value/1920) * s
end

===============

local length = dxGetTextWidth(_MapName,resY(1),fonts["normal"][3])
rectangle = dxDrawRectangle(s*0.008,y*0.957,length+55,y*0.030, tocolor ( 0, 266, 0, 250 ) )

 

  • Moderators
Posted

The IIYAMA rule: Scale EVERYTHING only over the Y as. Except for the X position.

We are very lucky that they hardly design monitors with a portrait orientation... else it would have blown off my mind.

 


 

This could be one of your issues, an absolute value:

dxDrawRectangle(s*0.008,y*0.957, length + 55,y*0.030, tocolor ( 0, 266, 0, 250 ) )

dxDrawRectangle(s*0.008,y*0.957,length + resY(55),y*0.030, tocolor ( 0, 266, 0, 250 ) )

 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted (edited)
8 minutes ago, IIYAMA said:

The IIYAMA rule: Scale EVERYTHING only over the Y as. Except for the X position.

We are very lucky that they hardly design monitors with a portrait orientation... else it would have blown off my mind.

 


 

This could be one of your issues, an absolute value:

dxDrawRectangle(s*0.008,y*0.957, length + 55,y*0.030, tocolor ( 0, 266, 0, 250 ) )


dxDrawRectangle(s*0.008,y*0.957,length + resY(55),y*0.030, tocolor ( 0, 266, 0, 250 ) )

 

Thanks, i tried. but its still the same issue..

Edited by Veo
Posted (edited)
local sw, sh =guiGetScreenSize() 
local sx, sy = sw/1920, sh/1080 dxDrawRectangle(sx*0.008,sy*0.957,length + sx*55,sy*0.030, tocolor ( 0, 266, 0, 250 ) )

 

Edited by Dimos7

 

 

  • Moderators
Posted
45 minutes ago, Veo said:

@IIYAMA i dont understand it, why that is not working. :(

Where is your dxDrawText function in your code?

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

Well, I always use this code to draw DX stuff, and I recommend you to try it so

local sx,sy = guiGetScreenSize()
local px,py = 1366,768 --Put your resolution here
local x,y =  (sx/px),(sy/py)

--Example code
dxDrawRectangle(x*0, y*0, x*1366, y*80, tocolor(0, 0, 0, 170), false)
dxDrawText("Test", x*0, y*0, x*1366, y*80, tocolor(255, 255, 255, 255), 1.5, "pricedown", "center", "center", false, false, false, false, false)

It always fits in all resolutions.

  • Like 1

Scripter, developer of the first MTA Rust-inspired server.

steamcommunity.com/id/erknneto

github.com/erknneto

Posted
6 hours ago, Erknneto said:

Well, I always use this code to draw DX stuff, and I recommend you to try it so


local sx,sy = guiGetScreenSize()
local px,py = 1366,768 --Put your resolution here
local x,y =  (sx/px),(sy/py)

--Example code
dxDrawRectangle(x*0, y*0, x*1366, y*80, tocolor(0, 0, 0, 170), false)
dxDrawText("Test", x*0, y*0, x*1366, y*80, tocolor(255, 255, 255, 255), 1.5, "pricedown", "center", "center", false, false, false, false, false)

It always fits in all resolutions.

I want that for all resolutions, Not just for 1360

Posted (edited)

@Erknneto that dosnt Help me for mine code.. someone has maybe Discord?

 

@Edit: If the Map changed, its change the Rectangle to the Map Name length.  The Rectangle fits the Map length Name

Edited by Veo
Posted
11 hours ago, Veo said:

I want that for all resolutions, Not just for 1360

yeah it's work for all 

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
2 hours ago, Dimos7 said:

@Veo did you try my code?

Yes, i do.

 

Here:
GmyQrcE.png

			local x,y = guiGetScreenSize()
			local sw, sh =guiGetScreenSize() 
			local length = dxGetTextWidth(_MapName,resY(1),fonts["normal"][3])
			rectangle = dxDrawRectangle(s*0.008,y*0.957,length + sx*55,y*0.030, tocolor ( 0, 266, 0, 250 ) )

 

Posted
14 hours ago, Veo said:
21 hours ago, Erknneto said:

Well, I always use this code to draw DX stuff, and I recommend you to try it so



local sx,sy = guiGetScreenSize()
local px,py = 1366,768 --Put your resolution here
local x,y =  (sx/px),(sy/py)

--Example code
dxDrawRectangle(x*0, y*0, x*1366, y*80, tocolor(0, 0, 0, 170), false)
dxDrawText("Test", x*0, y*0, x*1366, y*80, tocolor(255, 255, 255, 255), 1.5, "pricedown", "center", "center", false, false, false, false, false)

It always fits in all resolutions.

I want that for all resolutions, Not just for 1360

it WILL fit in each resolution - this is the simplest way. Your coordinates will be multiplied by (for example x: 1366/player_resolution) -> Bigger resolution x>0, smaller - 0<x<1

You can try it yourself by changing in-game/pc resolutions. By the way you should multiply dxDrawText's scale too

Posted (edited)
local sw, sh =guiGetScreenSize() 
local sx, sy = sw/1920, sh/1080 dxDrawRectangle(sx*0.008,sy*0.957,length + sx*55,sy*0.030, tocolor ( 0, 266, 0, 250 ) )
1 hour ago, Veo said:

Yes, i do.

 

Here:
GmyQrcE.png


			local x,y = guiGetScreenSize()
			local sw, sh =guiGetScreenSize() 
			local length = dxGetTextWidth(_MapName,resY(1),fonts["normal"][3])
			rectangle = dxDrawRectangle(s*0.008,y*0.957,length + sx*55,y*0.030, tocolor ( 0, 266, 0, 250 ) )

 

That wasn't my code

Edited by Dimos7

 

 

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