Advertisement
Guest User

logon-client

a guest
Jan 29th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.60 KB | None | 0 0
  1. local LogonDialog
  2.  
  3. addEvent("onClientPlayerLogon", true)
  4. addEvent("onClientPlayerAuthorized" )
  5. local function onClientPlayerLogon(errorCode, id)
  6.     if LogonDialog then
  7.         if errorCode == 0 then
  8.             LogonDialog:delete()
  9.             LogonDialog = nil
  10.             triggerEvent( "onClientPlayerAuthorized", localPlayer, id )
  11.         elseif errorCode == 1 then
  12.             LogonDialog.elements.message = "Не правильное имя или пароль" --"Invalid name or password"
  13.         elseif errorCode == 2 then
  14.             LogonDialog.elements.message = "Ошибка при регистрации, попробуйте другое имя" --"Registration error, try oher name"--
  15.         end
  16.     end
  17. end
  18. addEventHandler ("onClientPlayerLogon", localPlayer, onClientPlayerLogon)
  19.  
  20. addEvent("onPlayerLogon", true)
  21. local function OnClientResourceStart()
  22.     LogonDialog = Dialog:new({{ "window", acquireControls = true,
  23.         x = 0, y = 0, width = -0.6, height = -0.3, anchor = "cm", text = "Logon",
  24.         style = { style = "secondary", closable = false, sizable = false, movable = false, alfa = 1 },
  25.         {
  26.                            { "label",  x =  0.05, y =  0.00, width = 0.9,  height = 0.14, text = "Username:", style = { valign = "m" } },
  27.             username     = { "edit",   x =  0.05, y =  0.15, width = 0.9,  height = 0.14, text = "" },
  28.                            { "label",  x =  0.05, y =  0.30, width = 0.9,  height = 0.14, text = "Password:", style = { valign = "m" } },
  29.             password     = { "edit",   x =  0.05, y =  0.45, width = 0.9,  height = 0.14, text = "", masked = true },
  30.             message      = { "label",  x =  0.05, y =  0.60, width = 0.9,  height = 0.14, text = "", style = { valign = "m" } },
  31.             logon        = { "button", x = -0.05, y = -0.05, width = 0.25, height = 0.14, anchor = "rb", text = "Logon",
  32.                 onClick = function(dialog,template,button,state)
  33.                     if button == "left" and state == "down" then
  34.                         local username = dialog.elements.username
  35.                         local password = dialog.elements.password
  36.                         dialog.elements.message = ""
  37.                         triggerServerEvent( "onPlayerLogon", localPlayer, username, password )
  38.                     end
  39.                 end
  40.             },
  41.             registration = { "button", x =  0.05, y = -0.05, width = 0.25, height = 0.14, anchor = "lb", text = "Registration",
  42.                 onClick = function(dialog,template,button,state)
  43.                     if button == "left" and state == "down" then
  44.                         local username = dialog.elements.username
  45.                         local password = dialog.elements.password
  46.                         dialog.elements.message = ""
  47.                         triggerServerEvent( "onPlayerLogon", localPlayer, username, password, true )
  48.                     end
  49.                 end
  50.             }
  51.         }
  52.     }})
  53. end
  54. addEventHandler ("onClientResourceStart", resourceRoot, OnClientResourceStart)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement