Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------
- --Project: Vitality Gaming
- --Author: sekoX
- --File: login_client.lua
- --Side: Client
- ---------------------------------
- loginGUI = {}
- function loadLoginGUI()
- loginGUI.window = guiCreateStaticImage(screen.x/2-512/2, screen.y/2-512/2, 512, 512, "files/images/login/background.png", false)
- loginGUI.loginB = guiCreateStaticImage(113, 336, 128, 64, "files/images/login/login.png", false, loginGUI.window)
- loginGUI.guestB = guiCreateStaticImage(272, 336, 128, 64, "files/images/login/playasguest.png", false, loginGUI.window)
- loginGUI.username = guiCreateEdit(115, 245, 283, 26, "", false, loginGUI.window)
- loginGUI.password = guiCreateEdit(115, 305, 283, 26, "", false, loginGUI.window)
- guiSetAlpha(loginGUI.window, 0)
- guiEditSetMaxLength (loginGUI.username, 24)
- guiEditSetMasked (loginGUI.password, true)
- guiSetInputMode("no_binds_when_editing")
- addEventHandler ("onClientGUIClick", loginGUI.loginB, onButtonClick, false)
- addEventHandler ("onClientGUIClick", loginGUI.guestB, onButtonClick, false)
- addEventHandler("onClientRender", getRootElement(), fadeLoginGUI)
- showCursor(true)
- end
- addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), loadLoginGUI)
- function fadeLoginGUI()
- if guiGetAlpha(loginGUI.window) < 1 then
- guiSetAlpha(loginGUI.window, guiGetAlpha(loginGUI.window) + 0.05)
- end
- if guiGetAlpha(loginGUI.window) > 0 then
- guiSetAlpha(loginGUI.window, guiGetAlpha(loginGUI.window) - 0.05)
- end
- end
- function loginButtonHover()
- if source == loginGUI.loginB then
- guiStaticImageLoadImage(loginGUI.loginB, "files/images/login/login_hover.png")
- playSound("files/sounds/buttonHover.mp3")
- end
- end
- function loginButtonLeave()
- if source == loginGUI.loginB then
- guiStaticImageLoadImage(loginGUI.loginB, "files/images/login/login.png")
- end
- end
- function guestButtonHover()
- if source == loginGUI.guestB then
- guiStaticImageLoadImage(loginGUI.guestB, "files/images/login/playasguest_hover.png")
- playSound("files/sounds/buttonHover.mp3")
- end
- end
- function guestButtonLeave()
- if source == loginGUI.guestB then
- guiStaticImageLoadImage(loginGUI.guestB, "files/images/login/playasguest.png")
- end
- end
- addEventHandler("onClientMouseEnter", getRootElement(), loginButtonHover)
- addEventHandler("onClientMouseLeave", getRootElement(), loginButtonLeave)
- addEventHandler("onClientMouseEnter", getRootElement(), guestButtonHover)
- addEventHandler("onClientMouseLeave", getRootElement(), guestButtonLeave)
- function onButtonClick(button)
- if button == "left" then
- if source == loginGUI.loginB then
- triggerServerEvent("event_login", getLocalPlayer(), guiGetText(loginGUI.username), guiGetText(loginGUI.password))
- playSound("files/sounds/click.mp3")
- elseif source == loginGUI.guestB then
- triggerServerEvent("event_guest", getLocalPlayer())
- playSound("files/sounds/click.mp3")
- end
- end
- end
- function successLogin(message)
- showCursor(false)
- destroyElement(loginGUI.window)
- playSound("files/sounds/achievement.mp3")
- addEventHandler("onClientRender", getRootElement(), fadeLoginGUI)
- end
- addEvent("event_success", true)
- addEventHandler("event_success", getResourceRootElement(getThisResource()), successLogin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement