Jump to content

Position center


papam77

Recommended Posts

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) 

Link to comment

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 .

Link to comment
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...

Link to comment

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

Link to comment
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 ?

Link to comment
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 
) 

Link to comment
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 .

Link to comment
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

Link to comment
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 ?

Link to comment

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 .

Link to comment
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

Link to comment
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 
) 

Link to comment
  • Moderators
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 
) 
-------------------------------------------------------------------- 
  

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