Jump to content

How to discover the coordinates using guiGetScreenSize() ?


drk

Recommended Posts

Posted

Whit Dx the best is to check the client screen size and then if zise .....=1280x720 then post x,y,z=...... elseif ....

or use guiLabel and use bool relative as true and then its automaticaly sized and moved

Posted
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 ?

Thats how the script i wrote to you is working.. or is it not?

Posted

I know this script is going to be hard but the best way is to get the screen size and make if...elseif statements, but between all those, you have to change the size

Posted

could you take a shot screen to see where is the dx on the screen?

Edit:

try this should work 99.9%

function AbsoluteToRelativ2( X, Y ) 
    local rX, rY = guiGetScreenSize() 
    local x = math.floor(X*rX/1280) 
    local y = math.floor(Y*rY/720) 
    return x, y  
end 
  
function DXdraw() 
    local x1, y1 = AbsoluteToRelativ2( 959,246 ) 
    local x2, y2 = AbsoluteToRelativ2( 956,243 ) 
    dxDrawText("textQuit", x1, y1, 1224, 264, tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
    dxDrawText("textQuit", x2, y2, 1224, 261, tocolor(255,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
end 
addEventHandler("onClientRender", root, DXdraw) 

Posted
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 ?

Thats how the script i wrote to you is working.. or is it not?

Is working but isn't what I want, but thanks for try helping me.

Posted
could you take a shot screen to see where is the dx on the screen?

Edit:

try this should work 99.9%

function AbsoluteToRelativ2( X, Y ) 
    local rX, rY = guiGetScreenSize() 
    local x = math.floor(X*rX/1280) 
    local y = math.floor(Y*rY/720) 
    return x, y  
end 
  
function DXdraw() 
    local x1, y1 = AbsoluteToRelativ2( 959,246 ) 
    local x2, y2 = AbsoluteToRelativ2( 956,243 ) 
    dxDrawText("textQuit", x1, y1, 1224, 264, tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
    dxDrawText("textQuit", x2, y2, 1224, 261, tocolor(255,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
end 
addEventHandler("onClientRender", root, DXdraw) 

Ok, I will try. And sorry for what I said in another post. When I'm nervous I talk nonsense.

Posted

Don't worked, I tried this and this:

function AbsoluteToRelativ2( X, Y ) 
    local rX, rY = guiGetScreenSize() 
    if ( rX == 1280 ) and ( rY == 720 ) then 
    local x = math.floor(X*rX/1280) 
    local y = math.floor(Y*rY/720) 
    return x, y 
    end 
    if ( rX == 1280 ) and ( rY == 600 ) then 
    local x = math.floor(X*rX/1280) 
    local y = math.floor(Y*rY/600) 
    return x, y 
    end 
    if ( rX == 800 ) and ( rY == 600 ) then 
    local x = math.floor(X*rX/800) 
    local y = math.floor(Y*rY/600) 
    return x, y 
    end 
    if ( rX == 640 ) and ( rY == 480 ) then 
    local x = math.floor(X*rX/640) 
    local y = math.floor(Y*rY/480) 
    return x, y 
  end 
end 
  
addEventHandler ( "onClientRender", root, 
    local x1, y1 = AbsoluteToRelativ2( 959,246 ) 
    local x2, y2 = AbsoluteToRelativ2( 956,243 ) 
    local x3, y3 = AbsoluteToRelativ2( 943,217 ) 
    local x4, y4 = AbsoluteToRelativ2( 939,213 ) 
    dxDrawText( textQuit, x1, y1, 1224, 264, tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
    dxDrawText( textQuit, x2, y2, 1224, 261, tocolor(255,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
    dxDrawText( textJoin, x3, y3, 1211.0, 235.0,tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
    dxDrawText( textJoin, x4, y4, 1207.0,231.0,tocolor(0,255,0,255),0.6,"bankgothic","left","top",false,false,false) 
end 
) 

And don't work. Please anyone help.

Posted

what is doesn't work?

i tested this and working with all resolution

i don't understand what is not work

can you put an image?

function AbsoluteToRelativ2( X, Y ) 
    local rX, rY = guiGetScreenSize() 
    local x = math.floor(X*rX/1280) 
    local y = math.floor(Y*rY/720) 
    return x, y 
end 
  
function DXdraw() 
    local x1, y1 = AbsoluteToRelativ2( 959,246 ) 
    local x2, y2 = AbsoluteToRelativ2( 956,243 ) 
    dxDrawText("textQuit", x1, y1, 1224, 264, tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
    dxDrawText("textQuit", x2, y2, 1224, 261, tocolor(255,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
end 
addEventHandler("onClientRender", root, DXdraw) 

Posted

you want the player name showing in the screen when he is join - quit?

ok where is your script? the server won't appear anything by his self -_-""

what i post was just adjust to all resolutions

Posted
  
function AbsoluteToRelativ2( X, Y ) 
    local rX, rY = guiGetScreenSize() 
    local x = math.floor(X*rX/1280) 
    local y = math.floor(Y*rY/720) 
    return x, y 
end 
  
addEventHandler ( "onClientRender", root, 
    local x1, y1 = AbsoluteToRelativ2( 959,246 ) 
    local x2, y2 = AbsoluteToRelativ2( 956,243 ) 
    local x3, y3 = AbsoluteToRelativ2( 943,217 ) 
    local x4, y4 = AbsoluteToRelativ2( 939,213 ) 
    dxDrawText( textQuit, x1, y1, 1224, 264, tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
    dxDrawText( textQuit, x2, y2, 1224, 261, tocolor(255,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
    dxDrawText( textJoin, x3, y3, 1211.0, 235.0,tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
    dxDrawText( textJoin, x4, y4, 1207.0,231.0,tocolor(0,255,0,255),0.6,"bankgothic","left","top",false,false,false) 
end 
) 
  

I tried this too:

  
function AbsoluteToRelativ2( X, Y ) 
    local rX, rY = guiGetScreenSize() 
    if ( rX == 1280 ) and ( rY == 720 ) then 
    local x = math.floor(X*rX/1280) 
    local y = math.floor(Y*rY/720) 
    return x, y 
    end 
    if ( rX == 1280 ) and ( rY == 600 ) then 
    local x = math.floor(X*rX/1280) 
    local y = math.floor(Y*rY/600) 
    return x, y 
    end 
    if ( rX == 800 ) and ( rY == 600 ) then 
    local x = math.floor(X*rX/800) 
    local y = math.floor(Y*rY/600) 
    return x, y 
    end 
    if ( rX == 640 ) and ( rY == 480 ) then 
    local x = math.floor(X*rX/640) 
    local y = math.floor(Y*rY/480) 
    return x, y 
  end 
end 
  
addEventHandler ( "onClientRender", root, 
    local x1, y1 = AbsoluteToRelativ2( 959,246 ) 
    local x2, y2 = AbsoluteToRelativ2( 956,243 ) 
    local x3, y3 = AbsoluteToRelativ2( 943,217 ) 
    local x4, y4 = AbsoluteToRelativ2( 939,213 ) 
    dxDrawText( textQuit, x1, y1, 1224, 264, tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
    dxDrawText( textQuit, x2, y2, 1224, 261, tocolor(255,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
    dxDrawText( textJoin, x3, y3, 1211.0, 235.0,tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
    dxDrawText( textJoin, x4, y4, 1207.0,231.0,tocolor(0,255,0,255),0.6,"bankgothic","left","top",false,false,false) 
end 
) 

But don't work.

And don't have any error, I uused /debugscript 3 ;)

Posted

You forgot function() here:

addEventHandler ( "onClientRender", root, 
        local x1, y1 = AbsoluteToRelativ2( 959,246 ) 
        local x2, y2 = AbsoluteToRelativ2( 956,243 ) 
        local x3, y3 = AbsoluteToRelativ2( 943,217 ) 
        local x4, y4 = AbsoluteToRelativ2( 939,213 ) 
        dxDrawText( "textQuit", x1, y1, 1224, 264, tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
        dxDrawText( "textQuit", x2, y2, 1224, 261, tocolor(255,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
        dxDrawText( "textJoin", x3, y3, 1211.0, 235.0,tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
        dxDrawText( "textJoin", x4, y4, 1207.0,231.0,tocolor(0,255,0,255),0.6,"bankgothic","left","top",false,false,false) 
end) 

so write function() after root, .. like this:

addEventHandler ( "onClientRender", root, 
function() 
        local x1, y1 = AbsoluteToRelativ2( 959,246 ) 
        local x2, y2 = AbsoluteToRelativ2( 956,243 ) 
        local x3, y3 = AbsoluteToRelativ2( 943,217 ) 
        local x4, y4 = AbsoluteToRelativ2( 939,213 ) 
        dxDrawText( "textQuit", x1, y1, 1224, 264, tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
        dxDrawText( "textQuit", x2, y2, 1224, 261, tocolor(255,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
        dxDrawText( "textJoin", x3, y3, 1211.0, 235.0,tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) 
        dxDrawText( "textJoin", x4, y4, 1207.0,231.0,tocolor(0,255,0,255),0.6,"bankgothic","left","top",false,false,false) 
end) 

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