Matevsz Posted December 27, 2015 Share Posted December 27, 2015 Hello, why shows only background? addEventHandler("onClientResourceStart", resourceRoot, function() screenW, screenH = guiGetScreenSize() main = {} main.background = guiCreateWindow(1169, 416, 501, 0, "", true) guiWindowSetSizable(main.background, true) tloLogin = guiCreateStaticImage(0, 0, 1680, 1050, "Zdjecia/tlo.jpg", true) login = guiCreateStaticImage(385, 90, 102, 46, "Zdjecia/login.png", true, main.background) rejestracja = guiCreateStaticImage(385, 146, 102, 51, "Zdjecia/register.png", true, main.background) poleLogin = guiCreateEdit(106, 156, 269, 36, "Zdjecia/button.png", true, main.background) poleHaslo = guiCreateEdit(106, 96, 269, 36, "Zdjecia/button.png", true, main.background) postacLogin = guiCreateStaticImage(111, 96, 37, 36, "Zdjecia/person.png", true, main.background) kluczeHaslo = guiCreateStaticImage(110, 156, 38, 35, "Zdjecia/password.png", true, main.background) zapamietajKonto = guiCreateCheckBox(106, 202, 15, 15, "", true, true, main.background) labelzapamietajK = guiCreateLabel(131, 201, 102, 14, "Zapamiętaj Konto", true, main.background) labelError = guiCreateLabel(105, 234, 382, 15, "", true, main.background) end ) Meta: Link to comment
Tails Posted December 27, 2015 Share Posted December 27, 2015 You need to use values between 1 and 0 when you have relative set to true. relative: This is whether sizes and positioning are relative. If this is true, then all x,y,width,height floats must be between 0 and 1, representing measures relative to the parent. Link to comment
Matevsz Posted December 28, 2015 Author Share Posted December 28, 2015 how? because I do not quite understand Link to comment
Tails Posted December 28, 2015 Share Posted December 28, 2015 Because you have relative set to 'true', you'll need to use values like: 0.01, 0.18, 0.37, 0.25 instead of 1169, 416, 501, 0. You might have to adjust the values to match the same positions again. Do this for every gui element in your script. If you're using 0 , 0 , 0.42, 0.1 for the edit box, that means it will be in the corner of the window because the x and y values are 0, 0 and relative is set to 'true'. So the edit box will be relative to its parent (the window). The window will be relative to the screen. Link to comment
Matevsz Posted December 28, 2015 Author Share Posted December 28, 2015 Already did it, thanks Now how do button in the photo? OnClientGUIClick does not work Link to comment
Tails Posted December 28, 2015 Share Posted December 28, 2015 onClientGuiClick only works if you're pointing it to the source (the button). Like so: button1 = guiCreateButton(0.77, 0.94, 0.07, 0.09, "Click me", true, main.background) function message() if source == button1 then -- Source is the source of onClientGUIClick that is clicked on, in this case the button. outputChatBox("Hello world") end end addEventHandler("onClientGUIClick",resourceRoot,message) If you have more than one button you can add them like so: function message() if source == button1 then outputChatBox("Hello world") elseif source == button2 then outputChatBox("Hello mars") end end addEventHandler("onClientGUIClick",resourceRoot,message) Link to comment
Tails Posted December 28, 2015 Share Posted December 28, 2015 By the way, I highly recommend GUI Editor when working with GUI. If you're going to use it, just try to stick with the regular GUI stuff. The dxGui's don't have functions like onClientGUIClick and will require extra coding to create such functions. Link: https://forum.multitheftauto.com/viewtopic.php?f ... =guieditor Link to comment
Matevsz Posted December 28, 2015 Author Share Posted December 28, 2015 Of course I use GuiEditor : ) Instead OnClientGUIClick i gave OnClientMouseEnter, but something does not work GUI: main.poleLogin = guiCreateEdit(1246, 417, 237, 34, "", false) main.poleHaslo = guiCreateEdit(1246, 468, 237, 34, "", false) main.buttonLogin = guiCreateStaticImage(1501, 407, 106, 51, "login.png", false) Client: addEventHandler("onClientResourceStart", resourceRoot, function() showChat(false) showCursor(true) end ) addEventHandler("onClientMouseEnter", main.buttonLogin, function(btn,state) if btn == "left" and state == "up" then local login = guiGetText(main.poleLogin) local haslo = guiGetText(main.poleHaslo) if login ~= "" and haslo ~= "" then triggerServerEvent("sprobujZalogowac", localPlayer, login, haslo) else setErrorStrine("Uzupełnij wszystkie pola!") end end end, false ) Server: addEvent("sprobujZalogowac",true) addEventHandler("sprobujZalogowac", root, function(login,haslo) if getAccount(login) then local acc = getAccount(login,haslo) if acc then logIn(source,acc,haslo) else triggerClientEvent(source,"onClientWrongLogin",root,"The specified account has a different password.") end else triggerClientEvent(source,"onClientWrongLogin",root,"Account with the specified login name does not exist.") end if checksave == true then triggerClientEvent(source,"ZapiszLoginXML",getRootElement(),login,haslo) else triggerClientEvent(source,"ResetZapisuXML",getRootElement(),login,haslo) end end ) addEventHandler("onPlayerLogin", root, function() setCameraTarget(source,source) showChat(source,true) showCursor(source,false) setPlayerHudComponentVisible(source,"all",true) spawnPlayer(source, 0.0, 0.0, 5.0, 90.0, 0 ) outputChatBox("Press F1 to get information about the server.", player) triggerClientEvent(source,"onClientLoginSuccess",root) end ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now