Bantu Posted May 5, 2011 Share Posted May 5, 2011 Hello guys, I need help with GUI. I make a simple GUI with this tutorial: https://wiki.multitheftauto.com/wiki/Int ... ng_the_GUI and where join in server is black screen and doesn't effect. This is my code: -- server-side function loginHandler(username, password) if (username == "user" and password == "apple") then if (client) then spawnPlayer(client, 1954.3701, -1768.8671, 13.5468) fadeCamera(client, true) setCameraTarget(client, client) outputChatBox("Welcome to my MTA:Server", client) end else outputChatBox("Invalid username and password. Please re-connect and try again.",client) end end addEvent("submitLogin", true) addEventHandler("submitLogin", getRootElement(), loginHandler) --client-side function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) X = 0.0825 Y = 0.2 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username: ", true, wdwLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password: ", true, wdwLogin) X = 0.415 Y = 0.2 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.2 btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) guiSetVisible(wdwLogin, false) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end function clientSubmitLogin(button, state) if (button == "left" and state == "up") then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if (username and password) then triggerServerEvent("submitLogin", getRootElement(), username, password) guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) else outputChatBox("Please enter a username and password.") end end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource), function() createLoginWindow() outputChatBox("Welcome to My New MTA:Server, please Log In") if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end showCursor(true) guiSetInputEnabled(true) end ) Sorry for my bad english and please help Link to comment
Castillo Posted May 5, 2011 Share Posted May 5, 2011 --Server side function loginHandler(client, username, password) if (username == "user" and password == "apple") then if (client) then spawnPlayer(client, 1954.3701, -1768.8671, 13.5468) fadeCamera(client, true) setCameraTarget(client, client) outputChatBox("Welcome to my MTA:Server", client) showCursor(client,false) end else outputChatBox("Invalid username and password. Please re-connect and try again.",client) end end addEvent("submitLogin", true) addEventHandler("submitLogin", getRootElement(), loginHandler) --Client side function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) X = 0.0825 Y = 0.2 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username: ", true, wdwLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password: ", true, wdwLogin) X = 0.415 Y = 0.2 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.2 btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) guiSetVisible(wdwLogin, false) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end function clientSubmitLogin(button, state) if (button == "left" and state == "up") then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if (username and password) then triggerServerEvent("submitLogin", getLocalPlayer(), getLocalPlayer(), username, password) guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) else outputChatBox("Please enter a username and password.") end end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () createLoginWindow() outputChatBox("Welcome to My New MTA:Server, please Log In") if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) showCursor(true) guiSetInputEnabled(true) else outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end end) It works now. 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