Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local localPlayer = getLocalPlayer()
- local playerName = getPlayerName(localPlayer)
- function createPasswordWindow()
- windowChangepw = guiCreateWindow(0.3859,0.349,0.2219,0.5628,"[Dinastia Lusitana] Login - Change Password",true)
- guiSetSize(windowChangepw, 165, 21)
- guiSetAlpha(windowChangepw,0.80000001192093)
- editOldpw = guiCreateEdit(110,29,165,21,"",false,windowChangepw)
- guiSetAlpha(editOldpw,1)
- guiEditSetMasked(editOldpw,true)
- labelOldpw = guiCreateLabel(10,29,90,21,"Old password:",false,windowChangepw)
- guiSetAlpha(labelOldpw,1)
- guiLabelSetColor(labelOldpw,255,255,255)
- guiLabelSetVerticalAlign(labelOldpw,"center")
- guiLabelSetHorizontalAlign(labelOldpw,"left",false)
- editNewpw = guiCreateEdit(110,60,165,21,"",false,windowChangepw)
- guiSetAlpha(editNewpw,1)
- guiEditSetMasked(editNewpw,true)
- guiEditSetMaxLength(editNewpw,50)
- labelNewpw = guiCreateLabel(10,60,90,21,"New password:",false,windowChangepw)
- guiSetAlpha(labelNewpw,1)
- guiLabelSetColor(labelNewpw,255,255,255)
- guiLabelSetVerticalAlign(labelNewpw,"center")
- guiLabelSetHorizontalAlign(labelNewpw,"left",false)
- buttonChangepw = guiCreateButton(10,91,265,23,"Change password",false,windowChangepw)
- guiSetAlpha(buttonChangepw,1)
- guiSetVisible(windowChangepw, false)
- addEventHandler("onClientGUIClick", buttonChangepw, clientSubmitChangepw, false)
- end
- function createLoginWindow()
- windowLogin = guiCreateWindow(372,246,462,325,"[Dinastia Lusitana] - Login Panel",false)
- guiWindowSetMovable(windowLogin,true)
- guiWindowSetSizable(windowLogin,false)
- imagem = guiCreateStaticImage(9,38,206,188,"images/logo.png",false,windowLogin)
- labelExplicacao = guiCreateLabel(188,37,241,104,"Welcome to the Dinastia Lusitana Race Server!\n Below, fill the empty spaces with your login details and press 'Login'. If you don't have an account yet, fill it with the desired details, and press 'Register'.",false,window)
- guiLabelSetColor(labelExplicacao,176,000,000)
- guiLabelSetVerticalAlign(labelExplicacao,"center")
- guiLabelSetHorizontalAlign(labelExplicacao,"center",true)
- labelInfo = guiCreateLabel(40,144,377,16,"_________________________________________________________________",false,windowLogin)
- guiLabelSetColor(labelInfo,250,250,250)
- labelUsername = guiCreateLabel(210,160,69,19,"Username",false,windowLogin)
- guiLabelSetColor(labelUsername ,250,000,000)
- guiLabelSetVerticalAlign(labelUsername ,"center")
- guiLabelSetHorizontalAlign(labelUsername ,"center",false)
- guiSetFont(labelUsername ,"default-bold-small")
- editUsername = guiCreateEdit(74,185,326,28,"",false,windowLogin)
- labelPassword = guiCreateLabel(218,217,69,19,"Password",false,windowLogin)
- guiLabelSetColor(labelPassword,250,0,0)
- guiSetFont(labelPassword,"default-bold-small")
- editPassword = guiCreateEdit(74,241,326,28,"",false,windowLogin)
- buttonLogin = guiCreateButton(45,284,182,31,"Login",false,windowLogin)
- guiSetFont(buttonLogin,"default-bold-small")
- buttonRegister = guiCreateButton(254,283,182,31,"Register",false,windowLogin)
- guiSetFont(buttonRegister,"default-bold-small")
- guiSetVisible(windowLogin, false)
- addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false)
- addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, false)
- end
- function resourceStart()
- createLoginWindow()
- if (windowLogin ~= nil) then
- guiSetVisible(windowLogin, true)
- else
- outputChatBox("An error has occurred.")
- end
- showCursor(true)
- guiSetInputEnabled(true)
- end
- function changePw()
- createPasswordWindow()
- guiSetVisible(windowChangepw, true)
- showCursor(true)
- guiSetInputEnabled(true)
- end
- function clientSubmitLogin(button, state)
- if button == "left" and state == "up" then
- local username = guiGetText(editUsername)
- local password = guiGetText(editPassword)
- if username and password then
- triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password)
- else
- guiSetText(labelInfo, "Enter username and password.")
- end
- end
- end
- function clientSubmitRegister(button, state)
- if button == "left" and state == "up" then
- local username = guiGetText(editUsername)
- local password = guiGetText(editPassword)
- if username and password then
- triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
- else
- guiSetText(labelInfo, "Enter username and password.")
- end
- end
- end
- function clientSubmitChangepw(button, state)
- if button == "left" and state == "up" then
- local oldpassword = guiGetText(editOldpw)
- local newpassword = guiGetText(editNewpw)
- if oldpassword and newpassword then
- triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword)
- else
- outputChatBox("Enter old and new password.")
- end
- end
- end
- function hideLoginWindow()
- guiSetInputEnabled(false)
- guiSetVisible(windowLogin, false)
- showCursor(false)
- end
- function hidePasswordWindow()
- guiSetInputEnabled(false)
- guiSetVisible(windowChangepw, false)
- showCursor(false)
- end
- function unknownError()
- guiSetText(labelInfo, "Password/Username missing or wrong.")
- end
- function loginWrong()
- guiSetText(labelInfo, "Wrong username and/or password.")
- end
- function registerTaken()
- guiSetText(labelInfo, "This username is allready taken.")
- end
- addEvent("hidePasswordWindow", true)
- addEvent("hideLoginWindow", true)
- addEvent("unknownError", true)
- addEvent("loginWrong", true)
- addEvent("registerTaken", true)
- addEventHandler("hidePasswordWindow", getRootElement(), hidePasswordWindow)
- addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)
- addEventHandler("unknownError", getRootElement(), unknownError)
- addEventHandler("loginWrong", getRootElement(), loginWrong)
- addEventHandler("registerTaken", getRootElement(), registerTaken)
- addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), resourceStart)
- addCommandHandler("changepw", changePw)
Add Comment
Please, Sign In to add comment