Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --SERVER:
- client = source --
- function loginHandler(username, password)
- if username == "user" and password =="password" then --
- spawnPlayer(client, 2505.52, -1741.73, 2072.98)
- fadeCamera(client, true, 1.0, 0, 0, 0) --
- setTimer( fadeCamera, 500, 1, client, true, 0.5 ) --
- outputChatBox("Welocme To Cops & Robbers Server", client)
- end
- else
- outputChatBox("Invalid email or Password. Please try again", client)
- return
- end
- addEvent("submitLogin", true)
- addEventHandler("submitLogin", root, loginHandler)
- addEvent("guestLogin", true)
- addEventHandler("guestLogin", root,
- function ()
- spawnPlayer(client, 2505.52, -1741.73, 2072.98)
- fadeCamera(client, false, 1.0, 0, 0, 0) --
- setTimer( fadeCamera, 500, 1, client, false, 0.5 ) --
- outputChatBox("Welocme To Cops & Robbers Server. Remember You are guest", client)
- end
- )
- --CLIENT:
- function createLoginWindow()
- local sWidth, sHeight = guiGetScreenSize()
- local width, height = 450, 450
- local x = (sWidth/2) - (width/2)
- local y = (sHeight/2) - (height/2)
- loginWindow = guiCreateWindow(x,y, width, height, "Please Log-In", false)
- guiWindowSetMovable (loginWindow, false)
- guiWindowSetSizable (loginWindow, false)
- guiCreateLabel(200,110,55, 35, "Email", false, loginWindow)
- guiCreateLabel(200,185, 55,35, "Password", false, loginWindow )
- editUser = guiCreateEdit(125,125,200,40, "", false, loginWindow)
- editPass = guiCreateEdit(125, 200, 200, 40, "", false, loginWindow)
- guiEditSetMaxLength(editUser, 50)
- guiEditSetMaxLength(editPass, 50)
- buttLog = guiCreateButton(175, 250, 100, 50, "Submit", false, loginWindow)
- guest = guiCreateButton(175, 350, 100,50, "Play as Guest", false, loginWindow) --
- guiSetVisible(loginWindow, false)
- end
- function submit() --
- if (source == buttLog) then --
- local username = guiGetText(editUser)
- local password = guiGetText(editPass)
- if username and password then
- triggerServerEvent("submitLogin", getRootElement(), username, password)
- guiSetInputEnabled(false)
- guiSetVisible(loginWindow, false)
- showCursor(false)
- else
- outputChatBox("Please Enter Email And Password")
- end
- end
- end
- addEventHandler("onClientGUIClick", buttLog, submit, false)
- function guestAcc () --
- if (source == guest)then --
- triggerServerEvent("guestLogin", getRootElement())
- guiSetVisible(loginWindow, false)
- showCursor(false)
- end
- end
- addEventHandler("onClientGUIClick", guest, guestAcc, false)
- addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
- function()
- createLoginWindow()
- outputChatBox("Wlcome to MTA:SA Cops & Robbers Server. Please Log-In")
- if loginWindow ~= nil then
- guiSetVisible(loginWindow, true)
- else
- outputChatBox("An error has occured")
- end
- showCursor(true)
- guiSetInputEnabled(true)
- end
- )
Add Comment
Please, Sign In to add comment