Jump to content

How to discover the coordinates using guiGetScreenSize() ?


drk

Recommended Posts

It's a really simple operation to scale DX things to the screen.

Suppose your PC uses 1024x768 as resolution on MTA, okay?

Then do this:

local dw = 1024 
local sw = guiGetScreenSize ( ) 
dxDrawWhatever ( arguments... (SCALE = sw/dw ) .. more arguments ) 

Edited by Guest
Link to comment

Use the screen width and height and divide, or multiply with a value under 1..

for example:

  
local screen_w, screen_h = guiGetScreenSize() 
local guiWidth = 500 
local guiHeight = 500 
  
-- creates a window with 500 pixels width and height, and puts it on the center of the screen. 
local guiWindow = guiCreateWindow(screen_w*0.5 - guiWidth*0.5, screen_h*0.5 - guiHeight*0.5, guiWidth, guiHeight, "Centered window", false) 
  

Link to comment

I don't understand nothing '-' Can anyone adjust to me ? pls

dxDrawText( textQuit, 959.0, 246.0, 1227.0, 264.0, tocolor(0,0,0,255), 0.6, "bankgothic", "left", "top", false, false, false )

dxDrawText( textQuit, 956.0, 243.0, 1224.0, 261.0, tocolor(255,0,0,255), 0.6, "bankgothic", "left", "top", false, false, false )

Anyonee pls

Link to comment
  
local screen_x, screen_y = guiGetScreenSize() 
local font = "bankgothic" 
local scale = 0.6 
  
dxDrawText(textQuit, screen_x*(959.0/1280), screen_y*(246.0/720), screen_x*(1227.0/1280), screen_y*(264.0/720), tocolor(0,0,0,255), scale, font, "left", "top", false, false, false) 
dxDrawText(textQuit, screen_x*(956.0/1280), screen_y*(243.0/720), screen_x*(1224.0/1280), screen_y*(261.0/720), tocolor(255,0,0,255), scale, font, "left", "top", false, false, false) 

Link to comment

Can u tell me how to do this, with more details ?

And adjust this to mee pls '-'

  
        dxDrawText( textJoin,943.0,217.0,1211.0,235.0,tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
  
        dxDrawText( textJoin,939.0,213.0,1207.0,231.0,tocolor(0,255,0,255),0.6,"bankgothic","left","top",false,false,false) 
    end 
) 
  

Link to comment
Can u tell me how to do this, with more details ?

And adjust this to mee pls '-'

  
        dxDrawText( textJoin,943.0,217.0,1211.0,235.0,tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
  
        dxDrawText( textJoin,939.0,213.0,1207.0,231.0,tocolor(0,255,0,255),0.6,"bankgothic","left","top",false,false,false) 
    end 
) 
  

What you did with 'textJoin'

Is that some variable or a string ?

If that's a string then just do from

textJoin 

to

"textJoin" 

If that's a variable then just do like:

local textJoin = "type something here" 
dxDrawText(textJoin,.....) 

Link to comment

Don't pay attention to CapY. I made it on 1.0.4, there is no reason for it to don't work at 1.1 or 1.1.1.

sw1 = 1280 
sw2 = guiGetScreenSize ( ) 
  
dxDrawText ( textJoin, (943/sw1)*sw2, (217/sw1)*sw2, (1211/sw1)*sw2, (235/sw1)*sw2, tocolor ( 0, 0, 0, 255 ), (0.6/sw1)*sw2, "bankgothic", "left", "top", false, false, false ) 
dxDrawText ( textJoin, (939/sw1)*sw2, (213/sw1)*sw2, (1207/sw1)*sw2, (231/sw1)*sw2, tocolor ( 0, 255, 0, 255 ), (0.6/sw1)*sw2, "bankgothic", "left", "top", false, false, false ) 

If my maths are not wrong because of the long time I haven't been on school (education is stopped due to student manifestations because of the poor "free" education system ftw), that should work, man.

Link to comment
Don't pay attention to CapY. I made it on 1.0.4, there is no reason for it to don't work at 1.1 or 1.1.1.
sw1 = 1280 
sw2 = guiGetScreenSize ( ) 
  
