Quenix

Fit Gui to resoultion HELP

Recommended Posts

Hey Forum, i need to fit this money showing script to alll resoultions, some players with 1280 x 720 are having problems seeing their money in game. The money is located on top right of the screen. I visited https://wiki.multitheftauto.com/wiki/GuiGetScreenSize and saw some examples but its a bit confusing to be honest. Would appreciate if anyone could get me to understand the GuiGetScreenSize and help me make this  script fit all resolutions. Below ive added the script:

 

addEventHandler("onClientResourceStart", resourceRoot,
    function()    
    end
)
addEventHandler("onClientRender", root,
    function()
        local cash = getPlayerMoney( getLocalPlayer() )
        dxDrawText("KBK Points",   1785,   100,  688, 128, tocolor(30, 247, 7, 255), 0.50, "bankgothic", "left", "top", false, false, false, false, false)
        dxDrawText(""..cash,  1785, 115, 796,123, tocolor(255, 255, 255, 255), 0.50, "bankgothic", "left", "top", false, false, false, false, false)
    end
    
)

 

 

Tell me if you need more of the code!

Share this post


Link to post

Hi @Quenix !

           You are using 'absolute' method to take the positions of drawing DX texts. Use 'relative' method instead. It'll fix your problem.

Don't know what is known as 'Relative' and 'Absolute' ?

                                                                    Visit here :- Relative and Absolute

  • Like 1

Share this post


Link to post

guiGetScreenSize helps you to get the resolution of the player, and you cand make the math like this: sW,sH = guiGetScreenSize()

guiCreateWindow(sW*0.4,sH*0.4, 200, 200, "...", false)

and it is the same thing as using the relative version

guiCreateWindow(0.4,0.4, 0.3, 04, "...", true) **but you need to use values between 0 and 1 everywhere**

  • Like 1

Share this post


Link to post

Thank you both @DeadthStrock and @LyricalMM I thing its better to use relative as it is in percentage, meaning it will always be the same percantage on all resoultions instead of using absolute as that is almost like Pixels. It will be diffferent to each resolution. Thanks!

  • Thanks 1

Share this post


Link to post

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.