Guest User

Untitled

a guest
Aug 29th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.48 KB | None | 0 0
  1. ---------------------------------
  2. --Project: Vitality Gaming
  3. --Author: sekoX
  4. --File: login_client.lua
  5. --Side: Client
  6. ---------------------------------
  7. loginGUI = {}
  8.  
  9. function loadLoginGUI()
  10.     loginGUI.window = guiCreateStaticImage(screen.x/2-512/2, screen.y/2-512/2, 512, 512, "files/images/login/background.png", false)
  11.     loginGUI.loginB = guiCreateStaticImage(113, 336, 128, 64, "files/images/login/login.png", false, loginGUI.window)
  12.     loginGUI.guestB = guiCreateStaticImage(272, 336, 128, 64, "files/images/login/playasguest.png", false, loginGUI.window)
  13.     loginGUI.username = guiCreateEdit(115, 245, 283, 26, "", false, loginGUI.window)
  14.     loginGUI.password = guiCreateEdit(115, 305, 283, 26, "", false, loginGUI.window)
  15.  
  16.     fadeGUI = 0
  17.  
  18.     guiSetAlpha(loginGUI.window, 0)
  19.     guiEditSetMaxLength (loginGUI.username, 24)
  20.     guiEditSetMasked (loginGUI.password, true)
  21.     guiSetInputMode("no_binds_when_editing")
  22.     addEventHandler ("onClientGUIClick", loginGUI.loginB, onButtonClick, false)
  23.     addEventHandler ("onClientGUIClick", loginGUI.guestB, onButtonClick, false)
  24.     addEventHandler("onClientRender", getRootElement(), fadeLoginGUI)
  25.     showCursor(true)
  26. end
  27. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), loadLoginGUI)
  28.  
  29. function fadeLoginGUI()
  30.     if fadeGUI == 0 then
  31.         if guiGetAlpha(loginGUI.window) < 1 then
  32.             guiSetAlpha(loginGUI.window, guiGetAlpha(loginGUI.window) + 0.05)
  33.         end
  34.     elseif fadeGUI == 1 then
  35.         if guiGetAlpha(loginGUI.window) > 0 then
  36.             guiSetAlpha(loginGUI.window, guiGetAlpha(loginGUI.window) - 0.05)
  37.         end
  38.     end
  39. end
  40.  
  41. function loginButtonHover()
  42.     if source == loginGUI.loginB then
  43.         guiStaticImageLoadImage(loginGUI.loginB, "files/images/login/login_hover.png")
  44.         playSound("files/sounds/buttonHover.mp3")
  45.     end
  46. end
  47.  
  48. function loginButtonLeave()
  49.     if source == loginGUI.loginB then
  50.         guiStaticImageLoadImage(loginGUI.loginB, "files/images/login/login.png")
  51.     end
  52. end
  53.  
  54. function guestButtonHover()
  55.     if source == loginGUI.guestB then
  56.         guiStaticImageLoadImage(loginGUI.guestB, "files/images/login/playasguest_hover.png")
  57.         playSound("files/sounds/buttonHover.mp3")
  58.     end
  59. end
  60.  
  61. function guestButtonLeave()
  62.     if source == loginGUI.guestB then
  63.         guiStaticImageLoadImage(loginGUI.guestB, "files/images/login/playasguest.png")
  64.     end
  65. end
  66.  
  67. addEventHandler("onClientMouseEnter", getRootElement(), loginButtonHover)
  68. addEventHandler("onClientMouseLeave", getRootElement(), loginButtonLeave)
  69. addEventHandler("onClientMouseEnter", getRootElement(), guestButtonHover)
  70. addEventHandler("onClientMouseLeave", getRootElement(), guestButtonLeave)
  71.  
  72. function onButtonClick(button)
  73.     if button == "left" then
  74.         if source == loginGUI.loginB then
  75.             triggerServerEvent("event_login", getLocalPlayer(), guiGetText(loginGUI.username), guiGetText(loginGUI.password))
  76.             playSound("files/sounds/click.mp3")
  77.         elseif source == loginGUI.guestB then
  78.             triggerServerEvent("event_guest", getLocalPlayer())
  79.             playSound("files/sounds/click.mp3")
  80.         end
  81.     end
  82. end
  83.  
  84. function successLogin(message)
  85.     fadeGUI = 1
  86.     showCursor(false)
  87.     guiSetVisible(loginGUI.background, false)
  88.     guiSetVisible(loginGUI.loginB, false)
  89.     guiSetVisible(loginGUI.guestB, false)
  90.     guiSetVisible(loginGUI.username, false)
  91.     guiSetVisible(loginGUI.password, false)
  92.     playSound("files/sounds/achievement.mp3")
  93.     addEventHandler("onClientRender", getRootElement(), fadeLoginGUI)
  94. end
  95. addEvent("event_success", true)
  96. addEventHandler("event_success", getResourceRootElement(getThisResource()), successLogin)
Advertisement
Add Comment
Please, Sign In to add comment