papam77 Posted April 28, 2013 Share Posted April 28, 2013 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
iPrestege Posted April 28, 2013 Share Posted April 28, 2013 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
papam77 Posted April 28, 2013 Author Share Posted April 28, 2013 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
iPrestege Posted April 28, 2013 Share Posted April 28, 2013 Will check this out ; https://forum.multitheftauto.com/viewtopic.php?f=91&t=58189 Link to comment
papam77 Posted April 28, 2013 Author Share Posted April 28, 2013 I don't understand how to use it Link to comment
iPrestege Posted April 28, 2013 Share Posted April 28, 2013 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
papam77 Posted April 28, 2013 Author Share Posted April 28, 2013 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
iPrestege Posted April 28, 2013 Share Posted April 28, 2013 You can make a invisible buttons and do what you want . Link to comment
papam77 Posted April 28, 2013 Author Share Posted April 28, 2013 You can make a invisible buttons and do what you want . 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
iPrestege Posted April 28, 2013 Share Posted April 28, 2013 You can make a invisible buttons and do what you want . 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 and make the buttons relative !! from the guieditor options . Link to comment
papam77 Posted April 28, 2013 Author Share Posted April 28, 2013 You can make a invisible buttons and do what you want . 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 and make the buttons relative !! from the guieditor options . kk ty Link to comment
papam77 Posted April 28, 2013 Author Share Posted April 28, 2013 And i have background pic 1920x1080 but i wanna it for everybody. My friend with smaller resolution see it too big Link to comment
papam77 Posted April 28, 2013 Author Share Posted April 28, 2013 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
iPrestege Posted April 28, 2013 Share Posted April 28, 2013 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
papam77 Posted April 28, 2013 Author Share Posted April 28, 2013 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
iPrestege Posted April 28, 2013 Share Posted April 28, 2013 I Can't see the pictuer i don't know why try another upload site . Link to comment
papam77 Posted April 28, 2013 Author Share Posted April 28, 2013 http://www.upload.ee/image/3270718/gta_sa_2013-04-28_16-26-05-19.png 1024x768 http://www.upload.ee/image/3270726/LikeApro.png 1920x1080 Link to comment
iPrestege Posted April 28, 2013 Share Posted April 28, 2013 Hmm...are sure about the relative position ? You get it from the guieditor or from where? Link to comment
papam77 Posted April 28, 2013 Author Share Posted April 28, 2013 Background isn't relative because i can't make relative in dx Link to comment
iPrestege Posted April 28, 2013 Share Posted April 28, 2013 Make it relative and put the x,y pos here : local x,y = RelativeToAbsolute(x,y) And try ! Link to comment
Moderators IIYAMA Posted April 28, 2013 Moderators Share Posted April 28, 2013 why relative? it will only strech and most of the time in the wrong way. pls fill in the size. rX,rY Link to comment
papam77 Posted April 28, 2013 Author Share Posted April 28, 2013 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 IIYAMA Posted April 28, 2013 Moderators Share Posted April 28, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now