Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. local localPlayer = getLocalPlayer()
  2. local localPlayerName = getPlayerName(localPlayer)
  3. local localRootElement = getRootElement()
  4. local newUser
  5. local passwordAttempts = 0
  6.  
  7.  
  8. function Script1 ()
  9. bindKey( "F2", "down", CreateLoginWindow )
  10. end
  11.  
  12.  
  13. function CreateLoginWindow()
  14. wdwLogin = guiCreateWindow(226,146,372,233,"[Admin Login System]",false)
  15. guiWindowSetMovable(wdwLogin,false)
  16. guiWindowSetSizable(wdwLogin,false)
  17. tabpanel = guiCreateTabPanel(0.0242,0.0858,0.9489,0.8755,true,wdwLogin)
  18. tab1 = guiCreateTab("Login",tabpanel)
  19. login = guiCreateButton(0.1000,0.8611,0.2436,0.1167,"Login",true,tab1)
  20. username = guiCreateLabel(0.0113,0.1167,0.3768,0.15,"UserName:",true,tab1)
  21. guiLabelSetColor(username,255,255,255)
  22. guiLabelSetVerticalAlign(username,"top")
  23. guiLabelSetHorizontalAlign(username,"left",false)
  24. guiSetFont(username,"default-bold-small")
  25. password = guiCreateLabel(0.0113,0.2889,0.3768,0.15,"Password:",true,tab1)
  26. guiLabelSetColor(password,255,255,255)
  27. guiLabelSetVerticalAlign(password,"top")
  28. guiLabelSetHorizontalAlign(password,"left",false)
  29. guiSetFont(password,"default-bold-small")
  30. username = guiCreateEdit(0.2266,0.1,0.3598,0.1389,localPlayerName,true,tab1)
  31. password = guiCreateEdit(0.2266,0.2611,0.3598,0.1389,"",true,tab1)
  32. Canel = guiCreateButton( 0.4, 0.85, 0.20, 0.15, "Cancel", true,tab1 )
  33. guiEditSetMasked(password,true)
  34.  
  35.  
  36. tab2 = guiCreateTab("Info",tabpanel)
  37. Information= guiCreateButton ( 0.010, 0.100, 0.970, 0.800, "Information-This window is only for ADMINS if any non-Admin Trys to login and fail for about 3 turns they will be BANNED! The only people who should be trying to login is Admins named- Cannonball - Street - Tom508-Click on this to close the window", true, tab2 )
  38.  
  39. guiSetVisible(wdwLogin,false)
  40.  
  41. function Binds()
  42. bindKey( "F2", "up", CreateLoginWindow )
  43. end
  44. addEventHandler("onClientResourceStart", getRootElement(), Binds)
  45.  
  46.  
  47. addEventHandler("onClientGUIClick", Canel, closeWindow)
  48. addEventHandler("onClientGUIClick", Information, closeWindow)
  49. end
  50.  
  51. function closeWindow()
  52. guiSetVisible(wdwLogin, false)
  53. showCursor( false )
  54. end
  55.  
  56. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
  57. function()
  58. CreateLoginWindow()
  59. lblDisplayArea = guiCreateLabel(0.100,0.800,0.800,0.100,"",true)
  60. guiLabelSetHorizontalAlign(lblDisplayArea,"center",true)
  61.  
  62. addEventHandler("onClientGUIClick",login,clientSubmitLogin,false)
  63. addEventHandler("onClientGUIClick",register,clientSubmitCreate,false)
  64. addEventHandler("onClientGUIAccepted",password,clientEnterLogin,false)
  65.  
  66. triggerServerEvent ("checkValidAct",localPlayer,localPlayerName)
  67. end
  68. )
  69.  
  70. function clientNewUserHandler() --Called when no account exists for this players name...
  71. newUser = true
  72. guiSetText(lblDisplayArea,"")
  73. if(tab2) then
  74. guiSetVisible(wdwLogin,true)
  75. guiBringToFront(edtPass) --Puts the cursor into the password box for typing...
  76. end
  77. showCursor(true)
  78. guiSetInputEnabled(true)
  79. end
  80. addEvent("clientNewUser",true)
  81. addEventHandler("clientNewUser",localRootElement,clientNewUserHandler)
  82.  
  83. function clientReturningUserHandler() --Called when there is an existing account for this player's name...
  84. newUser = false
  85. guiSetText(lblDisplayArea,"You are using a registered nickname - please enter your password.")
  86. if(wdwLogin) then
  87. guiSetVisible(wdwLogin,true)
  88. guiBringToFront(edtPass) --Puts the cursor into the password box for typing...
  89. end
  90. showCursor(true)
  91. guiSetInputEnabled(true)
  92. end
  93. addEvent("clientReturningUser",true)
  94. addEventHandler("clientReturningUser",localRootElement,clientReturningUserHandler)
  95.  
  96. function clientEnterLogin()
  97. if(newUser) then
  98. triggerServerEvent("SubmitCreate",localRootElement,guiGetText(edtUser),guiGetText(edtPass))
  99. else
  100. triggerServerEvent("SubmitLogin",localRootElement,guiGetText(edtUser),guiGetText(edtPass))
  101. end
  102. end
  103.  
  104. function clientSubmitLogin(button)
  105. if(button == "left") then
  106. if(newUser) then
  107. triggerServerEvent("SubmitCreate",localRootElement,guiGetText(edtUser),guiGetText(edtPass))
  108. else
  109. triggerServerEvent("SubmitLogin",localRootElement,guiGetText(edtUser),guiGetText(edtPass))
  110. end
  111. end
  112. end
  113.  
  114. function clientDisplayAreaHandler(theMessage)
  115. guiSetText(lblDisplayArea,theMessage)
  116. end
  117. addEvent("clientDisplayArea",true)
  118. addEventHandler("clientDisplayArea",localRootElement,clientDisplayAreaHandler)
  119.  
  120. function clientWrongPasswordHandler(theMessage)
  121. passwordAttempts = passwordAttempts + 1
  122. if(passwordAttempts > 3) then
  123. guiSetText(lblDisplayArea,"Too many incorrect password attempts. Please disconnect.")
  124. destroyElement(wdwLogin)
  125. triggerServerEvent("removePlayer",localPlayer)
  126. end
  127. end
  128. addEvent("clientWrongPassword",true)
  129. addEventHandler("clientWrongPassword",localRootElement,clientWrongPasswordHandler)
  130.  
  131. function clientLoginSuccessHandler()
  132. guiSetInputEnabled(false)
  133. destroyElement(wdwLogin)
  134. destroyElement(lblDisplayArea)
  135. wdwLogin = nil
  136. newUser = nil
  137. lblDisplayArea = nil
  138. passwordAttempts = nil
  139. localPlayer = nil
  140. localPlayerName = nil
  141. localRootElement = nil
  142. showCursor(false)
  143. end
  144. addEvent("clientLoginSuccess",true)
  145. addEventHandler("clientLoginSuccess",localRootElement,clientLoginSuccessHandler)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement