I'm trying to make a login/register panel for my server and i can't get it to work the login button isn't doing anything.
function createLoginWindow()
local X = 0.375
local Y = 0.375
local Width = 0.25
local Height = 0.25
wdwLogin = guiCreateWindow(X, Y, Width, Height, "Account Panel", true)
guiWindowIsMovable(wdwLogin, false)
-- define new X and Y positions for the first label
X = 0.0825
Y = 0.15
-- define new Width and Height values for the first label
Width = 0.25
Height = 0.25
-- create the first label, note the final argument passed is 'wdwLogin' meaning the window
-- we created above is the parent of this label (so all the position and size values are now relative to the position of that window)
guiCreateLabel(X, Y, Width, Height, "First name", true, wdwLogin)
-- alter the Y value, so the second label is slightly below the first
Y = 0.35
guiCreateLabel(X, Y, Width, Height, "Last name", true, wdwLogin)
Y = 0.55
guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin)
X = 0.415
Y = 0.15
Width = 0.5
Height = 0.15
edtFirst = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin)
Y = 0.35
edtLast = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin)
Y = 0.55
edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin)
-- set the maximum character length for the username and password fields to 50
guiEditSetMaxLength(edtFirst, 50)
guiEditSetMaxLength(edtLast, 50)
guiEditSetMaxLength(edtPass, 50)
X = 0.0825
Y = 0.8
Width = 0.25
Height = 0.25
btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin)
X = 0.415
btnRegister = guiCreateButton(X, Y, Width, Height, "Register", true, wdwLogin)
-- make the window invisible
guiSetVisible(wdwLogin, false)
addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false)
addEventHandler("onClientGUIClick", btnRegister, clientSubmitRegister, false)
end
addEventHandler("onClientResourceStart", getResourceRootElement(),
function ()
createLoginWindow()
guiSetVisible(wdwLogin, true)
-- enable the player's cursor (so they can select and click on the components)
showCursor(true)
-- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening
guiSetInputEnabled(true)
end
)
function clientSubmitLogin(button,state)
-- if our login button was clicked with the left mouse button, and the state of the mouse button is up
if button == "left" and state == "up" then
local firstName = guiGetText(edtFirst)
local lastName = guiGetText(edtLast)
local username = firsName .. "_" .. secondName
local password = guiGetText(edtPass)
print(player .. username .. password)
logIn(player, username, password)
-- move the input focus back onto the game (allowing players to move around, open the chatbox, etc)
guiSetInputEnabled(false)
-- hide the window and all the components
guiSetVisible(wdwLogin, false)
-- hide the mouse cursor
showCursor(false)
end
end
Can you guys tell me what i did wrong or how can i code this panel?