Advertisement
Guest User

Untitled

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