LeonardoWilliams Posted May 10, 2021 Share Posted May 10, 2021 if getElementData( localPlayer,"duty_admin" ) == 1 then --dxDrawImage(ax,ay,iconH,iconH,"images/hud/adm_on.png") dxDrawImage(1645, 500, 64, 64, "images/hud/adm_on.png") table.insert(tooltips, "adminonduty") Hello guys, so i`m learning slowly a lot of stuff when u answer my questions, now i got a problem, a bigger one i think, i draw that image but it shows different on other resolutions, can u please tell me how to do it or show me an example because i`m a beginner.. i tried following other scaling on all resolutions but i think they are no use, i want that icon basically to stand in the right middle screen.. Link to comment
DiSaMe Posted May 10, 2021 Share Posted May 10, 2021 You need to get the screen resolution with guiGetScreenSize and use it to calculate the coordinates for that resolution. That page has examples for this particular purpose. 1 Link to comment
LeonardoWilliams Posted May 10, 2021 Author Share Posted May 10, 2021 I need to calculate it for every resolution ? Link to comment
Scripting Moderators ds1-e Posted May 10, 2021 Scripting Moderators Share Posted May 10, 2021 1 minute ago, LeonardoWilliams said: I need to calculate it for every resolution ? 1 Link to comment
LeonardoWilliams Posted May 10, 2021 Author Share Posted May 10, 2021 Thank you, i ll follow! Link to comment
LeonardoWilliams Posted May 10, 2021 Author Share Posted May 10, 2021 Can someone please give me an example on how to draw an image on all resolutions positioned right in the right middle , i tried to do it myself but it s just too much to understand by just reading, i need to see a script like that to understand it i think, please Link to comment
Moderators Patrick Posted May 10, 2021 Moderators Share Posted May 10, 2021 -- Okay, so you have to pick a base resolution, you should choose what you use. local baseWidth, baseHeight = 1920, 1080 -- I pick fullhd -- We'll need the current resolution local screenWidth, screenHeight = guiGetScreenSize() -- imageine this is 1366x768 now -- and now we have to calculate the difference ratio between the base- and current resolution local xDiffRatio, yDiffRatio = screenWidth/baseWidth, screenHeight/baseHeight -- this will be: (1920/1366=1.40556) and (1080/768=1.40625) -- then we have to multiply every (X-coordinate and Width with 'xDiffRatio') and every (Y-coordinate and Height with 'yDiffRatio') -> this will resize everything (ofcourse if base- and current resolution is equals, then it doesn't change) -- now draw the image local imageX, imageY = 1645, 500 local imageWidth, imageHeight = 64, 64 -- miltiply values with the right ratio dxDrawImage(imageX*xDiffRatio, imageY*yDiffRatio, imageWidth*xDiffRatio, imageHeight*yDiffRatio, "images/hud/adm_on.png") -- NOTE: you can make your life easier if you create a "custom" dxDrawImage event what do the math for you, call it 'myDrawImage' function myDrawImage(x, y, width, height, ...) -- three dot means (...) every parameter after 4th, this is a "magic parameter" dxDrawImage(x*xDiffRatio, y*yDiffRatio, width*xDiffRatio, height*yDiffRatio, ...) -- and don't forget the dots end -- and now you can use your new function myDrawImage(imageX, imageY, imageWidth, imageHeight, "images/hud/adm_on.png") 1 Link to comment
LeonardoWilliams Posted May 10, 2021 Author Share Posted May 10, 2021 Thank you so much Patrick, you helped me again a lot!! You are the best Link to comment
Moderators Patrick Posted May 10, 2021 Moderators Share Posted May 10, 2021 12 minutes ago, LeonardoWilliams said: Thank you so much Patrick, you helped me again a lot!! You are the best Of course this code doesn't handle 4:3 resolutions like 800x600, and HUDs will be stretched. You can find solution for that in the tutorial what srslyyyy linked above. 1 Link to comment
LeonardoWilliams Posted May 10, 2021 Author Share Posted May 10, 2021 Understood, thank you now imma keep reading this script till i get it right, ur my teacher fr 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