Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.19 KB | None | 0 0
  1. function OpenLoginScreen()
  2.     gui.EnableScreenClicker(true)
  3.    
  4.     local LoginFrame = vgui.Create( "DFrame" )
  5.     LoginFrame:SetSize( 300, 150 )
  6.     LoginFrame:SetTitle( "Login" ) -- Change the title of the window to whatever you want
  7.     LoginFrame:ShowCloseButton( true )
  8.     LoginFrame:SetSizable( false )
  9.     LoginFrame:SetDraggable( false )
  10.     LoginFrame:SetBackgroundBlur( true )
  11.     LoginFrame:MakePopup()
  12.     LoginFrame:Center()
  13.    
  14.     local LoginPanel = vgui.Create( "DPanel", LoginFrame )
  15.     LoginPanel:SetSize( 300- 20, 150 - 21- 20 )
  16.     LoginPanel:SetPos( 10, 10 + 22 )
  17.     LoginPanel.Paint = function() end
  18.    
  19.     local LoginUsername = vgui.Create( "DTextEntry", LoginPanel )
  20.     LoginUsername:SetMultiline( false )
  21.     LoginUsername:SetWidth( 260 )
  22.     LoginUsername:SetPos( 10, 10 )
  23.     LoginUsername:SetEditable( true )
  24.     LoginUsername:SetText( "Username" )
  25.     LoginUsername:SetTextColor( Color( 150, 150, 150, 255 ) )
  26.     LoginUsername.DefaultText = true
  27.     LoginUsername.OnGetFocus = function()
  28.         if( !LoginUsername.DefaultText ) then return end
  29.        
  30.         LoginUsername.DefaultText = false
  31.         LoginUsername:SetText( "" )
  32.         LoginUsername:SetTextColor( Color( 0, 0, 0, 255 ) )
  33.     end
  34.     LoginUsername.OnLoseFocus = function()
  35.         if( LoginUsername:GetValue() != "" ) then return end
  36.        
  37.         LoginUsername.DefaultText = true
  38.         LoginUsername:SetText( "Username" )
  39.         LoginUsername:SetTextColor( Color( 150, 150, 150, 255 ) )
  40.     end
  41.     LoginUsername.OnEnter = function()
  42.         if( LoginUsername:GetValue() != "" and LoginPassword.__SpecialValue != "" ) then
  43.             Login( LoginUsername:GetValue(), LoginPassword.__SpecialValue ) -- Change the function name to whatever it is in your code
  44.         elseif( LoginPassword ) then
  45.             LoginPassword:RequestFocus()
  46.         end
  47.     end
  48.    
  49.     local LoginPassword = vgui.Create( "DTextEntry", LoginPanel )
  50.     LoginPassword:SetMultiline( false )
  51.     LoginPassword:SetWidth( 260 )
  52.     LoginPassword:SetPos( 10, 10 + 10 + LoginUsername:GetTall() )
  53.     LoginPassword:SetEditable( true )
  54.     LoginPassword:SetText( "Password" )
  55.     LoginPassword:SetTextColor( Color( 150, 150, 150, 255 ) )
  56.     LoginPassword.DefaultText = true
  57.     LoginPassword.__SpecialValue = ""
  58.     LoginPassword.OnGetFocus = function()
  59.         if( !LoginPassword.DefaultText ) then return end
  60.        
  61.         LoginPassword.DefaultText = false
  62.         LoginPassword:SetText( "" )
  63.         LoginPassword:SetTextColor( Color( 0, 0, 0, 255 ) )
  64.     end
  65.     LoginPassword.OnLoseFocus = function()
  66.         if( LoginPassword:GetValue() != "" ) then return end
  67.        
  68.         LoginPassword.DefaultText = true
  69.         LoginPassword:SetText( "Password" )
  70.         LoginPassword:SetTextColor( Color( 150, 150, 150, 255 ) )
  71.     end
  72.     LoginPassword.OnEnter = function()
  73.         if( LoginUsername:GetValue() != "" and LoginPassword.__SpecialValue != "" ) then
  74.             Login( LoginUsername:GetValue(), LoginPassword.__SpecialValue ) -- Change the function name to whatever it is in your code
  75.         elseif( LoginPassword ) then
  76.             LoginPassword:RequestFocus()
  77.         end
  78.     end
  79.     LoginPassword.OnTextChanged = function()
  80.         -- Mask the box
  81.        
  82.         if( string.len( LoginPassword:GetValue() ) <= string.len( LoginPassword.__SpecialValue ) ) then
  83.             local len, value = string.len( LoginPassword:GetValue() ) - 1, ""
  84.                
  85.             for i = 1, len do
  86.                 value = value .. "*"
  87.             end
  88.            
  89.             LoginPassword.__SpecialValue = string.sub( LoginPassword.__SpecialValue, 0, -2 )
  90.             LoginPassword:SetValue( value )
  91.         else
  92.             local len, value = string.len( LoginPassword:GetValue() ), ""
  93.                
  94.             for i = 1, len do
  95.                 value = value .. "*"
  96.             end
  97.            
  98.             LoginPassword.__SpecialValue = LoginPassword.__SpecialValue .. string.sub( LoginPassword:GetValue(), -1, -1 )
  99.             LoginPassword:SetValue( value )
  100.         end
  101.     end
  102.    
  103.     local LoginLogin = vgui.Create( "DButton", LoginPanel )
  104.     LoginLogin:SetPos( LoginPanel:GetWide() / 2 + 5, 10 + 10 + 10 + LoginUsername:GetTall() * 2 )
  105.     LoginLogin:SetWidth( LoginPanel:GetWide() / 2 - 15 )
  106.     LoginLogin:SetText( "Login" )
  107.     LoginLogin.DoClick = function()
  108.         if( LoginUsername.DefaultText ) then
  109.             LoginUsername:RequestFocus()
  110.             return false
  111.         end
  112.         if( LoginPassword.DefaultText ) then
  113.             LoginPassword:RequestFocus()
  114.             return false
  115.         end
  116.         Login( LoginUsername:GetValue(), LoginPassword.__SpecialValue ) -- Change the function name to whatever it is in your code
  117.     end
  118.    
  119.     local LoginCreate = vgui.Create( "DButton", LoginPanel )
  120.     LoginCreate:SetPos( 10, 10 + 10 + 10 + LoginUsername:GetTall() * 2 )
  121.     LoginCreate:SetWidth( LoginPanel:GetWide() / 2 - 15 )
  122.     LoginCreate:SetText( "Create" )
  123.     LoginCreate.DoClick = function()
  124.         LoginPanel:SetVisible( false )
  125.         LoginFrame:SetSize( 300, 150 + LoginUsername:GetTall() + 10 )
  126.        
  127.         local LoginCreatePanel = vgui.Create( "DPanel", LoginFrame )
  128.         LoginCreatePanel:SetSize( 300 - 20, 150 + LoginUsername:GetTall() + 10 - 21 - 20 )
  129.         LoginCreatePanel:SetPos( 10, 10 + 22 )
  130.         LoginCreatePanel.Paint = function() end
  131.        
  132.         local LoginCreateUsername = vgui.Create( "DTextEntry", LoginCreatePanel )
  133.         LoginCreateUsername:SetMultiline( false )
  134.         LoginCreateUsername:SetWidth( 260 )
  135.         LoginCreateUsername:SetPos( 10, 10 )
  136.         LoginCreateUsername:SetEditable( true )
  137.         LoginCreateUsername:SetText( "Username" )
  138.         LoginCreateUsername:SetTextColor( Color( 150, 150, 150, 255 ) )
  139.         LoginCreateUsername.DefaultText = true
  140.         LoginCreateUsername.OnGetFocus = function()
  141.             if( !LoginCreateUsername.DefaultText ) then return end
  142.            
  143.             LoginCreateUsername.DefaultText = false
  144.             LoginCreateUsername:SetText( "" )
  145.             LoginCreateUsername:SetTextColor( Color( 0, 0, 0, 255 ) )
  146.         end
  147.         LoginCreateUsername.OnLoseFocus = function()
  148.             if( LoginCreateUsername:GetValue() != "" ) then return end
  149.            
  150.             LoginCreateUsername.DefaultText = true
  151.             LoginCreateUsername:SetText( "Username" )
  152.             LoginCreateUsername:SetTextColor( Color( 150, 150, 150, 255 ) )
  153.         end
  154.         LoginCreateUsername.OnEnter = function()
  155.             if( LoginCreateUsername:GetValue() == "" ) then
  156.                 LoginCreateUsername:RequestFocus()
  157.                 return false
  158.             elseif( LoginCreatePassword.__SpecialValue == "" ) then
  159.                 LoginCreatePassword:RequestFocus()
  160.                 return false
  161.             elseif( LoginCreatePasswordRe.__SpecialValue == "" ) then
  162.                 LoginCreatePasswordRe:RequestFocus()
  163.                 return false
  164.             elseif( LoginCreatePassword.__SpecialValue != LoginCreatePasswordRe.__SpecialValue ) then
  165.                 LoginCreatePassword:RequestFocus()
  166.                 return false
  167.             else
  168.                 CreateUser( LoginCreateUsername:GetValue(), LoginCreatePassword.__SpecialValue ) -- Change the function name to whatever it is in your code
  169.             end
  170.         end
  171.        
  172.         local LoginCreatePassword = vgui.Create( "DTextEntry", LoginCreatePanel )
  173.         LoginCreatePassword:SetMultiline( false )
  174.         LoginCreatePassword:SetWidth( 260 )
  175.         LoginCreatePassword:SetPos( 10, 10 + 10 + LoginCreateUsername:GetTall() )
  176.         LoginCreatePassword:SetEditable( true )
  177.         LoginCreatePassword:SetText( "Password" )
  178.         LoginCreatePassword:SetTextColor( Color( 150, 150, 150, 255 ) )
  179.         LoginCreatePassword.DefaultText = true
  180.         LoginCreatePassword.__SpecialValue = ""
  181.         LoginCreatePassword.OnGetFocus = function()
  182.             if( !LoginCreatePassword.DefaultText ) then return end
  183.            
  184.             LoginCreatePassword.DefaultText = false
  185.             LoginCreatePassword:SetText( "" )
  186.             LoginCreatePassword:SetTextColor( Color( 0, 0, 0, 255 ) )
  187.         end
  188.         LoginCreatePassword.OnLoseFocus = function()
  189.             if( LoginCreatePassword:GetValue() != "" ) then return end
  190.            
  191.             LoginCreatePassword.DefaultText = true
  192.             LoginCreatePassword:SetText( "Password" )
  193.             LoginCreatePassword:SetTextColor( Color( 150, 150, 150, 255 ) )
  194.         end
  195.         LoginCreatePassword.OnEnter = function()
  196.             if( LoginCreateUsername:GetValue() == "" ) then
  197.                 LoginCreateUsername:RequestFocus()
  198.                 return false
  199.             elseif( LoginCreatePassword.__SpecialValue == "" ) then
  200.                 LoginCreatePassword:RequestFocus()
  201.                 return false
  202.             elseif( LoginCreatePasswordRe.__SpecialValue == "" ) then
  203.                 LoginCreatePasswordRe:RequestFocus()
  204.                 return false
  205.             elseif( LoginCreatePassword.__SpecialValue != LoginCreatePasswordRe.__SpecialValue ) then
  206.                 LoginCreatePassword:RequestFocus()
  207.                 return false
  208.             else
  209.                 CreateUser( LoginCreateUsername:GetValue(), LoginCreatePassword.__SpecialValue ) -- Change the function name to whatever it is in your code
  210.             end
  211.         end
  212.         LoginCreatePassword.OnTextChanged = function()
  213.             -- Mask the box
  214.            
  215.             if( string.len( LoginCreatePassword:GetValue() ) <= string.len( LoginCreatePassword.__SpecialValue ) ) then
  216.                 local n = string.len( LoginCreatePassword.__SpecialValue ) - string.len( LoginCreatePassword:GetValue() )
  217.                 local len, value = string.len( LoginCreatePassword:GetValue() ) - n, ""
  218.                 print( n )
  219.                    
  220.                 for i = 1, len do
  221.                     value = value .. "*"
  222.                 end
  223.                
  224.                 LoginCreatePassword.__SpecialValue = string.sub( LoginCreatePassword.__SpecialValue, 0, -n - 1 )
  225.                 LoginCreatePassword:SetValue( value )
  226.             else
  227.                 local len, value = string.len( LoginCreatePassword:GetValue() ), ""
  228.                    
  229.                 for i = 1, len do
  230.                     value = value .. "*"
  231.                 end
  232.                
  233.                 LoginCreatePassword.__SpecialValue = LoginCreatePassword.__SpecialValue .. string.sub( LoginCreatePassword:GetValue(), -1, -1 )
  234.                 LoginCreatePassword:SetValue( value )
  235.             end
  236.             print( LoginCreatePassword.__SpecialValue )
  237.         end
  238.        
  239.         local LoginCreatePasswordRe = vgui.Create( "DTextEntry", LoginCreatePanel )
  240.         LoginCreatePasswordRe:SetMultiline( false )
  241.         LoginCreatePasswordRe:SetWidth( 260 )
  242.         LoginCreatePasswordRe:SetPos( 10, 10 + 10 + 10 + LoginCreateUsername:GetTall()* 2 )
  243.         LoginCreatePasswordRe:SetEditable( true )
  244.         LoginCreatePasswordRe:SetText( "Re-enter Password" )
  245.         LoginCreatePasswordRe:SetTextColor( Color( 150, 150, 150, 255 ) )
  246.         LoginCreatePasswordRe.DefaultText = true
  247.         LoginCreatePasswordRe.__SpecialValue = ""
  248.         LoginCreatePasswordRe.OnGetFocus = function()
  249.             if( !LoginCreatePasswordRe.DefaultText ) then return end
  250.            
  251.             LoginCreatePasswordRe.DefaultText = false
  252.             LoginCreatePasswordRe:SetText( "" )
  253.             LoginCreatePasswordRe:SetTextColor( Color( 0, 0, 0, 255 ) )
  254.         end
  255.         LoginCreatePasswordRe.OnLoseFocus = function()
  256.             if( LoginCreatePasswordRe:GetValue() != "" ) then return end
  257.            
  258.             LoginCreatePasswordRe.DefaultText = true
  259.             LoginCreatePasswordRe:SetText( "Re-enter Password" )
  260.             LoginCreatePasswordRe:SetTextColor( Color( 150, 150, 150, 255 ) )
  261.         end
  262.         LoginCreatePasswordRe.OnEnter = function()
  263.             if( LoginCreateUsername:GetValue() == "" ) then
  264.                 LoginCreateUsername:RequestFocus()
  265.                 return false
  266.             elseif( LoginCreatePassword.__SpecialValue == "" ) then
  267.                 LoginCreatePassword:RequestFocus()
  268.                 return false
  269.             elseif( LoginCreatePasswordRe.__SpecialValue == "" ) then
  270.                 LoginCreatePasswordRe:RequestFocus()
  271.                 return false
  272.             elseif( LoginCreatePassword.__SpecialValue != LoginCreatePasswordRe.__SpecialValue ) then
  273.                 LoginCreatePassword:RequestFocus()
  274.                 return false
  275.             else
  276.                 CreateUser( LoginCreateUsername:GetValue(), LoginCreatePassword.__SpecialValue ) -- Change the function name to whatever it is in your code
  277.             end
  278.         end
  279.         LoginCreatePasswordRe.OnTextChanged = function()
  280.             -- Mask the box
  281.            
  282.             if( string.len( LoginCreatePasswordRe:GetValue() ) <= string.len( LoginCreatePasswordRe.__SpecialValue ) ) then
  283.                 local n = string.len( LoginCreatePasswordRe.__SpecialValue ) - string.len( LoginCreatePasswordRe:GetValue() )
  284.                
  285.                 LoginCreatePasswordRe.__SpecialValue = string.sub( LoginCreatePasswordRe.__SpecialValue, 1, -n + 1 )
  286.             else
  287.                 local len, value = string.len( LoginCreatePasswordRe:GetValue() ), ""
  288.                    
  289.                 for i = 1, len do
  290.                     value = value .. "*"
  291.                 end
  292.                
  293.                 LoginCreatePasswordRe.__SpecialValue = LoginCreatePasswordRe.__SpecialValue .. string.sub( LoginCreatePasswordRe:GetValue(), -1, -1 )
  294.                 LoginCreatePasswordRe:SetValue( value )
  295.             end
  296.             print( LoginCreatePasswordRe.__SpecialValue )
  297.         end
  298.        
  299.         local LoginCreateChar = vgui.Create( "DButton", LoginCreatePanel )
  300.         LoginCreateChar:SetPos( LoginCreatePanel:GetWide() / 2 + 5, 10 + 10 + 10 + 10 + LoginUsername:GetTall() * 3 )
  301.         LoginCreateChar:SetWidth( LoginCreatePanel:GetWide() / 2 - 15 )
  302.         LoginCreateChar:SetText( "Create" )
  303.         LoginCreateChar.DoClick = function()
  304.             if( LoginCreateUsername:GetValue() == "" ) then
  305.                 LoginCreateUsername:RequestFocus()
  306.                 return false
  307.             elseif( LoginCreatePassword.__SpecialValue == "" ) then
  308.                 LoginCreatePassword:RequestFocus()
  309.                 return false
  310.             elseif( LoginCreatePasswordRe.__SpecialValue == "" ) then
  311.                 LoginCreatePasswordRe:RequestFocus()
  312.                 return false
  313.             elseif( LoginCreatePassword.__SpecialValue != LoginCreatePasswordRe.__SpecialValue ) then
  314.                 LoginCreatePassword:RequestFocus()
  315.                 return false
  316.             else
  317.                 CreateUser( LoginCreateUsername:GetValue(), LoginCreatePassword.__SpecialValue ) -- Change the function name to whatever it is in your code
  318.             end
  319.         end
  320.        
  321.         local LoginCreateCancel = vgui.Create( "DButton", LoginCreatePanel )
  322.         LoginCreateCancel:SetPos( 10, 10 + 10 + 10 + 10 + LoginUsername:GetTall() * 3 )
  323.         LoginCreateCancel:SetWidth( LoginCreatePanel:GetWide() / 2 - 15 )
  324.         LoginCreateCancel:SetText( "Cancel" )
  325.         LoginCreateCancel.DoClick = function()
  326.             LoginFrame:SetSize( 300, 150 )
  327.             LoginCreatePanel:SetVisible( false )
  328.             LoginPanel:SetVisible( true )
  329.         end
  330.     end
  331. end
  332.  
  333. function Login( User, Pass )
  334.     print( User, Pass )
  335. end
  336. function CreateUser( User, Pass )
  337.     print( User, Pass )
  338. end
  339. concommand.Add( "loginscreen", OpenLoginScreen() )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement