Guest User

Untitled

a guest
Oct 17th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.91 KB | None | 0 0
  1. local localPlayer = getLocalPlayer()
  2. local playerName = getPlayerName(localPlayer)
  3.  
  4. function createPasswordWindow()
  5.     windowChangepw = guiCreateWindow(0.3859,0.349,0.2219,0.5628,"[Dinastia Lusitana] Login - Change Password",true)
  6.     guiSetSize(windowChangepw, 165, 21)
  7.     guiSetAlpha(windowChangepw,0.80000001192093)
  8.     editOldpw = guiCreateEdit(110,29,165,21,"",false,windowChangepw)
  9.     guiSetAlpha(editOldpw,1)
  10.     guiEditSetMasked(editOldpw,true)
  11.     labelOldpw = guiCreateLabel(10,29,90,21,"Old password:",false,windowChangepw)
  12.     guiSetAlpha(labelOldpw,1)
  13.     guiLabelSetColor(labelOldpw,255,255,255)
  14.     guiLabelSetVerticalAlign(labelOldpw,"center")
  15.     guiLabelSetHorizontalAlign(labelOldpw,"left",false)
  16.     editNewpw = guiCreateEdit(110,60,165,21,"",false,windowChangepw)
  17.     guiSetAlpha(editNewpw,1)
  18.     guiEditSetMasked(editNewpw,true)
  19.     guiEditSetMaxLength(editNewpw,50)
  20.     labelNewpw = guiCreateLabel(10,60,90,21,"New password:",false,windowChangepw)
  21.     guiSetAlpha(labelNewpw,1)
  22.     guiLabelSetColor(labelNewpw,255,255,255)
  23.     guiLabelSetVerticalAlign(labelNewpw,"center")
  24.     guiLabelSetHorizontalAlign(labelNewpw,"left",false)
  25.     buttonChangepw = guiCreateButton(10,91,265,23,"Change password",false,windowChangepw)
  26.     guiSetAlpha(buttonChangepw,1)
  27.    
  28.     guiSetVisible(windowChangepw, false)
  29.    
  30.     addEventHandler("onClientGUIClick", buttonChangepw, clientSubmitChangepw, false)
  31.    
  32. end
  33.  
  34. function createLoginWindow()
  35.     windowLogin = guiCreateWindow(372,246,462,325,"[Dinastia Lusitana] - Login Panel",false)
  36.             guiWindowSetMovable(windowLogin,true)
  37.             guiWindowSetSizable(windowLogin,false)
  38.     imagem = guiCreateStaticImage(9,38,206,188,"images/logo.png",false,windowLogin)
  39.     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)
  40.             guiLabelSetColor(labelExplicacao,176,000,000)
  41.             guiLabelSetVerticalAlign(labelExplicacao,"center")
  42.             guiLabelSetHorizontalAlign(labelExplicacao,"center",true)
  43.     labelInfo = guiCreateLabel(40,144,377,16,"_________________________________________________________________",false,windowLogin)
  44.             guiLabelSetColor(labelInfo,250,250,250)
  45.     labelUsername = guiCreateLabel(210,160,69,19,"Username",false,windowLogin)
  46.             guiLabelSetColor(labelUsername ,250,000,000)
  47.             guiLabelSetVerticalAlign(labelUsername ,"center")
  48.             guiLabelSetHorizontalAlign(labelUsername ,"center",false)
  49.             guiSetFont(labelUsername ,"default-bold-small")
  50.     editUsername = guiCreateEdit(74,185,326,28,"",false,windowLogin)
  51.     labelPassword = guiCreateLabel(218,217,69,19,"Password",false,windowLogin)
  52.             guiLabelSetColor(labelPassword,250,0,0)
  53.             guiSetFont(labelPassword,"default-bold-small")
  54.     editPassword = guiCreateEdit(74,241,326,28,"",false,windowLogin)
  55.     buttonLogin = guiCreateButton(45,284,182,31,"Login",false,windowLogin)
  56.             guiSetFont(buttonLogin,"default-bold-small")
  57.     buttonRegister = guiCreateButton(254,283,182,31,"Register",false,windowLogin)
  58.             guiSetFont(buttonRegister,"default-bold-small")
  59.    
  60.     guiSetVisible(windowLogin, false)
  61.    
  62.     addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false)
  63.     addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, false)
  64. end
  65.  
  66. function resourceStart()
  67.     createLoginWindow()
  68.     if (windowLogin ~= nil) then
  69.         guiSetVisible(windowLogin, true)
  70.     else
  71.         outputChatBox("An error has occurred.")
  72.     end
  73.     showCursor(true)
  74.     guiSetInputEnabled(true)
  75. end
  76.  
  77. function changePw()
  78.     createPasswordWindow()
  79.     guiSetVisible(windowChangepw, true)
  80.     showCursor(true)
  81.     guiSetInputEnabled(true)
  82. end
  83.  
  84. function clientSubmitLogin(button, state)
  85.     if button == "left" and state == "up" then
  86.         local username = guiGetText(editUsername)
  87.         local password = guiGetText(editPassword)
  88.         if username and password then
  89.             triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password)
  90.         else
  91.             guiSetText(labelInfo, "Enter username and password.")
  92.         end
  93.     end
  94. end
  95.  
  96. function clientSubmitRegister(button, state)
  97.     if button == "left" and state == "up" then
  98.         local username = guiGetText(editUsername)
  99.         local password = guiGetText(editPassword)
  100.         if username and password then
  101.             triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password)
  102.         else
  103.             guiSetText(labelInfo, "Enter username and password.")
  104.         end
  105.     end
  106. end
  107.  
  108. function clientSubmitChangepw(button, state)
  109.     if button == "left" and state == "up" then
  110.         local oldpassword = guiGetText(editOldpw)
  111.         local newpassword = guiGetText(editNewpw)
  112.         if oldpassword and newpassword then
  113.             triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword)
  114.         else
  115.             outputChatBox("Enter old and new password.")
  116.         end
  117.     end
  118. end
  119.  
  120. function hideLoginWindow()
  121.     guiSetInputEnabled(false)
  122.     guiSetVisible(windowLogin, false)
  123.     showCursor(false)
  124. end
  125.  
  126. function hidePasswordWindow()
  127.     guiSetInputEnabled(false)
  128.     guiSetVisible(windowChangepw, false)
  129.     showCursor(false)
  130. end
  131.  
  132. function unknownError()
  133.     guiSetText(labelInfo, "Password/Username missing or wrong.")
  134. end
  135.  
  136. function loginWrong()
  137.     guiSetText(labelInfo, "Wrong username and/or password.")
  138. end
  139.  
  140. function registerTaken()
  141.     guiSetText(labelInfo, "This username is allready taken.")
  142. end
  143.  
  144. addEvent("hidePasswordWindow", true)
  145. addEvent("hideLoginWindow", true)
  146. addEvent("unknownError", true)
  147. addEvent("loginWrong", true)
  148. addEvent("registerTaken", true)
  149. addEventHandler("hidePasswordWindow", getRootElement(), hidePasswordWindow)
  150. addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)
  151. addEventHandler("unknownError", getRootElement(), unknownError)
  152. addEventHandler("loginWrong", getRootElement(), loginWrong)
  153. addEventHandler("registerTaken", getRootElement(), registerTaken)
  154. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), resourceStart)
  155.  
  156. addCommandHandler("changepw", changePw)
Add Comment
Please, Sign In to add comment