Chaos Posted January 30, 2014 Share Posted January 30, 2014 hi, i want to make dxdraw on same place in all resolutions i tried this but won't stay on same place local screenW, screenH = guiGetScreenSize() function dxdraw() dxDrawText("EXAMPLE", (screenW - 206) , (screenH - 59) , 1028, 97, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) end addEventHandler("onClientRender",root,dxdraw) please can you help me ? Link to comment
Karuzo Posted January 30, 2014 Share Posted January 30, 2014 try this : local screenW, screenH = guiGetScreenSize() function dxdraw() dxDrawText("EXAMPLE", (screenW - 206) / 2, (screenH - 59) /2.5 , 1028, 97, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) end addEventHandler("onClientRender",root,dxdraw) 2 = x coordinate 2.5 = y coordinate , just change them. Link to comment
Karuzo Posted January 30, 2014 Share Posted January 30, 2014 So ? what are you trying to say ? Link to comment
Chaos Posted January 30, 2014 Author Share Posted January 30, 2014 it's not staying on same position Link to comment
Karuzo Posted January 30, 2014 Share Posted January 30, 2014 Which one should be the right one ? And show me youre code pls. Link to comment
Chaos Posted January 30, 2014 Author Share Posted January 30, 2014 first pic it was 1024×768 sec pic it was 800×600 and i just used your code Link to comment
Karuzo Posted January 30, 2014 Share Posted January 30, 2014 Oh forgot that completely , you have to set the screenW , screenH of the Text size also , i mean this two : 1028, 97 (screenW - 1028) / 2) + 1028, (screenH - 97) / 2.5) + 97, Link to comment
Chaos Posted January 30, 2014 Author Share Posted January 30, 2014 you mean like this ? local screenW, screenH = guiGetScreenSize() function dxdraw() dxDrawText("EXAMPLE", (screenW - 1028) / 2) + 1028, (screenH - 97) / 2.5) + 97 , 1028, 97, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) end addEventHandler("onClientRender",root,dxdraw) Link to comment
Karuzo Posted January 30, 2014 Share Posted January 30, 2014 No, try that: local screenW, screenH = guiGetScreenSize() function dxdraw() dxDrawText("EXAMPLE", (screenW - 206) / 2, (screenH - 59) /2.5 , ((screenW - 1028) / 2.1) + 1028, ((screenH - 97) / 2.5) + 97, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) end addEventHandler("onClientRender",root,dxdraw) Link to comment
Chaos Posted January 30, 2014 Author Share Posted January 30, 2014 look same problem not staying on same position Link to comment
Chaos Posted January 30, 2014 Author Share Posted January 30, 2014 local screenW, screenH = guiGetScreenSize() function dxdraw() dxDrawText("EXAMPLE", (screenW - 206) / 2, (screenH - 59) /2.5 , ((screenW - 1028) / 2.1) + 1028, ((screenH - 97) / 2.5) + 97, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) end addEventHandler("onClientRender",root,dxdraw) Link to comment
Bonsai Posted January 30, 2014 Share Posted January 30, 2014 You can't use absolute values. E.g. screenW - 206, 1600-206 or 800-206, its a big difference. You have to use values relative to the size. screenw*0.9. This will always be the same position. Link to comment
Chaos Posted January 30, 2014 Author Share Posted January 30, 2014 function DXtext () local sWidth,sHeight = guiGetScreenSize() -- The variables dxDrawText("Hello World!",sWidth*0.668, sHeight*0.952, sWidth*0.715, sHeight*0.997,tocolor(0,255,255,175),1.0,"bankgothic","left","top",false,false,false) end addEventHandler ( "onClientRender", getRootElement(), DXtext ) i tried that example in wiki and still same problem Link to comment
Karuzo Posted January 30, 2014 Share Posted January 30, 2014 Try the dxDrawText example : local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) function createText ( ) local playerX, playerY, playerZ = getElementPosition ( localPlayer ) -- Get our player's coordinates. local playerZoneName = getZoneName ( playerX, playerY, playerZ ) -- Get name of the zone the player is in. -- Draw zone name text's shadow. dxDrawText ( playerZoneName, 44, screenHeight - 41, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) -- Draw zone name text. dxDrawText ( playerZoneName, 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) end function HandleTheRendering ( ) addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. end addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) Link to comment
Gallardo9944 Posted January 30, 2014 Share Posted January 30, 2014 (edited) local x,y = guiGetScreenSize() local text = "My n*gga, my n*gga..." local scale = 2 local length = dxGetTextWidth(text,scale,"default-bold") local height = dxGetFontHeight(scale,"default-bold") function renderText() dxDrawText(text,x/2-length/2,y/2-height/2,x,y,tocolor(255,255,255,255),scale,"default-bold") -- centered text end addEventHandler("onClientRender",getRootElement(),renderText) EDIT: found a small mistake. Changed it. Edited January 31, 2014 by Guest Link to comment
Chaos Posted January 30, 2014 Author Share Posted January 30, 2014 local x,y = guiGetScreenSize() local text = "Example" local scale = 2 local length = dxGetTextWidth(text,scale,"default-bold") local height = dxGetFontHeight(scale,"default-bold") function renderText() dxDrawText(text,x/1.05-length/2,y-height/1.20,x,y,tocolor(255,255,255,255),scale,"default-bold") -- centered text end addEventHandler("onClientRender",getRootElement(),renderText) look Link to comment
Bonsai Posted January 30, 2014 Share Posted January 30, 2014 How can such an easy function cause such a long discussion? What is wrong there? Link to comment
Chaos Posted January 30, 2014 Author Share Posted January 30, 2014 i just need it stay on same place accurately Link to comment
Bonsai Posted January 30, 2014 Share Posted January 30, 2014 i just need it stay on same place accurately If you use x*0.9 for example, it will always be on the same position on x axis. At least as long as the screen format stays the same. 16:9 will not look like 4:3. Link to comment
xXMADEXx Posted January 30, 2014 Share Posted January 30, 2014 This: local screenW, screenH = guiGetScreenSize() function dxdraw() dxDrawText("EXAMPLE", 0, 0, screenW, screenH, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "right", false, false, true, false, false) end addEventHandler("onClientRender",root,dxdraw) Link to comment
Chaos Posted January 31, 2014 Author Share Posted January 31, 2014 This: local screenW, screenH = guiGetScreenSize() function dxdraw() dxDrawText("EXAMPLE", 0, 0, screenW, screenH, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "right", false, false, true, false, false) end addEventHandler("onClientRender",root,dxdraw) Useless 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