- Documentation
- Client functions
- guiCreateWindow
Function
guiCreateWindow
Creates a window with a title bar. The window can be dragged and resized and has a close button (the onClientGUIClose event). Add other controls as its children.
Syntax
gui-window guiCreateWindow(float x, float y, float width, float height, string titleBarText, bool relative)Arguments
xfloat- X position.
yfloat- Y position.
widthfloat- Width.
heightfloat- Height.
titleBarTextstring- Title.
relativebooltrue: values are screen fractions (0-1),false: pixels.Optional in MTA:SA: bool relative = false
Differences from MTA:SA
- Arguments in a different colour differ from MTA:SA.
In MTA:SA
guiCreateWindow(float x, float y, float width, float height, string titleBarText, bool relative = false)Returns
The window or false.
Example
A login window with fields and a button.
local sw, sh = guiGetScreenSize()
local win = guiCreateWindow((sw - 360) / 2, (sh - 220) / 2, 360, 220, "Logowanie", false)
guiCreateLabel(20, 45, 320, 20, "Login:", false, win)
local login = guiCreateEdit(20, 65, 320, 30, "", false, win)
guiCreateLabel(20, 105, 320, 20, "Hasło:", false, win)
local pass = guiCreateEdit(20, 125, 320, 30, "", false, win)
guiEditSetMasked(pass, true)
local ok = guiCreateButton(240, 170, 100, 32, "Zaloguj", false, win)
showCursor(true)
addEventHandler("onClientGUIClick", ok, function()
triggerServerEvent("tryLogin", localPlayer, guiGetText(login), guiGetText(pass))
end, false)