Jump to content

Position center


papam77

Recommended Posts

Posted

Hello.

Is possible to make as in html

if yes how can make center in lua ?

I wanna add to center this

dxDrawText("Choose an arena", 2+160/2, 15, 160, 24, tocolor(255, 255, 255, 255), 3.00, "bankgothic", "left", "top", false, false, true, false, false) 

Posted

Did you read the wiki page ?

alignX: horizontal alignment of the text within the bounding box. Can be "left", "center" or "right".

alignY: vertical alignment of the text within the bounding box. Can be "top", "center" or "bottom".

try to set it to "center","center" and see what happened .

Posted
Did you read the wiki page ?

alignX: horizontal alignment of the text within the bounding box. Can be "left", "center" or "right".

alignY: vertical alignment of the text within the bounding box. Can be "top", "center" or "bottom".

try to set it to "center","center" and see what happened .

What happened ? Text isn't on my monitor...

Posted

I Get this code from SolidSnake :

function RelativeToAbsolute( X, Y ) 
        local rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 

convert it to relative and then use this function ^^ .

And you're code should be :

function RelativeToAbsolute( X, Y ) 
         rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 
  
addEventHandler("onClientRender",getRootElement(),  
function( )  
    local x,y = RelativeToAbsolute(0.08, 0.02) 
    dxDrawText("Choose an arena",x,y,rX, rY, tocolor(255, 255, 255, 255), 3.00, "bankgothic", "center", "center", false, false, true, false, false) 
end 
) 

Not tested !!

Posted
I Get this code from SolidSnake :

function RelativeToAbsolute( X, Y ) 
        local rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 

convert it to relative and then use this function ^^ .

And you're code should be :

function RelativeToAbsolute( X, Y ) 
         rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 
  
addEventHandler("onClientRender",getRootElement(),  
function( )  
    local x,y = RelativeToAbsolute(0.08, 0.02) 
    dxDrawText("Choose an arena",x,y,rX, rY, tocolor(255, 255, 255, 255), 3.00, "bankgothic", "center", "center", false, false, true, false, false) 
end 
) 

Not tested !!

Thank you work it ;)

And how can use dxDrawImage as button ?

Posted
You can make a invisible buttons and do what you want :P .

Oh this ?

GUIEditor = { 
    button = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.button[1] = guiCreateButton(451, 205, 388, 289, "", false) 
        guiSetAlpha(GUIEditor.button[1], 0.28)     
    end 
) 

Posted
You can make a invisible buttons and do what you want :P .

Oh this ?

GUIEditor = { 
    button = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.button[1] = guiCreateButton(451, 205, 388, 289, "", false) 
        guiSetAlpha(GUIEditor.button[1], 0.28)     
    end 
) 

Exactly and make the alpha 0 :D and make the buttons relative !! from the guieditor options .

Posted
You can make a invisible buttons and do what you want :P .

Oh this ?

GUIEditor = { 
    button = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.button[1] = guiCreateButton(451, 205, 388, 289, "", false) 
        guiSetAlpha(GUIEditor.button[1], 0.28)     
    end 
) 

Exactly and make the alpha 0 :D and make the buttons relative !! from the guieditor options .

kk ty :D

Posted
Use that same function .
addEventHandler("onClientResourceStart", resourceRoot, 
    function()     
    end 
) 
  
function RelativeToAbsolute( X, Y ) 
         rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 
  