dxDrawText ( textJoin, (943/sw1)*sw2, (217/sw1)*sw2, (1211/sw1)*sw2, (235/sw1)*sw2, tocolor ( 0, 0, 0, 255 ), (0.6/sw1)*sw2, "bankgothic", "left", "top", false, false, false ) 
dxDrawText ( textJoin, (939/sw1)*sw2, (213/sw1)*sw2, (1207/sw1)*sw2, (231/sw1)*sw2, tocolor ( 0, 255, 0, 255 ), (0.6/sw1)*sw2, "bankgothic", "left", "top", false, false, false ) 

If my maths are not wrong because of the long time I haven't been on school (education is stopped due to student manifestations because of the poor "free" education system ftw), that should work, man.

Okay my bad :)

you faggot;)

Then just GUIEditor sucks.

Link to comment
Don't pay attention to CapY. I made it on 1.0.4, there is no reason for it to don't work at 1.1 or 1.1.1.
sw1 = 1280 
sw2 = guiGetScreenSize ( ) 
  
dxDrawText ( textJoin, (943/sw1)*sw2, (217/sw1)*sw2, (1211/sw1)*sw2, (235/sw1)*sw2, tocolor ( 0, 0, 0, 255 ), (0.6/sw1)*sw2, "bankgothic", "left", "top", false, false, false ) 
dxDrawText ( textJoin, (939/sw1)*sw2, (213/sw1)*sw2, (1207/sw1)*sw2, (231/sw1)*sw2, tocolor ( 0, 255, 0, 255 ), (0.6/sw1)*sw2, "bankgothic", "left", "top", false, false, false ) 

If my maths are not wrong because of the long time I haven't been on school (education is stopped due to student manifestations because of the poor "free" education system ftw), that should work, man.

its not accurate to calculate positions only based on screen width, because it only works if screen "dimension" or whatever is the same as 1280x720, for example it wont work correctly on a 1280x1024 screen..

so try this instead:

local screen_x, screen_y = guiGetScreenSize() 
  
-- diffX and diffY is how many times bigger the users screen resolution is compared to yours. 
local diffX = screen_x/1280 
local diffY = screen_y/720 
local font = "bankgothic" 
-- scaling is based on the difference of screen width. or set scale = 0.6 if you want text to have same size as your screen. looks better when only multiplying with diffX. 
local scale = 0.6*diffX 
  
dxDrawText(textJoin, 943.0*diffX, 217.0*diffY, 1211.0*diffX, 235.0*diffY, tocolor(0, 0, 0, 255), scale, font, "left", "top", false, false, false) 
dxDrawText(textJoin, 939.0*diffX, 213.0*diffY, 1207.0*diffX, 231.0*diffY, tocolor(0, 255, 0, 255), scale, font, "left", "top", false, false, false) 

Link to comment

Thanks for all tried to help me but isn't that I want. I want to adjust the text to all resolutions, example:

If a player enter in a server with 800 x 600 resolution, the text is adjusted to that resolution.

If a player enter in a server with 1280 x 720 resolution, the text is adjusted to that resolution.

If anyone can help, I say "Thanks very much Noob !" ahshahshzhzahzahahzzahsh :D

Link to comment
Thanks for all tried to help me but isn't that I want. I want to adjust the text to all resolutions, example:

If a player enter in a server with 800 x 600 resolution, the text is adjusted to that resolution.

If a player enter in a server with 1280 x 720 resolution, the text is adjusted to that resolution.

If anyone can help, I say "Thanks very much Noob !" ahshahshzhzahzahahzzahsh :D

thats whats it is doing.. did you even try them?

Link to comment
Yes, but it isn't what I want. When a player joins the DX text not adjust to my resolution. Just get the screen size and move that. You understand me ?

I dont understand what you mean. Do you mean that for example if on your screen your text is in the middle of the screen, and you also want it to be in the middle of the screen for all resolutions?

if not, draw a picture or something of an example.

Link to comment

I've created the DX text in GUIEditor, but I want to the text adjust to all resolutions. The text appear in same location but adjusted to the resolution to be visible to the player. If resolution is 800 x 600 the text appear under the HUD but adjusted to resolution, if resolution is, ex: 1280 x 720 - Adjust the text to the screen size but in the same location. Understand ?

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