Advertisement
Guest User

Untitled

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