Jump to content

How to make this absolute to relative?


thund3rbird23

Recommended Posts

I did this in guieditor:

dxDrawLine(512 - 1, 645 - 1, 512 - 1, 674, tocolor(37, 199, 0, 255), 1, false)
dxDrawLine(859, 645 - 1, 512 - 1, 645 - 1, tocolor(37, 199, 0, 255), 1, false)
dxDrawLine(512 - 1, 674, 859, 674, tocolor(37, 199, 0, 255), 1, false)
dxDrawLine(859, 674, 859, 645 - 1, tocolor(37, 199, 0, 255), 1, false)
dxDrawRectangle(512, 645, 347, 29, tocolor(0, 0, 0, 197), false)

How can I make this to relative if I'm using:

local screenW, screenH = guiGetScreenSize() 

 

Link to comment
local relX = valueX / screenW -- this will return a 0.X value, so the relative you need

 

But in general I really recommend to use dxDraw values in a different way:

 

SX, SY = guiGetScreenSize(); -- Define the screen variables global for all scripts inside the resource (NO local!)

-- Then draw by dividing that
dxDrawLine(SX / 2, SY / 4, SX / 2, SY / 2, tocolor(255, 165, 0, 255));
-- Draws a vertical line from SY / 4 to SY / 2 (so from 1/4 of you screens height to your screen center)

 

  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...