Jump to content

AbsoluteToRelative


#Paper

Recommended Posts

I want to make some dxText in the same position for all resolutions but it doesn't work:

function AbsoluteToRelativ( X, Y ) -- this coverter transforms the gui position and size for the resolution of the player 
    local rX, rY = guiGetScreenSize() 
    local x = math.floor((X/2200)*rX) 
    local y = math.floor((Y/1085)*rY) 
    return x, y 
end 

From Citizen :S

Link to comment

It seems to be correct if I understand what you need. So what doesn't work? Debug errors, wrong results, ... (show an example)

Also, while technically correct, don't use the same variables names capitalized ('x' and 'X'). It's confusing and a bad scripting habit.

Link to comment

Use This;

function AbsoluteToRelative( X, Y ) 
        local rX, rY = guiGetScreenSize() 
        local x = X/rX 
        local y = Y/rY 
        return x, y 
end 

And RelativeToAbsolute;

function RelativeToAbsolute( X, Y ) 
        local rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 

Link to comment
Use This;

function AbsoluteToRelative( X, Y ) 
        local rX, rY = guiGetScreenSize() 
        local x = X/rX 
        local y = Y/rY 
        return x, y 
end 

And RelativeToAbsolute;

function RelativeToAbsolute( X, Y ) 
        local rX, rY = guiGetScreenSize() 
        local x = X*rX 
        local y = Y*rY 
        return x, y 
end 

Ty, it works! :D

Link to comment
  • Moderators
I want to make some dxText in the same position for all resolutions but it doesn't work:
function AbsoluteToRelativ( X, Y ) -- this coverter transforms the gui position and size for the resolution of the player 
    local rX, rY = guiGetScreenSize() 
    local x = math.floor((X/2200)*rX) 
    local y = math.floor((Y/1085)*rY) 
    return x, y 
end 

From Citizen :S

Haha yeah I recognized my script immediately when I saw it and then I saw your credit thx :mrgreen:

dxDrawText works with absolutes arguments so you have to convert relatives arguments to absolutes arguments like laserlaser made.

But something is strange, why do you have to use it ? because it's useless !

=> why do you convert absolute args to relatives args and then go back to absolutes args, just take directly the absolute args.

IDK if you see what I mean ...

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...