rusztamas Posted December 6, 2016 Share Posted December 6, 2016 Hi! I want to learn using dxDraws properly, but i don't know where can i check screen coordinates, and i want to draw a straight line, and place a box in the center, and i'm trying my best and it is like this: Coding: local x,y = guiGetScreenSize() function drawStuff() local bg = dxDrawRectangle ( 500, 250, 500, 500, tocolor ( 0, 0, 0, 155 ) ) local line1 = dxDrawLine ( 600, 500, 300, 250, tocolor(0,0,0,255)) end addEventHandler("onClientRender", root, drawStuff) addCommandHandler ("asdasd", drawStuff) Can you help me? Please? Link to comment
ViRuZGamiing Posted December 7, 2016 Share Posted December 7, 2016 By using math, screenX / 2 is the horizontal middle screenY / 2 is the vertical middle this gives the center. Link to comment
Best-Killer Posted December 7, 2016 Share Posted December 7, 2016 like this : local x,y = guiGetScreenSize() function drawStuff() local bg = dxDrawRectangle ( x*500, y*250, x*500, y*500, tocolor ( 0, 0, 0, 155 ) ) local line1 = dxDrawLine ( x*600, y*500, x*300, y*250, tocolor(0,0,0,255)) end addEventHandler("onClientRender", root, drawStuff) addCommandHandler ("asdasd", drawStuff) and this for make it show at same position in all res local x,y = guiGetScreenSize() local sx, sy = x/1280, y/720 ----- put your res here function drawStuff() local bg = dxDrawRectangle ( sx*500, sy*250, sx*500, sy*500, tocolor ( 0, 0, 0, 155 ) ) local line1 = dxDrawLine ( sx*600, sy*500, sx*300, sy*250, tocolor(0,0,0,255)) end addEventHandler("onClientRender", root, drawStuff) addCommandHandler ("asdasd", drawStuff) Link to comment
Sticmy Posted December 7, 2016 Share Posted December 7, 2016 use guieditor, link: https://community.multitheftauto.com/index.php?p=resources&s=details&id=141 Link to comment
koragg Posted December 7, 2016 Share Posted December 7, 2016 (edited) An easy way is to position the dxdraw things using just number values so that it looks as you want it to on your resolution. And after that use this example to convert the number values to floating point ones and multiply by screen width and height. The dxDrawRectangle you posted will look like this: local x, y = guiGetScreenSize() dxDrawRectangle ( x* 0,2604166667 , y* 0,2314814815 , x* 0,2604166667, y* 0,462962963 , tocolor ( 0, 0, 0, 155 ) ) And it will stay same size and on same position on any screen resolution. What i did was: I divided the first number by my pc screen resolution width so 500/1920. The second number i divided by the height so 500/1080. Then the third number again divided by screen width and forth number-by screen height. After this i just multiply each result of each division with the corresponding screen dimension. x = screen width y = screen height Edited December 7, 2016 by koragg Sry for any typos, I'm from phone 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