Advertisement
Guest User

hgfhgfh

a guest
Sep 23rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.39 KB | None | 0 0
  1. --[[
  2. * ***********************************************************************************************************************
  3. * Copyright (c) 2015 OwlGaming Community - All Rights Reserved
  4. * All rights reserved. This program and the accompanying materials are private property belongs to OwlGaming Community
  5. * Unauthorized copying of this file, via any medium is strictly prohibited
  6. * Proprietary and confidential
  7. * ***********************************************************************************************************************
  8. ]]
  9.  
  10. local panel = {
  11. login = {},
  12. register = {},
  13. sounds = {
  14. { 'http://files.owlgaming.net/menu.mp3', 0.3 },
  15. { 'http://files.owlgaming.net/gtav.mp3', 0.3 },
  16. { 'http://files.owlgaming.net/gtaiv.mp3', 0.3 },
  17. }
  18. }
  19. local sw, sh = guiGetScreenSize()
  20. local fade = { }
  21. local logoScale = 0.5
  22. local logoSize = { sw*logoScale, sw*455/1920*logoScale }
  23. local uFont
  24.  
  25. function open_log_reg_pannel()
  26. if not isElement ( panel.login.main ) then
  27. -- blur screen.
  28. triggerEvent( 'hud:blur', resourceRoot, 'off', true )
  29. setTimer( triggerEvent, 8000, 1, 'hud:blur', resourceRoot, 6, true, 0.1, nil )
  30.  
  31. -- sound effects.
  32. local sound = math.random( 1, 3 )
  33. local bgMusic = playSound ( panel.sounds[ sound ][ 1 ], true )
  34. if bgMusic then
  35. setSoundVolume( bgMusic, panel.sounds[ sound ][ 2 ] )
  36. end
  37. setElementData(localPlayer, "bgMusic", bgMusic , false)
  38.  
  39. -- prepare.
  40. showChat(false)
  41. showCursor(true)
  42. guiSetInputEnabled(true)
  43. local Width,Height = 350,350
  44. local X = (sw/2) - (Width/2)
  45. local Y = (sh/2) - (Height/2)
  46. ufont = ufont or guiCreateFont( ':interior_system/intNameFont.ttf', 11 )
  47.  
  48. panel.login.main = guiCreateStaticImage( X, Y, 350, 350, "/login-panel/login_window.png", false )
  49. guiSetEnabled (panel.login.main, false)
  50.  
  51. --panel.login.logo = guiCreateStaticImage( (sw-logoSize[1])/2, logoSize[2]/2, logoSize[1], logoSize[2], "/login-panel/OwlLogo7.png", false )
  52. panel.login.logo = guiCreateStaticImage( (sw-logoSize[1])/2, (sh-logoSize[2])/2 , logoSize[1], logoSize[2], "/login-panel/OwlLogo7.png", false )
  53. local x, y = guiGetPosition( panel.login.logo, false )
  54. --guiSetPosition( panel.login.logo, x, -logoSize[2], false )
  55.  
  56.  
  57. --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  58. panel.login.login = guiCreateStaticImage( X + 23, Y + 349-120, 301, 44, "/login-panel/login.png", false )
  59. addEventHandler("onClientGUIClick",panel.login.login,onClickBtnLogin, false )
  60. addEventHandler( "onClientMouseEnter",panel.login.login,LoginSH)
  61. addEventHandler("onClientMouseLeave",panel.login.login,SErem)
  62.  
  63. panel.login.username = guiCreateEdit(X + 20,Y + 220-120,310,35,"",false)
  64. panel.login.password = guiCreateEdit(X + 20,Y + 295-120,310,35,"",false)
  65. guiSetFont( panel.login.username, ufont )
  66. guiSetFont( panel.login.password, ufont )
  67. guiEditSetMaxLength ( panel.login.username,25)
  68. guiEditSetMasked ( panel.login.password, true )
  69. guiSetProperty( panel.login.password, 'MaskCodepoint', '8226' )
  70.  
  71. addEventHandler("onClientGUIChanged", panel.login.username, resetLogButtons)
  72. addEventHandler("onClientGUIChanged", panel.login.password, resetLogButtons)
  73. addEventHandler( "onClientGUIAccepted", panel.login.username, startLoggingIn)
  74. addEventHandler( "onClientGUIAccepted", panel.login.password, startLoggingIn)
  75. --[[
  76. lbl_about_legth = guiCreateLabel(142,42,184,18,"",false)
  77. guiLabelSetColor(lbl_about_legth,253,255,68)
  78. guiLabelSetVerticalAlign(lbl_about_legth,"center")
  79. guiLabelSetHorizontalAlign(lbl_about_legth,"center",false)
  80. ]]
  81. panel.login.remember = guiCreateCheckBox(X + 230,Y + 275-120,100,20,"(Remember me!)",false,false)
  82. guiSetFont(panel.login.remember,"default-small")
  83.  
  84. panel.login.error = guiCreateLabel(X,Y + 325-120,364,31,"Error_login_tab",false)
  85. guiLabelSetColor(panel.login.error,255,0,0)
  86. guiLabelSetVerticalAlign(panel.login.error,"center")
  87. guiLabelSetHorizontalAlign(panel.login.error,"center",false)
  88. guiSetFont(panel.login.error,"default-bold-small")
  89.  
  90. panel.login.authen = guiCreateLabel(X,Y + 325-120,364,31,"Authen_login_tab",false)
  91. guiLabelSetColor(panel.login.authen,0,255,0)
  92. guiLabelSetVerticalAlign(panel.login.authen,"center")
  93. guiLabelSetHorizontalAlign(panel.login.authen,"center",false)
  94. guiSetFont(panel.login.authen,"default-bold-small")
  95.  
  96.  
  97. --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  98. panel.login.register = guiCreateStaticImage( X + 23, Y + 401-120, 301, 44, "/login-panel/signup.png", false ) -- A gomb
  99. addEventHandler("onClientGUIClick",panel.login.register,OnBtnRegister, false )
  100. addEventHandler( "onClientMouseEnter",panel.login.register,SignupSH)
  101. addEventHandler("onClientMouseLeave",panel.login.register,SErem)
  102.  
  103. panel.login.toplabel = guiCreateLabel(X - 70,Y + 388+70-120,500,30,"",false)
  104. guiLabelSetColor(panel.login.toplabel,255,234,55)
  105. guiLabelSetVerticalAlign(panel.login.toplabel,"center")
  106. guiLabelSetHorizontalAlign(panel.login.toplabel,"center",false)
  107. guiSetFont(panel.login.toplabel,"default-bold-small")
  108. guiSetVisible(panel.login.toplabel,false)
  109.  
  110. panel.login.username2 = guiCreateEdit(X + 20,Y + 215-120,310,35,"",false)
  111. guiEditSetMaxLength ( panel.login.username2,25)
  112. guiSetVisible(panel.login.username2,false)
  113. guiSetFont( panel.login.username2, ufont )
  114. addEventHandler("onClientGUIChanged", panel.login.username2, resetRegButtons)
  115.  
  116. panel.login.password2 = guiCreateEdit(X + 20,Y + 290-120,310,35,"",false)
  117. guiEditSetMaxLength ( panel.login.password2,25)
  118. guiEditSetMasked ( panel.login.password2, true )
  119. guiSetProperty(panel.login.password2, 'MaskCodepoint', '8226')
  120. guiSetVisible(panel.login.password2,false)
  121. guiSetFont( panel.login.password2, ufont )
  122. addEventHandler("onClientGUIChanged", panel.login.password2, resetRegButtons)
  123.  
  124. panel.login.repassword = guiCreateEdit(X + 20,Y + 365-120,310,35,"",false)
  125. guiEditSetMaxLength ( panel.login.repassword,25)
  126. guiEditSetMasked ( panel.login.repassword, true )
  127. guiSetProperty(panel.login.repassword, 'MaskCodepoint', '8226')
  128. guiSetVisible(panel.login.repassword,false)
  129. guiSetEnabled (panel.login.repassword, true)
  130. guiSetFont( panel.login.repassword, ufont )
  131. addEventHandler("onClientGUIChanged", panel.login.repassword, resetRegButtons)
  132.  
  133. panel.login.email = guiCreateEdit(X + 20,Y + 435-120,310,35,"",false)
  134. guiEditSetMaxLength ( panel.login.email,100)
  135. --guiEditSetMasked ( panel.login.email, true )
  136. guiSetVisible(panel.login.email,false)
  137. guiSetFont( panel.login.email, ufont )
  138. guiSetEnabled (panel.login.email, true)
  139. addEventHandler("onClientGUIChanged", panel.login.email, resetRegButtons)
  140.  
  141. --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  142. panel.login.register2 = guiCreateStaticImage( X + 182, Y + 401+6+70-120, 143, 45, "/login-panel/register.png", false )--guiCreateStaticImage( X + 23, Y + 409, 301, 44, "/login-panel/register2.png", false )
  143. addEventHandler("onClientGUIClick",panel.login.register2,onClickBtnRegister, false )
  144. addEventHandler( "onClientMouseEnter",panel.login.register2,Register2SH)
  145. addEventHandler("onClientMouseLeave",panel.login.register2,SErem)
  146. guiSetVisible(panel.login.register2,false)
  147.  
  148. panel.login.cancel = guiCreateStaticImage( X + 23, Y + 401+6+70-120, 143, 45, "/login-panel/cancel.png", false ) -- A gomb
  149. addEventHandler("onClientGUIClick",panel.login.cancel,onClickCancel, false )
  150. addEventHandler( "onClientMouseEnter",panel.login.cancel,CancelSH)
  151. addEventHandler("onClientMouseLeave",panel.login.cancel,SErem)
  152. guiSetVisible(panel.login.cancel,false)
  153.  
  154. showCursor(true)
  155.  
  156. guiSetText(panel.login.error, "")
  157. guiSetText(panel.login.authen, "")
  158.  
  159. local username, password = loadLoginFromXML()
  160. if username ~= "" then
  161. guiCheckBoxSetSelected ( panel.login.remember, true )
  162. guiSetText ( panel.login.username, tostring(username))
  163. guiSetText ( panel.login.password, tostring(password))
  164. else
  165. guiCheckBoxSetSelected ( panel.login.remember, false )
  166. guiSetText ( panel.login.username, tostring(username))
  167. guiSetText ( panel.login.password, tostring(password))
  168. end
  169.  
  170. guisSetEnabled( 'login', false )
  171. guisSetPosition( 'login', (sw+Width)/2 )
  172.  
  173. -- fade the login tab in.
  174. setTimer( fade.login, 8000, 1 , (sw+Width)/2 )
  175.  
  176. -- dynamic screen effect.
  177. addEventHandler( 'onClientRender', root, slideScreen )
  178.  
  179. -- make sure screen isn't black.
  180. fadeCamera ( true )
  181. end
  182. end
  183.  
  184. function guisSetEnabled( part, state )
  185. for index, gui in pairs( panel[ part ] ) do
  186. if index ~= 'main' then
  187. guiSetEnabled( gui , state )
  188. end
  189. end
  190. end
  191.  
  192. function guisSetPosition( part, x_, y_ )
  193. for index, gui in pairs( panel[ part ] ) do
  194. if index ~= 'logo' then
  195. local x, y = guiGetPosition( gui, false )
  196. if x_ then
  197. x = x + x_
  198. end
  199. if y_ then
  200. y = y + y_
  201. end
  202. guiSetPosition( gui, x, y, false )
  203. end
  204. end
  205. end
  206.  
  207. function fade.render( )
  208. fade.cur = fade.cur + fade.dir
  209. fade.logo_start = fade.logo_start + fade.logo_dir
  210. if math.abs(fade.cur) <= fade.max then
  211. guisSetPosition( 'login', fade.dir )
  212. guiSetPosition( panel.login.logo, fade.logo_x, fade.logo_start, false )
  213. else
  214. guisSetEnabled( 'login', true )
  215. removeEventHandler( 'onClientRender', root, fade.render )
  216. end
  217. end
  218.  
  219. function fade.login( max )
  220. fade.cur = 0
  221. fade.max = max
  222. fade.dir = -fade.max/50
  223. fade.logo_start = (sh-logoSize[2])/2
  224. fade.logo_end = sh - logoSize[2]*3/2
  225. fade.logo_dir = -(fade.logo_end-fade.logo_start)/50
  226. fade.logo_x = (sw-logoSize[1])/2
  227. addEventHandler( 'onClientRender', root, fade.render )
  228. end
  229.  
  230. local speed = 0.01
  231. local moved = 0
  232.  
  233. function slideScreen()
  234. local matrix = { getCameraMatrix ( localPlayer ) }
  235. matrix[1] = matrix[1] + speed
  236. moved = moved + speed
  237. if moved > 50 then
  238. local scr = shuffleScreen()
  239. moved = 0
  240. setCameraMatrix ( scr[1], scr[2], scr[3], scr[4], scr[5], scr[6], 0, exports.global:getPlayerFov())
  241. else
  242. setCameraMatrix ( unpack(matrix) )
  243. end
  244. end
  245.  
  246. function LoginSH ()
  247. guiStaticImageLoadImage(panel.login.login, "/login-panel/sh.png" )
  248. end
  249.  
  250. function SignupSH ()
  251. guiStaticImageLoadImage(panel.login.register, "/login-panel/signup2.png" )
  252. end
  253.  
  254. function Register2SH ()
  255. guiStaticImageLoadImage(panel.login.register, "/login-panel/shr.png" )
  256. end
  257.  
  258. function CancelSH ()
  259. guiStaticImageLoadImage(panel.login.cancel, "/login-panel/cancel2.png" )
  260. end
  261.  
  262. function SErem ()
  263. guiStaticImageLoadImage(panel.login.login, "/login-panel/login.png" )
  264. guiStaticImageLoadImage(panel.login.register, "/login-panel/signup.png" )
  265. guiStaticImageLoadImage(panel.login.register2, "/login-panel/register.png" )
  266. guiStaticImageLoadImage(panel.login.cancel, "/login-panel/cancel.png" )
  267. end
  268.  
  269. --[[
  270. function start_cl_resource()
  271. open_log_reg_pannel()
  272. end
  273. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),start_cl_resource)
  274. ]]
  275.  
  276. function loadLoginFromXML()
  277. local xml_save_log_File = xmlLoadFile ("@rememberme.xml")
  278. if not xml_save_log_File then
  279. xml_save_log_File = xmlCreateFile("@rememberme.xml", "login")
  280. end
  281. local usernameNode = xmlFindChild (xml_save_log_File, "username", 0)
  282. local passwordNode = xmlFindChild (xml_save_log_File, "password", 0)
  283. local username, password = usernameNode and exports.global:decryptString(xmlNodeGetValue(usernameNode), localPlayer) or "", passwordNode and exports.global:decryptString(xmlNodeGetValue(passwordNode), localPlayer) or ""
  284. xmlUnloadFile ( xml_save_log_File )
  285. return username, password
  286. end
  287.  
  288. function saveLoginToXML(username, password)
  289. local xml_save_log_File = xmlLoadFile ("@rememberme.xml")
  290. if not xml_save_log_File then
  291. xml_save_log_File = xmlCreateFile("@rememberme.xml", "login")
  292. end
  293. if (username ~= "") then
  294. local usernameNode = xmlFindChild (xml_save_log_File, "username", 0)
  295. local passwordNode = xmlFindChild (xml_save_log_File, "password", 0)
  296. if not usernameNode then
  297. usernameNode = xmlCreateChild(xml_save_log_File, "username")
  298. end
  299. if not passwordNode then
  300. passwordNode = xmlCreateChild(xml_save_log_File, "password")
  301. end
  302. xmlNodeSetValue (usernameNode, exports.global:encryptString(username, localPlayer))
  303. xmlNodeSetValue (passwordNode, exports.global:encryptString(password, localPlayer))
  304. end
  305. xmlSaveFile(xml_save_log_File)
  306. xmlUnloadFile (xml_save_log_File)
  307. end
  308. addEvent("saveLoginToXML", true)
  309. addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML)
  310.  
  311.  
  312.  
  313. function resetSaveXML()
  314. local xml_save_log_File = xmlLoadFile ("@rememberme.xml")
  315. if xml_save_log_File then
  316. fileDelete ("@rememberme.xml")
  317. xmlUnloadFile ( xml_save_log_File )
  318. end
  319. end
  320. addEvent("resetSaveXML", true)
  321. addEventHandler("resetSaveXML", getRootElement(), resetSaveXML)
  322.  
  323. function onClickBtnLogin(button,state)
  324. if(button == "left" and state == "up") then
  325. if (source == panel.login.login) then
  326. startLoggingIn()
  327. end
  328. end
  329. end
  330.  
  331. local loginClickTimer = nil
  332. function startLoggingIn()
  333. if not getElementData(localPlayer, "clickedLogin") then
  334. setElementData(localPlayer, "clickedLogin", true, false)
  335. if isTimer(loginClickTimer) then
  336. killTimer(loginClickTimer)
  337. end
  338. loginClickTimer = setTimer(setElementData, 1000, 1, localPlayer, "clickedLogin", nil, false)
  339.  
  340. username = guiGetText(panel.login.username)
  341. password = guiGetText(panel.login.password)
  342. if guiCheckBoxGetSelected ( panel.login.remember ) == true then
  343. checksave = true
  344. else
  345. checksave = false
  346. end
  347. playSoundFrontEnd ( 6 )
  348. guiSetEnabled(panel.login.login, false)
  349. guiSetAlpha(panel.login.login, 0.3)
  350. triggerServerEvent("accounts:login:attempt", getLocalPlayer(), username, password, checksave)
  351. authen_msg("Login", "Sending request to server..")
  352. else
  353. Error_msg("Login", "Slow down..")
  354. end
  355. end
  356.  
  357. function hideLoginPanel(keepBG)
  358. showCursor(true)
  359. if keepBG then
  360. for name, gui in pairs( panel.login ) do
  361. if name ~= 'logo' then
  362. guiSetVisible( gui, false)
  363. end
  364. end
  365. else
  366. for name, gui in pairs( panel.login ) do
  367. if gui and isElement( gui ) then
  368. destroyElement( gui )
  369. gui = nil
  370. end
  371. end
  372. triggerEvent( 'hud:blur', resourceRoot, 'off', true )
  373. removeEventHandler( 'onClientRender', root, slideScreen )
  374. end
  375. end
  376. addEvent("hideLoginPanel", true)
  377. addEventHandler("hideLoginPanel", getRootElement(), hideLoginPanel)
  378.  
  379.  
  380. function OnBtnRegister ()
  381. switchToRegisterPanel() -- Disabled registration
  382. playSoundFrontEnd ( 2 )
  383. --guiSetText(panel.login.error, "Please register on Owlgaming.net/register.php")
  384. end
  385.  
  386. function onClickCancel()
  387. switchToLoginPanel()
  388. playSoundFrontEnd ( 2 )
  389. end
  390.  
  391. function switchToLoginPanel()
  392. guiSetText(panel.login.error, "")
  393. guiSetText(panel.login.authen, "")
  394. guiSetText(panel.login.toplabel, "")
  395.  
  396. guiSetSize(panel.login.main, 350,350, false)
  397. guiStaticImageLoadImage(panel.login.main, "login-panel/Login_window.png" )
  398. guiSetVisible(panel.login.register2, false)
  399. guiSetVisible(panel.login.cancel,false)
  400. guiSetVisible(panel.login.toplabel,false)
  401. guiSetVisible(panel.login.repassword,false)
  402. guiSetEnabled (panel.login.repassword, false)
  403. guiSetVisible(panel.login.email,false)
  404. guiSetEnabled (panel.login.email, false)
  405. guiSetVisible(panel.login.password2,false)
  406. guiSetVisible(panel.login.username2,false)
  407. guiSetVisible(panel.login.register, true)
  408. guiSetVisible(panel.login.login, true)
  409. guiSetVisible(panel.login.password, true)
  410. guiSetVisible(panel.login.username, true)
  411. guiSetVisible(panel.login.remember, true)
  412. showCursor(true)
  413. end
  414.  
  415. function switchToRegisterPanel()
  416. guiSetText(panel.login.error, "")
  417. guiSetText(panel.login.authen, "")
  418. guiSetText(panel.login.toplabel, "")
  419.  
  420. guiSetSize(panel.login.main, 350,421, false)
  421. guiStaticImageLoadImage(panel.login.main, "login-panel/register_window.png" )
  422. guiSetVisible(panel.login.register2, true)
  423. guiSetVisible(panel.login.cancel,true)
  424. guiSetVisible(panel.login.toplabel,true)
  425. guiSetVisible(panel.login.repassword,true)
  426. guiSetEnabled (panel.login.repassword, true)
  427. guiSetVisible(panel.login.password2,true)
  428. guiSetVisible(panel.login.username2,true)
  429. guiSetVisible(panel.login.email,true)
  430. guiSetEnabled (panel.login.email, true)
  431. guiSetVisible(panel.login.register, false)
  432. guiSetVisible(panel.login.login, false)
  433. guiSetVisible(panel.login.password, false)
  434. guiSetVisible(panel.login.username, false)
  435. guiSetVisible(panel.login.remember, false)
  436. showCursor(true)
  437. setElementData(localPlayer, "switched", true, false)
  438. end
  439.  
  440. function onClickBtnRegister(button,state)
  441. username = guiGetText(panel.login.username2)
  442. password = guiGetText(panel.login.password2)
  443. passwordConfirm = guiGetText(panel.login.repassword)
  444. email = guiGetText(panel.login.email)
  445. registerValidation(username, password, passwordConfirm,email)
  446.  
  447. --playSoundFrontEnd ( 6 )
  448. guiSetEnabled(panel.login.register, false)
  449. guiSetAlpha(panel.login.register, 0.3)
  450. end
  451.  
  452. function registerValidation(username, password, passwordConfirm, email)
  453. if not username or username == "" or not password or password == "" or not passwordConfirm or passwordConfirm == "" or not email or email == "" then
  454. guiSetText(panel.login.toplabel, "Please fill out all fields.")
  455. guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
  456. playSoundFrontEnd ( 4 )
  457. elseif string.len(username) < 3 then
  458. guiSetText(panel.login.toplabel, "Username must be 3 characters or longer.")
  459. guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
  460. playSoundFrontEnd ( 4 )
  461. elseif string.len(username) >= 19 then
  462. guiSetText(panel.login.toplabel, "Username must be less then 20 characters long.")
  463. guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
  464. playSoundFrontEnd ( 4 )
  465. elseif string.find(username, ' ') then
  466. guiSetText(panel.login.toplabel, "Invalid Username.")
  467. guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
  468. playSoundFrontEnd ( 4 )
  469. elseif string.find(password, "'") or string.find(password, '"') then
  470. guiSetText(panel.login.toplabel, "Password must not contain ' or "..'"')
  471. guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
  472. playSoundFrontEnd ( 4 )
  473. elseif string.len(password) < 8 then
  474. guiSetText(panel.login.toplabel, "Password must be 8 characters or longer.")
  475. guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
  476. playSoundFrontEnd ( 4 )
  477. elseif string.len(password) > 25 then
  478. guiSetText(panel.login.toplabel, "Password must be less than 25 characters long.")
  479. guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
  480. playSoundFrontEnd ( 4 )
  481. elseif password ~= passwordConfirm then
  482. guiSetText(panel.login.toplabel, "Passwords mismatched!")
  483. guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
  484. playSoundFrontEnd ( 4 )
  485. elseif string.match(username,"%W") then
  486. guiSetText(panel.login.toplabel, "\"!@#$\"%'^&*()\" are not allowed in username.")
  487. guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
  488. playSoundFrontEnd ( 4 )
  489. else
  490. local validEmail, reason = exports.global:isEmail(email)
  491. if not validEmail then
  492. guiSetText(panel.login.toplabel, reason)
  493. guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
  494. playSoundFrontEnd ( 4 )
  495. else
  496. triggerServerEvent("accounts:register:attempt",getLocalPlayer(),username,password,passwordConfirm, email)
  497. authen_msg("Register", "Sending request to server.")
  498. end
  499. end
  500. end
  501.  
  502. function registerComplete(username, pw, email)
  503. guiSetText(panel.login.username, username)
  504. guiSetText(panel.login.password, pw)
  505. playSoundFrontEnd(13)
  506. displayRegisterConpleteText(username, email)
  507. end
  508. addEvent("accounts:register:complete",true)
  509. addEventHandler("accounts:register:complete",getRootElement(),registerComplete)
  510.  
  511. function displayRegisterConpleteText(username)
  512. local GUIEditor = {
  513. button = {},
  514. window = {},
  515. label = {}
  516. }
  517.  
  518. local extend = 100
  519. local yoffset = 150
  520.  
  521. GUIEditor.window[1] = guiCreateWindow(667, 381, 357, 189+extend, "Congratulations! Account has been successfully created!", false)
  522. exports.global:centerWindow(GUIEditor.window[1])
  523. --local x, y = guiGetPosition(GUIEditor.window[1], false)
  524. --guiSetPosition(GUIEditor.window[1], x, y+yoffset, false)
  525. guiSetAlpha(GUIEditor.window[1], 1)
  526. guiWindowSetMovable(GUIEditor.window[1], false)
  527. guiWindowSetSizable(GUIEditor.window[1], false)
  528. guiSetProperty(GUIEditor.window[1], "AlwaysOnTop", "True")
  529. local temp = "An email contains instructions to activate your account has been dispatched, please check your email's inbox.\n\nIf for some reasons you don't receive the email, please check your junk box or try to dispatch another activation email at https://owlgaming.net/account/"
  530. GUIEditor.label[1] = guiCreateLabel(8, 50, 339, 121+extend, "Your OwlGaming MTA account for '"..username.."' is almost ready for action!\n\n"..temp.."\n\nSincerely, \nOwlGaming Community OwlGaming Development Team\"", false, GUIEditor.window[1])
  531. guiLabelSetHorizontalAlign(GUIEditor.label[1], "left", true)
  532.  
  533. GUIEditor.button[1] = guiCreateButton(10, 153+extend, 337, 26, "Copy Activation Link", false, GUIEditor.window[1])
  534. addEventHandler("onClientGUIClick", GUIEditor.button[1], function()
  535. if source == GUIEditor.button[1] then
  536. if isElement(GUIEditor.window[1]) then
  537. destroyElement(GUIEditor.window[1])
  538. GUIEditor = nil
  539. switchToLoginPanel()
  540. setClipboard("https://owlgaming.net/account/")
  541. end
  542. else
  543. cancelEvent()
  544. end
  545. end, false )
  546. end
  547.  
  548. function Error_msg(Tab, Text)
  549. showCursor(true)
  550. if Tab == "Login" then
  551. playSoundFrontEnd ( 4)
  552. guiSetVisible(panel.login.register, true)
  553. guiSetVisible(panel.login.login, true)
  554. guiSetVisible(panel.login.password, true)
  555. guiSetVisible(panel.login.username, true)
  556. guiSetVisible(panel.login.remember, true)
  557. guiSetVisible(panel.login.main, true)
  558.  
  559. guiSetText(panel.login.authen, "")
  560. guiSetText(panel.login.error, tostring(Text))
  561. --setTimer(function() guiSetText(panel.login.error, "") end,3000,1)
  562. else
  563. playSoundFrontEnd ( 4)
  564. guiSetText(panel.login.toplabel, tostring(Text))
  565. guiLabelSetColor ( panel.login.toplabel, 255, 0, 0 )
  566. end
  567. end
  568. addEvent("set_warning_text",true)
  569. addEventHandler("set_warning_text",getRootElement(),Error_msg)
  570.  
  571. function authen_msg(Tab, Text)
  572. showCursor(true)
  573. if Tab == "Login" then
  574. if panel.login.authen and isElement(panel.login.authen) and guiGetVisible(panel.login.authen) then
  575. --playSoundFrontEnd ( 12)
  576. guiSetVisible(panel.login.register, true)
  577. guiSetVisible(panel.login.login, true)
  578. guiSetVisible(panel.login.password, true)
  579. guiSetVisible(panel.login.username, true)
  580. guiSetVisible(panel.login.remember, true)
  581. guiSetVisible(panel.login.main, true)
  582.  
  583. guiSetText(panel.login.error, "")
  584. guiSetText(panel.login.authen, tostring(Text))
  585. --setTimer(function() guiSetText(panel.login.authen, "") end,3000,1)
  586. end
  587. else
  588. --playSoundFrontEnd ( 12 )
  589. guiSetText(panel.login.toplabel, tostring(Text))
  590. guiLabelSetColor ( panel.login.toplabel, 255, 255, 255 )
  591. end
  592. end
  593. addEvent("set_authen_text",true)
  594. addEventHandler("set_authen_text",getRootElement(),authen_msg)
  595.  
  596.  
  597. function hideLoginWindow()
  598. showCursor(false)
  599. hideLoginPanel()
  600. end
  601. addEvent("hideLoginWindow", true)
  602. addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)
  603.  
  604. function CursorError ()
  605. showCursor(false)
  606. end
  607. addCommandHandler("showc", CursorError)
  608.  
  609. function resetRegButtons ()
  610. guiSetEnabled(panel.login.register2, true)
  611. guiSetAlpha(panel.login.register2, 1)
  612. end
  613.  
  614. function resetLogButtons()
  615. guiSetEnabled(panel.login.login, true)
  616. guiSetAlpha(panel.login.login, 1)
  617. end
  618.  
  619.  
  620. local screenStandByCurrent = 0
  621. local screenStandByComplete = 2
  622. local screenStandByShowing = false
  623. function screenStandBy(action, value) -- Maxime / 2015.3.25
  624. if action == "add" then
  625. screenStandByCurrent = screenStandByCurrent + 1
  626. if screenStandByShowing then
  627. authen_msg("Login", "Loading prerequisite resources.."..screenStandBy("getPercentage").."%")
  628. end
  629. return screenStandByCurrent
  630. elseif action == "getCurrent" then
  631. return screenStandByCurrent
  632. elseif action == "getState" then
  633. return screenStandByShowing
  634. elseif action == "setState" then
  635. screenStandByShowing = value
  636. if screenStandByShowing then
  637. authen_msg("Login", "Loading prerequisite resources.."..screenStandBy("getPercentage").."%")
  638. end
  639. screenStandByCurrent = 0
  640. return true
  641. elseif action == "getPercentage" then
  642. local percentage = math.floor(screenStandByCurrent/screenStandByComplete*100)
  643. if screenStandByShowing then
  644. authen_msg("Login", "Loading prerequisite resources.."..percentage.."%")
  645. end
  646. return percentage
  647. end
  648. end
  649. addEvent("screenStandBy",true)
  650. addEventHandler("screenStandBy",root,screenStandBy)
  651.  
  652. addEventHandler ( "onClientElementDataChange", localPlayer,
  653. function ( dataName )
  654. if getElementType ( localPlayer ) == "player" and dataName == "loggedin" then
  655. showChat(getElementData(localPlayer, "loggedin") == 1)
  656. end
  657. end )
  658.  
  659. --
  660.  
  661. addEventHandler("onClientResourceStart", resourceRoot, function()
  662. -- migrate the public file :account/login-panel/rememberme.xml to private resource @account/rememberme.xml
  663. if fileExists("/login-panel/rememberme.xml") then
  664. if not fileExists("@rememberme.xml") then
  665. fileCopy("/login-panel/rememberme.xml", "@rememberme.xml")
  666. end
  667. fileDelete("/login-panel/rememberme.xml")
  668. end
  669. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement