Turbesz Posted February 5, 2021 Posted February 5, 2021 (edited) I wrote two texts with dxdrawtext and with same calculations for all resolution and one text is in the right place but another is not with same method... wth? anyone can help me? code: local sx, sy = guiGetScreenSize() function draw() dxDrawText("#FFB540Test text test text test text test text", sx/2-140-10,sy/2-320/2, 0, sy/2-515/2+36, tocolor(255,255,255,255), 1, Roboto, "left", "center",false,false,false,true) dxDrawText("text2 text2 text2 text2 text2 text2 text2 text2", sx/2+890-10,sy/2+940/2, 0,sy/2-515/2+36, tocolor(255,255,255,255), 1, Roboto, "center", "center",false,false,false,true) end addEventHandler("onClientRender",root,draw) the text with colorcode it is in a good place on every resolution but "text2" moves in another resolutions... why? Edited February 5, 2021 by Turbesz What if the only way not to feel bad, is to stop feeling, anything at all, forever? - Hannah Baker I cost a girl her life because I was afraid to love her... - Clay Jensen ~ 13 Reasons Why
Furzy Posted February 6, 2021 Posted February 6, 2021 Maybe your align's? One have left and center and another center and center FURZY'S CUSTOM WEAPON SYSTEM Discord: Furzy#4125
Turbesz Posted February 6, 2021 Author Posted February 6, 2021 4 hours ago, Furzy said: Maybe your align's? One have left and center and another center and center Maybe, but why? I want to put in the middle the second text and with left align it looks stupid So can i fix this somehow, without changing to left align? What if the only way not to feel bad, is to stop feeling, anything at all, forever? - Hannah Baker I cost a girl her life because I was afraid to love her... - Clay Jensen ~ 13 Reasons Why
Tekken Posted February 6, 2021 Posted February 6, 2021 local sx, sy = guiGetScreenSize() function draw() dxDrawText("#FFB540Test text test text test text test text", sx/2-140-10,sy/2-320/2, 0, sy/2-515/2+36, tocolor(255,255,255,255), 1, Roboto, "left", "center",false,false,false,true); local text = "text2 text2 text2 text2 text2 text2 text2 text2"; --define text local textSize = dxGetTextWidth(text, 1, Roboto, true); -- get the width of the text; local fontHeight = dxGetFontHeight(1, Roboto); -- get the height of the text; dxDrawText(text, sx/2-textSize/2, sy/2-fontHeight/2, sx, sy, tocolor(255,255,255,255), 1, Roboto, "center", "center",false,false,false,true); --draw the text in the middle of the screen! end addEventHandler("onClientRender", root, draw); You might do the same for the first one, just keep in mind the text align works like this (X + TEXT WIDTH) Resources I made: attachToBones - A newer bone_attach. Simple Level system - Just a simple level system. Do not PM me for help with leaked scripts! I WILL NOT HELP YOU!
Turbesz Posted February 6, 2021 Author Posted February 6, 2021 13 hours ago, Tekken said: local sx, sy = guiGetScreenSize() function draw() dxDrawText("#FFB540Test text test text test text test text", sx/2-140-10,sy/2-320/2, 0, sy/2-515/2+36, tocolor(255,255,255,255), 1, Roboto, "left", "center",false,false,false,true); local text = "text2 text2 text2 text2 text2 text2 text2 text2"; --define text local textSize = dxGetTextWidth(text, 1, Roboto, true); -- get the width of the text; local fontHeight = dxGetFontHeight(1, Roboto); -- get the height of the text; dxDrawText(text, sx/2-textSize/2, sy/2-fontHeight/2, sx, sy, tocolor(255,255,255,255), 1, Roboto, "center", "center",false,false,false,true); --draw the text in the middle of the screen! end addEventHandler("onClientRender", root, draw); You might do the same for the first one, just keep in mind the text align works like this (X + TEXT WIDTH) thanks, but i don't want to place it in the middle of the screen, I want put in the middle of a button. The first one is is in a perfect place, but the second one not (at my resolution yes, but other resolutions not, because moves, the first one doesn't do that). What if the only way not to feel bad, is to stop feeling, anything at all, forever? - Hannah Baker I cost a girl her life because I was afraid to love her... - Clay Jensen ~ 13 Reasons Why
Tekken Posted February 7, 2021 Posted February 7, 2021 A little example local sx, sy = guiGetScreenSize(); local scaleX,scaleY = 1920/sx, 1080/sy; -- replace 1920 and 1080 with your resolution! function draw() -- Let's say we want to create a button on the right side 20px away from the screen at 150px from the bottom; local xpos = 20*scaleX; local ypos = 150*scaleY; local text = "PRESS ME!"; local tx, ty = dxGetTextSize(text, 0, 1, 1, Roboto, true); dxDrawText(text, sx-tx-xpos, sy-ty-ypos, sx-xpos, sy-ypos, tocolor(255,255,255,255), 1, Roboto, "center", "center", false, false, false, true); end addEventHandler("onClientRender", root, draw); Take a look at this tutorial: Hope that helped you! 1 Resources I made: attachToBones - A newer bone_attach. Simple Level system - Just a simple level system. Do not PM me for help with leaked scripts! I WILL NOT HELP YOU!
Turbesz Posted February 8, 2021 Author Posted February 8, 2021 On 07/02/2021 at 09:53, Tekken said: A little example local sx, sy = guiGetScreenSize(); local scaleX,scaleY = 1920/sx, 1080/sy; -- replace 1920 and 1080 with your resolution! function draw() -- Let's say we want to create a button on the right side 20px away from the screen at 150px from the bottom; local xpos = 20*scaleX; local ypos = 150*scaleY; local text = "PRESS ME!"; local tx, ty = dxGetTextSize(text, 0, 1, 1, Roboto, true); dxDrawText(text, sx-tx-xpos, sy-ty-ypos, sx-xpos, sy-ypos, tocolor(255,255,255,255), 1, Roboto, "center", "center", false, false, false, true); end addEventHandler("onClientRender", root, draw); Take a look at this tutorial: Hope that helped you! thanks What if the only way not to feel bad, is to stop feeling, anything at all, forever? - Hannah Baker I cost a girl her life because I was afraid to love her... - Clay Jensen ~ 13 Reasons Why
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