Guest User

Untitled

a guest
Aug 6th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.47 KB | None | 0 0
  1. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
  2.     function ()
  3.         createLoginWindow()
  4.         guiSetVisible(wdwLogin, true)
  5.         showCursor(true)
  6.         guiSetInputEnabled(true)
  7.  
  8.         outputChatBox("Welcome to My MTA:SA Server, please log in.")
  9.  
  10.         fadeCamera(true, 5)
  11.        
  12.         showPlayerHudComponent("radar", false)
  13.         showPlayerHudComponent("wanted", false)
  14.         showPlayerHudComponent("clock", false)
  15.         showPlayerHudComponent("armour", false)
  16.         showPlayerHudComponent("area_name", false)
  17.         showPlayerHudComponent("ammo", false)
  18.         showPlayerHudComponent("weapon", false)
  19.  
  20.         setCameraMatrix(1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316)
  21.     end
  22. )
  23.  
  24. addEvent("loginResponse", true)
  25. addEventHandler("loginResponse", getRootElement(),
  26.     function (response)
  27.         outputChatBox("("..response..")")
  28.         if response == 1 then
  29.             outputChatBox("Nieprawidlowy nick lub haslo.")
  30.         else
  31.             triggerServerEvent("SetPlayerSpawn", getRootElement())
  32.         end
  33.     end
  34. )
  35. addEvent("HideLoginGUI", true)
  36. addEventHandler("HideLoginGUI", getRootElement(),
  37.     function ()
  38.         guiSetVisible(wdwLogin, false)
  39.         showCursor(false)
  40.         guiSetInputEnabled(false)
  41.     end
  42. )
  43.  
  44. function createLoginWindow()
  45.     local X = 0.375
  46.     local Y = 0.375
  47.     local Width = 0.25
  48.     local Height = 0.25
  49.     wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true)
  50.     guiWindowSetMovable(wdwLogin, false)
  51.    
  52.     X = 0.0825
  53.     Y = 0.2
  54.     Width = 0.25
  55.     Height = 0.25
  56.     guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin)
  57.     Y = 0.5
  58.     guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin)
  59.  
  60.     X = 0.415
  61.     Y = 0.2
  62.     Width = 0.5
  63.     Height = 0.15
  64.     edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin)
  65.     Y = 0.5
  66.     edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin)
  67.     guiEditSetMaxLength(edtUser, 32)
  68.     guiEditSetMaxLength(edtPass, 32)
  69.     guiEditSetMasked(edtPass, true)
  70.  
  71.     X = 0.415
  72.     Y = 0.7
  73.     Width = 0.25
  74.     Height = 0.2
  75.     btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin)
  76.  
  77.     addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false)
  78. end
  79.  
  80. function clientSubmitLogin(button,state)
  81.     if button == "left" and state == "up" then
  82.         local username = guiGetText(edtUser)
  83.         local password = guiGetText(edtPass)
  84.  
  85.         if username and password then
  86.             triggerServerEvent("submitLogin", getRootElement(), username, password)
  87.         else
  88.             outputChatBox("Please enter a username and password.")
  89.         end
  90.     end
  91. end
Add Comment
Please, Sign In to add comment