Guest User

Untitled

a guest
Jan 19th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.82 KB | None | 0 0
  1. --SERVER:
  2. client = source --
  3.  
  4. function loginHandler(username, password)
  5.  if username == "user" and password =="password" then --
  6.    spawnPlayer(client, 2505.52, -1741.73, 2072.98)
  7.    fadeCamera(client, true, 1.0, 0, 0, 0) --
  8.    setTimer( fadeCamera, 500, 1, client, true, 0.5 ) --
  9.    outputChatBox("Welocme To Cops & Robbers Server", client)
  10.  end
  11.  else
  12.   outputChatBox("Invalid email or Password. Please try again", client)
  13.   return
  14.  end
  15. addEvent("submitLogin", true)
  16. addEventHandler("submitLogin", root, loginHandler)
  17.  
  18. addEvent("guestLogin", true)
  19. addEventHandler("guestLogin", root,
  20. function ()
  21.   spawnPlayer(client, 2505.52, -1741.73, 2072.98)
  22.   fadeCamera(client, false, 1.0, 0, 0, 0) --
  23.   setTimer( fadeCamera, 500, 1, client, false, 0.5 ) --
  24.   outputChatBox("Welocme To Cops & Robbers Server. Remember You are guest", client)
  25. end
  26. )
  27.  
  28. --CLIENT:
  29. function createLoginWindow()
  30.     local sWidth, sHeight = guiGetScreenSize()
  31.     local width, height = 450, 450
  32.    
  33.     local x = (sWidth/2) - (width/2)
  34.     local y = (sHeight/2) - (height/2)
  35.    
  36.     loginWindow = guiCreateWindow(x,y, width, height, "Please Log-In", false)
  37.     guiWindowSetMovable (loginWindow, false)
  38.     guiWindowSetSizable (loginWindow, false)
  39.    
  40.     guiCreateLabel(200,110,55, 35, "Email", false, loginWindow)
  41.     guiCreateLabel(200,185, 55,35, "Password", false, loginWindow )
  42.    
  43.     editUser = guiCreateEdit(125,125,200,40, "", false, loginWindow)
  44.     editPass = guiCreateEdit(125, 200, 200, 40, "", false, loginWindow)
  45.     guiEditSetMaxLength(editUser, 50)
  46.     guiEditSetMaxLength(editPass, 50)
  47.    
  48.     buttLog = guiCreateButton(175, 250, 100, 50, "Submit", false, loginWindow)
  49.    
  50.     guest = guiCreateButton(175, 350, 100,50, "Play as Guest", false, loginWindow) --
  51.    
  52.     guiSetVisible(loginWindow, false)
  53.    
  54. end
  55. function submit() --
  56.     if (source == buttLog) then --
  57.         local username = guiGetText(editUser)
  58.         local password = guiGetText(editPass)
  59.         if username and password then
  60.             triggerServerEvent("submitLogin", getRootElement(), username, password)
  61.             guiSetInputEnabled(false)
  62.             guiSetVisible(loginWindow, false)
  63.             showCursor(false)
  64.         else
  65.             outputChatBox("Please Enter Email And Password")
  66.         end
  67.     end
  68. end
  69. addEventHandler("onClientGUIClick", buttLog, submit, false)
  70.  
  71. function guestAcc () --
  72.     if (source == guest)then --
  73.         triggerServerEvent("guestLogin", getRootElement())
  74.         guiSetVisible(loginWindow, false)
  75.         showCursor(false)
  76.     end
  77. end
  78. addEventHandler("onClientGUIClick", guest, guestAcc, false)
  79.  
  80. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
  81.     function()
  82.         createLoginWindow()
  83.        
  84.         outputChatBox("Wlcome to MTA:SA Cops & Robbers Server. Please Log-In")
  85.         if loginWindow ~= nil then
  86.             guiSetVisible(loginWindow, true)
  87.         else
  88.             outputChatBox("An error has occured")
  89.         end
  90.        
  91.         showCursor(true)
  92.         guiSetInputEnabled(true)
  93.        
  94.     end
  95. )
Add Comment
Please, Sign In to add comment