iiv03 Posted December 21, 2019 Posted December 21, 2019 (edited) hey i have a little problem here when converting a screen from 1600x900 to 800x600 i used some scaling tutorial @IIYAMA so i did loop and had some problem with screen sizes my screen screen user's 800x600: code: local devScreenX = 1920 local devScreenY = 1080 local screenX, screenY = guiGetScreenSize() local scaleValue = screenY / devScreenY scaleValue = math.max(scaleValue, 0.65) -- < here add the limit addEventHandler("onClientResourceStart",resourceRoot, function() setPlayerHudComponentVisible("all", false) end) local dash = { menu = {"Hello There","Hello There2","Hello There3","Hello There4","Hello There5","Hello There6"}, } addEventHandler("onClientRender", root, function () -- create a scaled size local sizeX = scaleValue * 180 local sizeY = scaleValue * 40 -- get the center of the screen local centerX = screenX - screenX local centerY = screenY / 2 -- calculate the starting point of the rectangle local startRectangleX = centerX local startRectangleY = centerY - (sizeY / 0.5) local offsetY = 0 dxDrawRectangle ( startRectangleX, startRectangleY, sizeX, sizeY, tocolor ( 0, 0, 0, 180 ) ) offsetY = offsetY + startRectangleY*0.15 dxDrawRectangle ( startRectangleX, startRectangleY+offsetY, sizeX, sizeY, tocolor ( 0, 0, 0, 180 ) ) offsetY = offsetY + startRectangleY*0.15 dxDrawRectangle ( startRectangleX, startRectangleY+offsetY, sizeX, sizeY, tocolor ( 0, 0, 0, 180 ) ) offsetY = offsetY + startRectangleY*0.15 dxDrawRectangle ( startRectangleX, startRectangleY+offsetY, sizeX, sizeY, tocolor ( 0, 0, 0, 180 ) ) offsetY = offsetY + startRectangleY*0.15 dxDrawRectangle ( startRectangleX, startRectangleY+offsetY, sizeX, sizeY, tocolor ( 0, 0, 0, 180 ) ) offsetY = offsetY + startRectangleY*0.15 dxDrawRectangle ( startRectangleX, startRectangleY+offsetY, sizeX, sizeY, tocolor ( 0, 0, 0, 180 ) ) --[[local offsetY = 0 local posY = startRectangleY * 0.022 dxDrawText("Hello There!", startRectangleX, startRectangleY+posY, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top") offsetY = offsetY + startRectangleY * 0.17 dxDrawText("Hello There!", startRectangleX, startRectangleY+offsetY, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top") offsetY = offsetY + startRectangleY * 0.15 dxDrawText("Hello There!", startRectangleX, startRectangleY+offsetY, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top") offsetY = offsetY + startRectangleY * 0.155 dxDrawText("Hello There!", startRectangleX, startRectangleY+offsetY, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top") offsetY = offsetY + startRectangleY * 0.145 dxDrawText("Hello There!", startRectangleX, startRectangleY+offsetY, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top") offsetY = offsetY + startRectangleY * 0.15 dxDrawText("Hello There!", startRectangleX, startRectangleY+offsetY, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top")]] -- THIS WORK WITHOUT LOOP local posY = startRectangleY * 1.88 for i,v in ipairs(dash.menu) do dxDrawText(v, startRectangleX, posY-startRectangleY+i*57, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top") end end) Edited December 21, 2019 by xFabel
Moderators IIYAMA Posted December 21, 2019 Moderators Posted December 21, 2019 (Mobile) dxDrawText(v, startRectangleX, posY-startRectangleY+i*57, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top") > This is not scaled. Take a closer look at how you did that with the rectangle. dxDrawText(v, startRectangleX, posY-startRectangleY+i*57, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top") > dxDrawText doesn't make use of sizes. But end points. (startpoint + size = endpoint) Overall, > mirror what you did with the rectangle. > use endpoints instead of the size. > center the text vertically. Between the 2 startpoints and the 2 endpoints. 1 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
iiv03 Posted December 21, 2019 Author Posted December 21, 2019 (edited) thank you for answer but what u mean between start and end point? dxDrawText(v, startRectangleX, startRectangleY, sizeX,startRectangleY+sizeY+i,tocolor(255,255,255,255),1,"default-bold","right","center") -- loop almost like this but when i hit (i)*70 the text goes down below It's like I'm moving Y and I haven't touched it Edited December 21, 2019 by xFabel
Moderators IIYAMA Posted December 21, 2019 Moderators Posted December 21, 2019 3 hours ago, xFabel said: but what u mean between start and end point? startX = 0 startY = 0 sizeX = 100 sizeY = 20 endX = startX + sizeX endY = startY + sizeY dxDrawText("text", startX, startY, endX, endY, ... Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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