Jump to content

AbsoluteToRelative


#Paper

Recommended Posts

Posted

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

mtaubluascripter.png

My skype: skiper964

I helped you? Help me! ^^

Help me bro! ^^

Posted

To convert absolute to relative you simply do;

relativeX = absoluteX*relativePosX

relativeY = absoluteY*relativePosY

Retired

Posted

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 

Posted
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

mtaubluascripter.png

My skype: skiper964

I helped you? Help me! ^^

Help me bro! ^^

  • Moderators
Posted
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 ...

The rEvolution is coming ...

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