well i made this script with the help of comunity resources and the wiki but the login and register buttons wont work. Client script
local localPlayer = getLocalPlayer()
local playerName = getPlayerName(localPlayer)
function loginWindow()
GUIEditor_Button = {}
GUIEditor_Label = {}
GUIEditor_Edit = {}
GUIEditor_Image = {}
GUIEditor_Image[1] = guiCreateStaticImage(0,0,1,1,"images/LoginBack.png",true)
GUIEditor_Image[2] = guiCreateStaticImage(.2,.1,.6,.4,"images/Logo.png",true,GUIEditor_Image[1])
GUIEditor_Edit[1] = guiCreateEdit(.2,.7,.2,.05,"",true,GUIEditor_Image[1])
guiEditSetMaxLength(GUIEditor_Edit[1],25)
GUIEditor_Edit[2] = guiCreateEdit(.6,.7,.2,.05,"",true,GUIEditor_Image[1])
guiEditSetMasked(GUIEditor_Edit[2],true)
guiEditSetMaxLength(GUIEditor_Edit[2],25)
GUIEditor_Label[1] = guiCreateLabel(.2,.6,.2,.1,"Username:",true,GUIEditor_Image[1])
guiLabelSetColor(GUIEditor_Label[1],0,0,255)
guiSetFont(GUIEditor_Label[1],"sa-gothic")
GUIEditor_Label[2] = guiCreateLabel(.6,.6,.2,.1,"Password:",true,GUIEditor_Image[1])
guiLabelSetColor(GUIEditor_Label[2],0,0,255)
guiSetFont(GUIEditor_Label[2],"sa-gothic")
GUIEditor_Button[1] = guiCreateButton(.825,.1,.1,.1,"Guest",true,GUIEditor_Image[1])
guiSetFont(GUIEditor_Button[1],"sa-header")
GUIEditor_Button[2] = guiCreateButton(.45,.7,.1,.1,"Login",true,GUIEditor_Image[1])
guiSetFont(GUIEditor_Button[2],"default-bold-small")
GUIEditor_Button[3] = guiCreateButton(.45,.85,.1,.1,"Register",true,GUIEditor_Image[1])
guiSetFont(GUIEditor_Button[3],"default-bold-small")
guiSetVisible(GUIEditor_Image[1], false)
addEventHandler("onClientGUIClick", GUIEditor_Button[1], submitGuest, false)
addEventHandler("onClientGUIClick", GUIEditor_Button[2], submitLogin, false)
addEventHandler("onClientGUIClick", GUIEditor_Button[3], submitRegister, false)
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
function ()
loginWindow()
if (GUIEditor_Image[1] ~= nil) then
guiSetVisible(GUIEditor_Image[1], true)
else
outputChatBox("An unexpected error has occurred and the log in GUI has not been created. Please reconnect and try again.")
end
showCursor(true)
guiSetInputEnabled(true)
end
)
function submitGuest(button,state)
if button == "left" and state == "up" then
guiSetInputEnabled(false)
guiSetVisible(GUIEditor_Image[1], false)
showCursor(false)
outputChatBox("You are playing as a guest please register.")
end
end
function submitLogin(button,state)
if button == "left" and state == "up" then
local username = guiGetText(username)
local password = guiGetText(password)
if username and password then
triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password)
end
end
end
function submitRegister(button,state)
if button == "left" and state == "up" then
local username = guiGetText(username)
local password = guiGetText(password)
if username and password then
triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
end
end
end
function hideLoginWindow()
guiSetInputEnabled(false)
guiSetVisible(GUIEditor_Image[1], false)
showCursor(false)
end
function unknownError()
outputChatBox("Error 1: Please reconnect and try again.")
end
function loginWrong()
outputChatBox("Error 2: Wrong username/password")
end
function registerTaken()
outputChatBox("Error 3: This name is already taken.")
end
addEvent("hideLoginWindow", true)
addEvent("unknownError", true)
addEvent("loginWrong", true)
addEvent("registerTaken", true)
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)
addEventHandler("unknownError", getRootElement(), unknownError)
addEventHandler("loginWrong", getRootElement(), loginWrong)
addEventHandler("registerTaken", getRootElement(), registerTaken)
Server Script
function loginHandler(player, username, password)
local account = getAccount(username, password)
if (account ~= false) then
if (logIn(player, account, password) == true) then
triggerClientEvent (player, "hideLoginWindow", getRootElement())
else
triggerClientEvent (player, "unknownError", getRootElement())
end
else
triggerClientEvent (player, "loginWrong", getRootElement())
end
end
function registerHandler(player, username, password)
local account = getAccount(username, password)
if (account ~= false) then
triggerClientEvent(player, "registerTaken", getRootElement())
else
account = addAccount(username, password)
if (logIn(player, account, password) == true) then
triggerClientEvent(player, "hideLoginWindow", getRootElement())
else
triggerClientEvent(player, "unknownError", getRootElement())
end
end
end
addEvent("submitLogin", true)
addEvent("submitRegister", true)
addEventHandler("submitLogin", getRootElement(), loginHandler)
addEventHandler("submitRegister", getRootElement(), registerHandler)
Any help would be appreciated. Thanks