addEventHandler("onClientRender",getRootElement(), 
function( ) 
    local x,y = RelativeToAbsolute(0.00, -0.90) 
    dxDrawImage(0, 0, 1920, 1080, "img/lobby-bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
end 
) 

If i have this he still see it as already saw. Is any function how can set it to max resolution on every monitor ?

Posted

Try this ;

function RelativeToAbsolute( X, Y ) 
         rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 
  
addEventHandler("onClientRender",getRootElement(), 
function( ) 
    local x,y = RelativeToAbsolute(0.00, -0.90) 
    dxDrawImage(x,y,rX,rY,"img/lobby-bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
end 
) 

Not tested .

Posted
Try this ;

function RelativeToAbsolute( X, Y ) 
         rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 
  
addEventHandler("onClientRender",getRootElement(), 
function( ) 
    local x,y = RelativeToAbsolute(0.00, -0.90) 
    dxDrawImage(x,y,rX,rY,"img/lobby-bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
end 
) 

Not tested .

It looks as here: http://www.img.tpx.cz/uploads/LikeApro.png = 1920x1080

http://www.img.tpx.cz/uploads/gta_sa%20 ... -05-19.png 1024x768

  • Moderators
Posted

why relative? it will only strech and most of the time in the wrong way.

pls fill in the size. rX,rY

Posted
Make it relative and put the x,y pos here :

local x,y = RelativeToAbsolute(x,y) 

And try !

Error

'<eof>' expected near 'end' 
line 27 

Full LUA code

------------------------------------------------- 
-- Bind Key 
------------------------------------------------- 
bindKey("F1", "down", toggleLobbyWindow) 
------------------------------------------------- 
-- Components 
------------------------------------------------- 
showCursor ( true ) 
showChat ( true ) 
showPlayerHudComponent ( source, "ammo", false ) 
showPlayerHudComponent ( source, "weapon", false )  
  
  
------------------------------------------------- 
-- Background and Images 
------------------------------------------------- 
addEventHandler("onClientResourceStart", resourceRoot, 
    function()     
    end 
) 
  
local x,y = RelativeToAbsolute(x,y) 
         rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 
  
addEventHandler("onClientRender",getRootElement(), 
function( ) 
    local x,y = RelativeToAbsolute(0.00, -0.90) 
    dxDrawImage(0, 0, 1920, 1080, "img/lobby-bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
end 
) 
  
  
  
------------------------------------------------- 
addEventHandler("onClientResourceStart", resourceRoot, 
    function()     
    end 
) 
  
function RelativeToAbsolute( X, Y ) 
         rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 
  
addEventHandler("onClientRender",getRootElement(), 
function( ) 
    local x,y = RelativeToAbsolute(0.00, -0.90) 
    dxDrawText("Choose an arena",x,y,rX, rY, tocolor(255, 255, 255, 255), 2.50, "bankgothic", "center", "center", false, false, true, false, false) 
end 
) 
  
  
  
------------------------------------------------- 
-- Buttons 
------------------------------------------------- 
addEventHandler("onClientResourceStart", resourceRoot, 
    function()     
    end 
) 
  
addEventHandler("onClientRender",getRootElement(), 
function( ) 
    dxDrawImage(100, 100, 300, 300, "img/dm.png", 0, 0, 0, tocolor(255, 255, 255, 200), true) 
end 
) 

  • Moderators
Posted
Error

'<eof>' expected near 'end' 
line 27 

Full LUA code

------------------------------------------------- 
-- Bind Key 
------------------------------------------------- 
bindKey("F1", "down", toggleLobbyWindow) 
------------------------------------------------- 
-- Components 
------------------------------------------------- 
showCursor ( true ) 
showChat ( true ) 
showPlayerHudComponent ( source, "ammo", false ) 
showPlayerHudComponent ( source, "weapon", false )  
  
  
------------------------------------------------- 
-- Background and Images 
------------------------------------------------- 
addEventHandler("onClientResourceStart", resourceRoot, 
    function()     
    end 
) 
  
function RelativeToAbsolute( X, Y ) -- you forgot the function. 
         rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 
  
addEventHandler("onClientRender",getRootElement(), 
function( ) 
    local x,y = RelativeToAbsolute(0.00, -0.90) 
    dxDrawImage(0, 0, 1920, 1080, "img/lobby-bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
end 
) 
  
  
  
------------------------------------------------- 
addEventHandler("onClientResourceStart", resourceRoot, 
    function()     
    end 
) 
  
function RelativeToAbsolute( X, Y ) 
         rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 
  
addEventHandler("onClientRender",getRootElement(), 
function( ) 
    local x,y = RelativeToAbsolute(0.00, -0.90) 
    dxDrawText("Choose an arena",x,y,rX, rY, tocolor(255, 255, 255, 255), 2.50, "bankgothic", "center", "center", false, false, true, false, false) 
end 
) 
  
  
  
------------------------------------------------- 
-- Buttons 
------------------------------------------------- 
addEventHandler("onClientResourceStart", resourceRoot, 
    function()     
    end 
) 
  
addEventHandler("onClientRender",getRootElement(), 
function( ) 
    dxDrawImage(100, 100, 300, 300, "img/dm.png", 0, 0, 0, tocolor(255, 255, 255, 200), true) 
end 
) 

You forgot a function! (fixed)

You can also try to center it, instead of scaling it. (as your title says)

  
-- for picture. 
local X, Y = guiGetScreenSize()  
local hX, hY = (X/2)-(1920/2), (Y/2)-(1080/2) 
  
addEventHandler("onClientRender",getRootElement(), 
function( ) 
    dxDrawImage(hX, hY,1920,1080,"img/lobby-bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
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...