Jump to content

Gui screen size problem! PLS HELP!


Xwad

Recommended Posts

Hi i made a gui on my table computer. Its working but when i try the script on my laptop then the gui size will be different maybe becaouse the resolution of the laptops screen..Pls help how can i fix that problem?

here is a part of my gui script.

bg = guiCreateWindow(0, 0, 850, 850, "Spawn menu", false) 

Link to comment

you can use this useful function

source code

function guiSetPos ( theGUI, x, y, Relative ) 
    if ( ( isElement ( theGUI ) ) and ( getElementType ( theGUI ):find( "gui-" ) ) ) then 
        if ( ( theGUI ) and ( x ) and ( y ) ) then 
    local px, py = guiGetScreenSize ( ); 
        local hx, hy = guiGetPosition ( theGUI, Relative ); 
    guiSetPosition ( theGUI, hx * px / x, hy * py / y, Relative ); 
        return true 
    else 
        return false 
    end 
else 
    return false 
   end 
end 

syntax

bool guiSetPos ( GUI theGUI, float x, float y, bool Relative ) 

example :

GUIEditor = { 
    button = {}, 
    window = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(396, 187, 377, 256, "Test", false) 
        guiWindowSetMovable(GUIEditor.window[1], false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 1.00) 
        guiSetPos ( GUIEditor.window[1], 1366, 768, false ) 
        guiSetVisible ( GUIEditor.window[1], false ) 
        GUIEditor.button[1] = guiCreateButton(142, 73, 168, 41, "hi", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA")     
    end 
) 
  
bindKey ( "F7", "down", function (  ) 
guiSetVisible ( GUIEditor.window[1], not guiGetVisible ( GUIEditor.window[1] ) ) 
showCursor ( guiGetVisible ( GUIEditor.window[1] ) ) 
end ) 
  
function guiSetPos ( theGUI, x, y, Relative ) 
    if ( ( isElement ( theGUI ) ) and ( getElementType ( theGUI ):find( "gui-" ) ) ) then 
        if ( ( theGUI ) and ( x ) and ( y ) ) then 
    local px, py = guiGetScreenSize ( ); 
        local hx, hy = guiGetPosition ( theGUI, Relative ); 
    guiSetPosition ( theGUI, hx * px / x, hy * py / y, Relative ); 
        return true 
    else 
        return false 
    end 
else 
    return false 
   end 
end 
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...