Advertisement
Guest User

Untitled

a guest
Apr 18th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.45 KB | None | 0 0
  1. thePlayer = getLocalPlayer()
  2. local screenWidth,screenHeight = guiGetScreenSize()
  3. --showChat(false)
  4.  
  5.  
  6. function startup()
  7. showChat(true)
  8. setElementHealth(thePlayer,100)
  9. setElementPosition (thePlayer, 1584.39856, -2654.52710, 13.54688)
  10. local localPlayerName = getPlayerName(thePlayer)
  11. outputChatBox("Welcome " .. localPlayerName .. " on my server!")
  12. -- destroyElement(GUIEditor.window[1])
  13. -- showCursor(false)
  14. removeEventHandler("onClientRender", root, logPanel)
  15. end
  16.  
  17. GUIEditor = {
  18. tab = {},
  19. tabpanel = {},
  20. edit = {},
  21. button = {},
  22. window = {},
  23. label = {}
  24. }
  25.  
  26.  
  27. function loginGUI()
  28. local screenW, screenH = guiGetScreenSize()
  29. GUIEditor.window[1] = guiCreateWindow((screenW - 376) / 2, (screenH - 317) / 2, 376, 317, "Welcome", false)
  30. guiWindowSetSizable(GUIEditor.window[1], false)
  31. showCursor(true)
  32.  
  33. GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 20, 357, 287, false, GUIEditor.window[1])
  34.  
  35. GUIEditor.tab[1] = guiCreateTab("Login", GUIEditor.tabpanel[1])
  36.  
  37. GUIEditor.label[1] = guiCreateLabel(94, 81, 103, 20, "Username:", false, GUIEditor.tab[1])
  38. GUIEditor.label[2] = guiCreateLabel(94, 108, 103, 20, "Password:", false, GUIEditor.tab[1])
  39. GUIEditor.edit[1] = guiCreateEdit(155, 81, 83, 20, "", false, GUIEditor.tab[1])
  40. GUIEditor.edit[2] = guiCreateEdit(155, 108, 83, 20, "", false, GUIEditor.tab[1])
  41. GUIEditor.button[1] = guiCreateButton(133, 144, 64, 25, "Login", false, GUIEditor.tab[1])
  42. GUIEditor.label[3] = guiCreateLabel(97, 179, 200, 20, "", false, GUIEditor.tab[1])
  43.  
  44. GUIEditor.tab[2] = guiCreateTab("Register", GUIEditor.tabpanel[1])
  45.  
  46. GUIEditor.label[4] = guiCreateLabel(80, 67, 92, 20, "Username:", false, GUIEditor.tab[2])
  47. GUIEditor.label[5] = guiCreateLabel(80, 92, 92, 20, "Password:", false, GUIEditor.tab[2])
  48. GUIEditor.label[6] = guiCreateLabel(80, 117, 92, 20, "Password:", false, GUIEditor.tab[2])
  49. GUIEditor.edit[3] = guiCreateEdit(143, 68, 78, 20, "", false, GUIEditor.tab[2])
  50. GUIEditor.edit[4] = guiCreateEdit(143, 92, 78, 20, "", false, GUIEditor.tab[2])
  51. GUIEditor.edit[5] = guiCreateEdit(143, 118, 78, 20, "", false, GUIEditor.tab[2])
  52. GUIEditor.button[2] = guiCreateButton(107, 151, 75, 23, "Register", false, GUIEditor.tab[2])
  53. GUIEditor.label[7] = guiCreateLabel(86, 184, 200, 20, "", false, GUIEditor.tab[2])
  54. GUIEditor.label[8] = guiCreateLabel(80, 37, 140, 20, "Max lenght 10 character!", false, GUIEditor.tab[2])
  55. guiLabelSetColor(GUIEditor.label[8], 255, 0, 0)
  56. fixEdit()
  57.  
  58. addEventHandler("onClientGUIClick", GUIEditor.button[1], function()
  59. uname = guiGetText(GUIEditor.edit[1])
  60. pw = guiGetText (GUIEditor.edit[2])
  61.  
  62. if uname == "" or pw == "" then
  63. guiSetText(GUIEditor.label[3], "Invalid username or password!")
  64. guiLabelSetColor(GUIEditor.label[3], 255, 0, 0)
  65. regClear()
  66. else
  67. pw = md5(pw)
  68. triggerServerEvent("onLogining", resourceRoot, uname,pw)
  69. end
  70.  
  71. addEvent("onLogining", true)
  72. addEventHandler("onLogining", thePlayer, function(labelText, password)
  73. if labelText == "Successful login! Wait few seconds!" then
  74. guiSetText(GUIEditor.label[3], labelText)
  75. guiLabelSetColor(GUIEditor.label[3], 0, 255, 0)
  76. setTimer ( function()
  77. startup()
  78. end, 5000, 1 )
  79. else
  80. regClear()
  81. guiSetText(GUIEditor.label[3], "Invalid username or password!")
  82. guiLabelSetColor(GUIEditor.label[3], 255, 0, 0)
  83. end
  84. end)
  85.  
  86. end,false)
  87.  
  88. addEventHandler("onClientGUIClick", GUIEditor.button[2], function()
  89. uname = guiGetText(GUIEditor.edit[3])
  90. pw = guiGetText (GUIEditor.edit[4])
  91. pw2 = guiGetText (GUIEditor.edit[5])
  92. if uname == "" or uname == " " then
  93. guiSetText(GUIEditor.label[7], "Incorrect username!")
  94. guiLabelSetColor(GUIEditor.label[7], 255, 0, 0)
  95. regClear()
  96. elseif pw ~= pw2 or pw == "" then
  97. guiSetText(GUIEditor.label[7], "The password don't match!")
  98. guiLabelSetColor(GUIEditor.label[7], 255, 0, 0)
  99. regClear()
  100. else
  101. local uname = guiGetText(GUIEditor.edit[3])
  102. pw = md5(pw2)
  103. outputChatBox(pw)
  104. triggerServerEvent("onRegister", resourceRoot,uname, pw)
  105.  
  106. addEvent("onRegistered", true)
  107. addEventHandler("onRegistered", thePlayer, function(labelText)
  108. guiSetText(GUIEditor.label[7], labelText)
  109. regClear()
  110. guiLabelSetColor(GUIEditor.label[7], 0, 255, 0)
  111. end)
  112.  
  113. addEvent("onUsed", true)
  114. addEventHandler("onUsed", thePlayer, function(labelText)
  115. guiSetText(GUIEditor.label[7], labelText)
  116. regClear()
  117. guiLabelSetColor(GUIEditor.label[7], 255, 0, 0)
  118. end)
  119. end
  120. end, false)
  121. end
  122. addEventHandler("onClientPlayerJoin", root, loginGUI)
  123. addCommandHandler("asd", loginGUI )
  124. ----------------------------------------------------------------------
  125. function regClear()
  126. guiSetText(GUIEditor.edit[1], "")
  127. guiSetText(GUIEditor.edit[2], "")
  128. guiSetText(GUIEditor.edit[3], "")
  129. end
  130.  
  131. function fixEdit()
  132. guiEditSetMaxLength(GUIEditor.edit[1], 10)
  133. guiEditSetMaxLength(GUIEditor.edit[2], 10)
  134. guiEditSetMaxLength(GUIEditor.edit[3], 10)
  135. guiEditSetMaxLength(GUIEditor.edit[4], 10)
  136. guiEditSetMaxLength(GUIEditor.edit[5], 10)
  137.  
  138. guiEditSetMasked ( GUIEditor.edit[2], true )
  139. guiEditSetMasked ( GUIEditor.edit[4], true )
  140. guiEditSetMasked ( GUIEditor.edit[5], true )
  141. end
  142. -------------------------------------------------------------Login Screen
  143.  
  144. function isMouseInPosition(a, b, c, d)
  145. if not isCursorShowing() then return end
  146. local x, y = getCursorPosition()
  147. x, y = x*screenWidth, y*screenHeight
  148. if x >= a and y >= b and x <= a+c and y <= b+d then
  149. return true
  150. end
  151. return false
  152. end
  153.  
  154. function logregPanel()
  155. stopRender = false
  156. function logPanel()
  157. dxDrawImage(screenWidth / 2 -350, screenHeight / 2 -90, 660, 155, "Login_Sys/data/log_panel.png")
  158. dxDrawImage(screenWidth / 2 -110, screenHeight / 2 -12.5 , 150, 35, "Login_Sys/data/log_panel_edit.png")
  159. dxDrawImage(screenWidth / 2 -110, screenHeight / 2 +20 , 150, 35, "Login_Sys/data/log_panel_edit.png")
  160.  
  161. if( isMouseInPosition(screenWidth / 2 + 40, screenHeight / 2 + 10, 157, 33 ) ) == true then
  162. dxDrawImage(screenWidth / 2 + 40, screenHeight / 2 + 10, 157, 33, "Login_Sys/data/loginOver.png")
  163. else
  164. dxDrawImage(screenWidth / 2 + 40, screenHeight / 2 + 10, 157, 33, "Login_Sys/data/login.png")
  165. end
  166.  
  167. function LoginBTN (button,state)
  168. stopRender = 0
  169. if stopRender == 0 then
  170. if ( isMouseInPosition (screenWidth / 2 + 40, screenHeight / 2 + 10, 157, 33 ) ) then
  171. if ( button == "left" and state == "up" ) then
  172. uname = guiGetText(GUIEditor.edit[1])
  173. pw = guiGetText (GUIEditor.edit[2])
  174. if uname == "" or pw == "" then
  175. removeEventHandler("onClientRender", root, erLog)
  176. addEventHandler("onClientRender", root, erLog)
  177. regClear()
  178. outputChatBox("anyád",0,0,255)
  179. else
  180. if stopRender == 0 then
  181. stopRender = 1
  182. if stopRender == 1 then
  183. pw = md5(pw)
  184. triggerServerEvent("onLogining", resourceRoot, uname,pw)
  185. stopRender = 0
  186. end
  187. stopRender = 0
  188. end
  189. stopRender = 1
  190. end
  191. stopRender = 1
  192. end
  193. addEvent("onLogining", true)
  194. addEventHandler("onLogining", thePlayer, function(labelText, password)
  195. if stopRender == 1 then
  196. stopRender = 0
  197. if stopRender == 0 then
  198. if labelText == "Successful login! Wait few seconds!" then
  199. addEventHandler("onClientRender", root, sfLog)
  200. removeEventHandler("onClientRender", root, erLog)
  201. outputChatBox("anyád")
  202. setTimer ( function()
  203. startup()
  204. end, 5000, 1 )
  205. else
  206. removeEventHandler("onClientRender", root, erLog)
  207. addEventHandler("onClientRender", root, erLog)
  208. regClear()
  209. outputChatBox("anyád",255,0,0)
  210. end
  211. end
  212. stopRender = 0
  213. end
  214. end)
  215. stopRender = 1
  216. end
  217. stopRender = 1
  218. end
  219. stopRender = 1
  220. end
  221. addEventHandler("onClientClick", root, LoginBTN)
  222.  
  223. dxDrawText ( guiGetText(GUIEditor.edit[1]), screenWidth / 2 -95, screenHeight / 2 -2 ,100,19, tocolor ( 255, 255, 255, 255 ), 1, "arial" )
  224.  
  225. editTextIn = (guiGetText(GUIEditor.edit[2]))
  226. editTextLength = string.len(editTextIn)
  227. editTextOut = ""
  228. for i = 1 , editTextLength do
  229. editTextOut = (editTextOut .. "*")
  230. end
  231. dxDrawText ( editTextOut, screenWidth / 2 -95, screenHeight / 2 + 32 ,100,19, tocolor ( 255, 255, 255, 255 ), 1, "arial" )
  232.  
  233. function erLog()
  234. dxDrawImage(screenWidth / 2 -286, screenHeight / 2 + 80, 572, 60, "Login_Sys/data/invalid_u_p.png")
  235. end
  236. function sfLog()
  237. dxDrawImage(screenWidth / 2 -335, screenHeight / 2 + 80, 670, 60, "Login_Sys/data/successful_login.png")
  238. end
  239. stopRender = true
  240. end
  241.  
  242. --Background
  243. dxDrawRectangle (screenWidth / 2-330, screenHeight / 2-77.5, 660, 155, tocolor ( 0, 0, 0, 150 ) ) --OP cuc mindenhova betenni!!!!
  244. dxDrawImage(screenWidth / 2-330, screenHeight / 2-77.5, 660, 155, "Login_Sys/data/login_background.png")
  245. --Login
  246. if( isMouseInPosition(screenWidth / 2 + 40, screenHeight / 2 + 15, 157, 33 ) ) == true then
  247. dxDrawImage(screenWidth / 2 + 40, screenHeight / 2 + 15, 157, 33, "Login_Sys/data/loginOver.png")
  248. addEventHandler("onClientClick", root, function(button, state)
  249. if stopRender == false then
  250. if ( isMouseInPosition (screenWidth / 2 + 40, screenHeight / 2 + 15, 157, 33 ) ) then
  251. if ( button == "left" and state == "up" ) then
  252. removeEventHandler("onClientRender", root, logregPanel)
  253. addEventHandler("onClientRender", root, logPanel)
  254. end
  255. end
  256. stopRender = true
  257. end
  258. end)
  259. else
  260. dxDrawImage(screenWidth / 2 + 40, screenHeight / 2 + 15, 157, 33, "Login_Sys/data/login.png")
  261. end
  262.  
  263. --Register
  264. if( isMouseInPosition(screenWidth / 2 - 260, screenHeight / 2 + 5, 226, 50 ) ) == true then
  265. dxDrawImage(screenWidth / 2 - 260, screenHeight / 2 + 5, 226, 50, "Login_Sys/data/registerOver.png")
  266. else
  267. dxDrawImage(screenWidth / 2 - 260, screenHeight / 2 + 5, 226, 50, "Login_Sys/data/register.png")
  268. end
  269. end
  270.  
  271.  
  272. addEventHandler("onClientResourceStart", resourceRoot,
  273. function()
  274. GUIEditor = {
  275. edit = {}
  276. }
  277.  
  278. GUIEditor.edit[1] = guiCreateEdit(screenWidth / 2 -95, screenHeight / 2 - 4 , 204,20, "", false)
  279. GUIEditor.edit[2] = guiCreateEdit(screenWidth / 2 -100, screenHeight / 2 +28 , 204, 20, "", false)
  280. GUIEditor.edit[3] = guiCreateEdit(screenWidth, screenHeight / 2 +28 , 204, 20, "", false)
  281.  
  282. guiEditSetMaxLength ( GUIEditor.edit[1], 10 )
  283. guiEditSetMaxLength ( GUIEditor.edit[2], 10 )
  284. guiEditSetMaxLength ( GUIEditor.edit[3], 10 )
  285.  
  286. guiSetAlpha(GUIEditor.edit[1], 0)
  287. guiSetAlpha(GUIEditor.edit[2], 0)
  288. guiSetAlpha(GUIEditor.edit[3], 0)
  289.  
  290.  
  291. end)
  292.  
  293. function logClick (button,state)
  294. if ( isMouseInPosition ( screenWidth / 2 + 40, screenHeight / 2 + 15, 157, 33 ) ) then
  295. if ( button == "left" and state == "up" ) then
  296. showCursor(false)
  297. removeEventHandler("onClientRender", root, logregPanel)
  298. end
  299. end
  300. end
  301.  
  302. --addEventHandler("onClientClick", root, logClick)
  303.  
  304.  
  305.  
  306. function HandleTheRendering ( )
  307. showCursor(true)
  308. addEventHandler("onClientRender", root, logregPanel)
  309. end
  310. -- addEventHandler("onClientPlayerJoin", root, HandleTheRendering)
  311. addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering)
  312. --------------------------------------------------
  313. function getPos()
  314. x,y,z = getElementPosition(thePlayer)
  315. outputConsole(x .. ", " .. y .. ", " .. z)
  316. end
  317. addCommandHandler("gp", getPos)
  318. function setPos(cmd, x,y,z)
  319. setElementPosition(thePlayer, x,y,z)
  320. end
  321. addCommandHandler("sp", setPos)
  322.  
  323. ------------------------------------------------------------
  324.  
  325.  
  326. addEventHandler("onClientPlayerDamage", thePlayer, function()
  327. playerHP = getElementHealth(thePlayer)
  328. if playerHP == 0 then
  329. setTimer( function()
  330. triggerServerEvent("onPlayerWasteed", thePlayer)
  331. end, 2000, 1)
  332. end
  333. end, false)
  334.  
  335. -----------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement