Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.18 KB | None | 0 0
  1. function createLoginWindow()
  2.        local X = 0.375
  3.        local Y = 0.375
  4.        local Width = 0.25
  5.        local Height = 0.25
  6.        wdwLogin = guiCreateWindow (X, Y, Width, Height, "Please log in.", true)
  7.  
  8.        X = 0.0825
  9.        Y = 0.2
  10.        Width = 0.25
  11.        Height = 0.25
  12.        guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin)
  13.        Y = 0.5
  14.        guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin)
  15.  
  16.  
  17.        X = 0.415
  18.        Y = 0.2
  19.        Width = 0.5
  20.        Height = 0.15
  21.        edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin)
  22.        Y = 0.5
  23.        edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin)
  24.        guiEditSetMaxLenght(edtUser, 50)
  25.        guiEditSetMaxLenght(edtPass, 50)
  26.  
  27.        X = 0.415
  28.        Y = 0.7
  29.        Width = 0.025
  30.        Height = 0.2
  31.        btnLogin = guiCreateButton(X, Y, Width, Height, "Log in.", true, wdwLogin)
  32.  
  33.        guiSetVisible(wdwLogin, false)
  34. end
  35. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
  36.         function ()
  37.                 createLoginWindow()
  38.                 outputChatBox("Welcome to Fun Flight Server. Please log in.")
  39.  
  40.                 if (wdwLogin ~= nil)  then
  41.                         guiSetVisible(wdwLogin, true)
  42.                 else
  43.                         outputChatBox("An unexpected error has ocurred. Please visit funflightserver.webs.com and report this error.")
  44.                 end
  45.                
  46.                 if btnLogin then
  47.                     addEventHandler ('onClientGUIClick', btnLogin, clientSubmitLogin, false)
  48.                 else
  49.                     outputDebugString ('attaching event handler for btnLogin fail')
  50.                 end
  51.  
  52.                 showCursor(true)
  53.                 guiSetInputEnabled(true)
  54.         end
  55. )
  56.  
  57. function clientSubmitLogin(button,state)
  58.     if button == "left" and state == "up" then
  59.         local username = guiGetText(edtUser)
  60.         local password = guiGetText(edtPass)
  61.  
  62.         if username and password then
  63.             triggerServerEvent("submitLogin", getRootElement(), username, password)
  64.  
  65.             guiSetInputEnabled(false)
  66.             guiSetVisible(wdwLogin, false)
  67.             showCursor(false)
  68.         else
  69.             outputChatBox("Please enter wanted username and password.")
  70.         end
  71.     end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement