Tokio Posted August 30, 2019 Posted August 30, 2019 This is in 1440x900 (in my resolution): This is in 1920x1080: I calculate the dx elements position with this: local sx_, sy_ = guiGetScreenSize() local sx, sy = sx_/1440, sy_/900 And i draw dx elements like this: dxDrawRectangle(sx / 2 + 290, sy / 2 +240,850,65,tocolor(0,0,0,200)) What wrong??? How can i fix this problem?? My servers: Fun: Derby(DD):
Moderators IIYAMA Posted August 30, 2019 Moderators Posted August 30, 2019 1 hour ago, Tokio said: What wrong??? How can i fix this problem?? Absolute values like 290px and 240px do not scale, without a multiplier. There is a tutorial for scaling DX (+useful for other user interfaces). 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
Tokio Posted August 30, 2019 Author Posted August 30, 2019 4 minutes ago, IIYAMA said: Absolute values like 290px and 240px do not scale, without a multiplier. There is a tutorial for scaling DX (+useful for other user interfaces). uhm, what is multiplier? My servers: Fun: Derby(DD):
Moderators IIYAMA Posted August 30, 2019 Moderators Posted August 30, 2019 (edited) 6 minutes ago, Tokio said: uhm, what is multiplier? It is nothing magic. Just a value you use to multiply another value, so it gets bigger, smaller or unchanged. local bananas = 100 local multiplier = 0.5 -- = 50% bananas = bananas * multiplier print(bananas) -- 50 bananas Edited August 30, 2019 by IIYAMA 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
Tokio Posted August 31, 2019 Author Posted August 31, 2019 12 hours ago, IIYAMA said: It is nothing magic. Just a value you use to multiply another value, so it gets bigger, smaller or unchanged. local bananas = 100 local multiplier = 0.5 -- = 50% bananas = bananas * multiplier print(bananas) -- 50 bananas I used a multiplier but didn't help much My servers: Fun: Derby(DD):
Moderators IIYAMA Posted August 31, 2019 Moderators Posted August 31, 2019 33 minutes ago, Tokio said: I used a multiplier but didn't help much I did send you a tutorial in my last reply, so I assume you did read it and applied it to you code? This one. Well show me what you did. 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
Tokio Posted August 31, 2019 Author Posted August 31, 2019 6 hours ago, IIYAMA said: I did send you a tutorial in my last reply, so I assume you did read it and applied it to you code? This one. Well show me what you did. The dxdrawtext why move in 1920x1080? dxDrawText("SuperFun - Szórakozó szerver",(sx_-1910) * xm, (sy_/2+20) * ym, 1130 * xm, 75 * ym, tocolor(255,255,255,255),1.00,font2,"center","center") My servers: Fun: Derby(DD):
Cacaroto Posted August 31, 2019 Posted August 31, 2019 I use another way which I think is easier to use: local sX, sY = guiGetScreenSize() --IMAGINE THAT WE WILL DRAW A RECTANGLE myXRes = Your width value of your resolution myYRes = Your height value of your resolution function drawMyRectangle() dxDrawRectangle((position/myXRes)*sX, (position/myYRes)*sY, (sizeX/myXRes)*sX, (sizeY/myYRes)*sY, tocolor(20, 190, 50, 200), false) end addEventHandler("onClientRender", root, drawMyRectangle) Hope I help you!
Moderators IIYAMA Posted August 31, 2019 Moderators Posted August 31, 2019 1 hour ago, Tokio said: The dxdrawtext why move in 1920x1080? dxDrawText("SuperFun - Szórakozó szerver",(sx_-1910) * xm, (sy_/2+20) * ym, 1130 * xm, 75 * ym, tocolor(255,255,255,255),1.00,font2,"center","center") You subtract an absolute values from the player his resolution, before applying the multiplier. (sx_-1910) * xm That is not a logic calculation. At least follow the tutorial: local devScreenX = 1440 local devScreenY = 900 local screenX, screenY = guiGetScreenSize() local scaleValue = screenY / devScreenY This is more or less how I do it and keep things clean. (untested) local box = { startX = screenX * 0.25, startY = screenY * 0.25, width = screenX * 0.5, height = 500 * scaleValue } box.endX = box.startX + box.width box.endY = box.startY + box.height dxDrawRectangle ( box.startX, box.startY, box.width, box.height, tocolor(0,0,0) ) dxDrawText("SuperFun - Szórakozó szerver", box.startX + 10 * scaleValue, box.startY, box.endY - 100 * scaleValue, box.startY + 50 * scaleValue, tocolor(255,255,255,255), 1.00 --[[* scaleValue]], font2, "left", "center") 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