PapitoEUS

Untitled

Aug 11th, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.25 KB | None | 0 0
  1. --[[
  2.     Author: michalMonster
  3.     Contact: Discord(michalMonster#3295)
  4. ]]
  5. if getElementData(localPlayer, 'player:pid') then return end;
  6. local auth = {}
  7.  
  8. local sw, sh = guiGetScreenSize()
  9. local zoom = 1920/sw
  10.  
  11. local editbox = exports['editbox']
  12. local auth_page = 1
  13. local auth_rules = 0
  14.  
  15. local auth_login, auth_pass
  16. local rot = 0
  17. local tick
  18.  
  19. local rules = [[
  20.     §1 Pierwsza zasada
  21.     §2 Druga zasada
  22.     §3 Trzecia zasada, która jest dłuższa od pierwszej i drugiej zasady
  23. ]]
  24.  
  25. auth.font = {
  26.     dxCreateFont('assets/fonts/light.ttf', 15, false, 'draft'),
  27.     dxCreateFont('assets/fonts/medium.ttf', 25, false, 'draft'),
  28.     dxCreateFont('assets/fonts/medium.ttf', 15, false, 'draft'),
  29.     dxCreateFont('assets/fonts/light.ttf', 30, false, 'draft'),
  30.     dxCreateFont('assets/fonts/medium.ttf', 30, false, 'draft')
  31. }
  32.  
  33. auth.textures = {
  34.     vinyl = dxCreateTexture('assets/img/vinyl.png', 'argb', false, 'clamp'),
  35.     button = dxCreateTexture('assets/img/button.png', 'argb', false, 'clamp'),
  36.     checkoff = dxCreateTexture('assets/img/checkbox_off.png', 'argb', false, 'clamp'),
  37.     checkon = dxCreateTexture('assets/img/checkbox_on.png', 'argb', false, 'clamp'),
  38.     map = dxCreateTexture('assets/img/map.png', 'argb', false, 'clamp'),
  39.     pin = dxCreateTexture('assets/img/pin.png', 'argb', false, 'clamp'),
  40. }
  41.  
  42. auth.render = function()
  43.     local meta = getSoundMetaTags(auth_music)
  44.     rot = rot + 1
  45.     wpl = anim(tick, 1039, 444, 2000, 'Linear')
  46.     bpl = anim(tick, 444, 920, 2000, 'Linear')
  47.     wpr = anim(tick, 444, 1039, 1500, 'Linear')
  48.     if auth_page == 1 then
  49.         editbox:createEditbox('L_Login', 512, 450, 342, 47, 'Login', auth_login or '')
  50.         editbox:createEditbox('L_Haslo', 512, 560, 342, 47, 'Hasło', auth_pass or '')
  51.         editbox:setEditboxMasked('L_Haslo', true)
  52.         dxDrawRectangle(0, 0, 1920, 1080, tocolor(28, 29, 50, 255), false)
  53.         dxDrawRectangle(444, 140, 476, 800, tocolor(255, 255, 255, 255), false)
  54.         dxDrawRectangle(920, 140, 595, 800, tocolor(34, 35, 66, 255), false)
  55.         dxDrawRectangle(512, 607, 342, 2, tocolor(34, 35, 66, 255), false)
  56.         dxDrawRectangle(512, 497, 342, 2, tocolor(34, 35, 66, 255), false)
  57.         dxDrawImage(512, 680, 340, 57, auth.textures['button'], 0, 0, 0, tocolor(255, 255, 255), false)
  58.         dxDrawImage(10, 964, 106, 106, auth.textures['vinyl'], rot, 0, 0, tocolor(255, 255, 255, 255), false)
  59.         dxDrawImage(512, 617, 30, 30, auth.textures['checkoff'], 0, 0, 0, tocolor(255, 255, 255, 255), false)
  60.         if auth_save and auth_save == 1 then
  61.             dxDrawImage(517, 622, 20, 20, auth.textures['checkon'], 0, 0, 0, tocolor(255, 255, 255, 255), false)
  62.         end
  63.         dxDrawText('ZALOGUJ', 509, 710, 854, 710, tocolor(255, 255, 255, 255), 1, auth.font[2], 'center', 'center', false, false, false, false, false)
  64.         dxDrawText('HASŁO', 512, 530, 855, 573, tocolor(34, 35, 66, 255), 1, auth.font[3], 'left', 'center', false, false, false, false, false)
  65.         dxDrawText('LOGIN', 512, 310, 855, 573, tocolor(34, 35, 66, 255), 1, auth.font[3], 'left', 'center', false, false, false, false, false)
  66.         dxDrawText('Nie posiadasz konta?', 507, 690, 862, 645, tocolor(34, 35, 66, 255), 1, auth.font[1], 'left', 'center', false, false, false, false, false)
  67.         dxDrawText('Zarejestruj się', 715, 690, 862, 645, tocolor(34, 35, 66, 255), 1, auth.font[3], 'left', 'center', false, false, false, false, false)
  68.         dxDrawText('Logo projektu',  445, 115, 920, 209, tocolor(34, 35, 66, 255), 1, auth.font[4], 'left', 'center', false, false, false, false, false)
  69.         dxDrawText('Witaj na NAZWA SERWERA', 854, 469, 1582, 1276, tocolor(255, 255, 255, 255), 1, auth.font[2], 'center', 'top', false, false, false, false, false)
  70.         dxDrawText('Zaloguj się, aby uzyskać dostęp do konta', 1011, 508, 1425, 532, tocolor(255, 255, 255, 255), 1, auth.font[1], 'center', 'center', false, false, false, false, false)
  71.         dxDrawText("Zapamiętaj dane", 544, 617, 887, 647, tocolor(34, 35, 66, 255), 1.00, auth.font[1], "left", "center", false, false, false, false, false)
  72.         dxDrawText(meta.artist.." - "..meta.title, 121, 991, 1910, 1070, tocolor(255, 255, 255, 255), 1.00, auth.font[4], "left", "center", false, false, false, false, false)
  73.         editbox:renderEditbox('L_Login')
  74.         editbox:renderEditbox('L_Haslo')
  75.     end
  76.     if auth_page == 2 then
  77.         editbox:createEditbox('R_Login', 1107, 332, 342, 47, 'Login')
  78.         editbox:createEditbox('R_Haslo', 1107, 442, 342, 47, 'Hasło')
  79.         editbox:createEditbox('R_Email', 1107, 552, 342, 47, 'Email')
  80.         editbox:setEditboxMasked('R_Haslo', true)
  81.         dxDrawRectangle(0, 0, 1920, 1080, tocolor(28, 29, 50, 255), false)
  82.         dxDrawRectangle(wpr, 140, 476, 800, tocolor(255, 255, 255, 255), false)
  83.         dxDrawRectangle(444, 140, 595, 800, tocolor(34, 35, 66, 255), false)
  84.         dxDrawRectangle(1107, 379, 342, 2, tocolor(34, 35, 66, 255), false)
  85.         dxDrawRectangle(1107, 489, 342, 2, tocolor(34, 35, 66, 255), false)
  86.         dxDrawRectangle(1107, 599, 342, 2, tocolor(34, 35, 66, 255), false)
  87.         dxDrawImage(1108, 646, 340, 57, auth.textures['button'], 0, 0, 0, tocolor(255, 255, 255), false)
  88.         dxDrawImage(10, 964, 106, 106, auth.textures['vinyl'], rot, 0, 0, tocolor(255, 255, 255, 255), false)
  89.         dxDrawImage(1107, 608, 30, 30, auth.textures['checkoff'], 0, 0, 0, tocolor(255, 255, 255, 255), false)
  90.         if auth_rules and auth_rules == 1 then
  91.             dxDrawImage(1112, 613, 20, 20, auth.textures['checkon'], 0, 0, 0, tocolor(255, 255, 255, 255), false)
  92.         end
  93.         dxDrawText('Logo projektu', 1040, 115, 920, 209, tocolor(34, 35, 66, 255), 1, auth.font[4], 'left', 'center', false, false, false, false, false)
  94.         dxDrawText('ZAREJESTRUJ', 1107, 650, 1447, 703, tocolor(255, 255, 255, 255), 1, auth.font[2], 'center', 'center', false, false, false, false, false)
  95.         dxDrawText('REGULAMIN', 444, 137, 1037, 202, tocolor(255, 255, 255, 255), 1, auth.font[5], 'center', 'center', false, false, false, false, false)
  96.         dxDrawText(rules, 442, 192, 1037, 940, tocolor(255, 255, 255, 255), 1, auth.font[1], "center", "top", false, true, false, false, false)
  97.         dxDrawText("Akceptuje regulamin", 1139, 608, 1457, 638, tocolor(34, 35, 66, 255), 1, auth.font[1], "left", "center", false, false, false, false, false)
  98.         dxDrawText('LOGIN', 1107, 75, 855, 573, tocolor(34, 35, 66, 255), 1, auth.font[3], 'left', 'center', false, false, false, false, false)
  99.         dxDrawText('HASŁO', 1107, 292, 855, 573, tocolor(34, 35, 66, 255), 1, auth.font[3], 'left', 'center', false, false, false, false, false)
  100.         dxDrawText('EMAIL', 1107, 513, 855, 573, tocolor(34, 35, 66, 255), 1, auth.font[3], 'left', 'center', false, false, false, false, false)
  101.         dxDrawText("Wróć do logowania", 1037, 903, 1514, 939, tocolor(34, 35, 66, 255), 1.00, auth.font[3], "center", "center", false, false, false, false, false)
  102.         dxDrawText(meta.artist.." - "..meta.title, 121, 991, 1910, 1070, tocolor(255, 255, 255, 255), 1.00, auth.font[4], "left", "center", false, false, false, false, false)
  103.         editbox:renderEditbox('R_Login')
  104.         editbox:renderEditbox('R_Haslo')
  105.         editbox:renderEditbox('R_Email')
  106.     end
  107.     if auth_page == 3 then
  108.         dxDrawRectangle(0, 0, 1920, 1080, tocolor(28, 29, 50, 255), false)
  109.         dxDrawImage(10, 964, 106, 106, auth.textures['vinyl'], rot, 0, 0, tocolor(255, 255, 255, 255), false)
  110.         dxDrawImage(884, 60, 977, 960, auth.textures['map'], 0, 0, 0, tocolor(255, 255, 255, 255), false)
  111.         dxDrawImage(215, 512, 340, 57, auth.textures['button'], 0, 0, 0, tocolor(255, 255, 255, 255), false)
  112.         dxDrawImage(215, 412, 340, 57, auth.textures['button'], 0, 0, 0, tocolor(255, 255, 255, 255), false)
  113.         dxDrawImage(215, 612, 340, 57, auth.textures['button'], 0, 0, 0, tocolor(255, 255, 255, 255), false)
  114.         if isMouseInPosition(215, 411, 341, 57) then
  115.             dxDrawImage(1516, 177, 28, 48, auth.textures['pin'], 0, 0, 0, tocolor(255, 255, 255, 255), false)
  116.         elseif isMouseInPosition(215, 511, 341, 57) then
  117.             dxDrawImage(1675, 792, 28, 48, auth.textures['pin'], 0, 0, 0, tocolor(255, 255, 255, 255), false)
  118.         elseif isMouseInPosition(215, 611, 341, 57) then
  119.             dxDrawImage(921, 490, 28, 48, auth.textures['pin'], 0, 0, 0, tocolor(255, 255, 255, 255), false)
  120.         end
  121.         dxDrawText("LAS VENTURAS", 213, 411, 556, 471, tocolor(255, 255, 255, 255), 1.00, auth.font[2], "center", "center", false, false, false, false, false)
  122.         dxDrawText("LOS SANTOS", 213, 510, 556, 570, tocolor(255, 255, 255, 255), 1.00, auth.font[2], "center", "center", false, false, false, false, false)
  123.         dxDrawText("SAN FIERRO", 213, 610, 556, 670, tocolor(255, 255, 255, 255), 1.00, auth.font[2], "center", "center", false, false, false, false, false)
  124.         dxDrawText(meta.artist.." - "..meta.title, 121, 991, 1910, 1070, tocolor(255, 255, 255, 255), 1.00, auth.font[4], "left", "center", false, false, false, false, false)
  125.     end
  126. end
  127.  
  128. auth.click = function(b, s)
  129.     if b == 'left' and s == 'down' then
  130.         if isMouseInPosition(712, 658, 155, 21) then
  131.             auth_page = 2
  132.             editbox:deleteEditbox('L_Login')
  133.             editbox:deleteEditbox('L_Haslo')
  134.         elseif isMouseInPosition(1175, 907, 206, 26) then
  135.             auth_page = 1
  136.             editbox:deleteEditbox('R_Login')
  137.             editbox:deleteEditbox('R_Haslo')
  138.             editbox:deleteEditbox('R_Email')
  139.         end
  140.         elseif isMouseInPosition(511, 679, 342, 60) and auth_page == 1 then
  141.             local login = editbox:getEditboxText('L_Login') or '';
  142.             local pass = editbox:getEditboxText('L_Haslo') or '';
  143.             if (#login < 3) then
  144.                 outputConsole('Login powinien zawierać przynajmniej 4 znaki.');
  145.             elseif (#pass < 7) then
  146.                 outputConsole('Niepoprawne hasło');
  147.             else
  148.                 triggerServerEvent('logging.loginPlayer', resourceRoot, login, pass);
  149.             end;
  150.         elseif isMouseInPosition(1108, 646, 340, 57) and auth_page == 2 then
  151.             local login = editbox:getEditboxText('R_Login') or '';
  152.             local pass = editbox:getEditboxText('R_Haslo') or '';
  153.             local email = editbox:getEditboxText('R_Email') or '';
  154.             if (#login < 4) then
  155.                 outputConsole('Login powinien zawierać przynajmniej 4 znaki.');
  156.             elseif (#pass < 7) then
  157.                 outputConsole('Ze względów bezpieczeństwa hasło powinno zawierać minimum 7 znaków.');
  158.             elseif (#email < 5) then
  159.                 outputConsole('Adres e-mail powinien zawierać przynajmniej 5 znaków');
  160.             elseif(not isValidMail(email))then
  161.                 outputConsole('Adres e-mail jest nieprawidłowy.');
  162.             elseif auth_rules == 0 then
  163.                 outputConsole('Aby dokonać rejestracji musisz zaakceptować regulamin');
  164.             else
  165.                 triggerServerEvent('logging.registerPlayer', resourceRoot, login, pass, email);
  166.                 outputConsole('Pomyślnie utworzono konto.');
  167.             end;
  168.     elseif isMouseInPosition(1107, 608, 30, 30) and auth_page == 2 then
  169.         auth_rules = auth_rules or 0
  170.         if auth_rules and auth_rules == 0 then
  171.             auth_rules = 1
  172.         else
  173.             auth_rules = 0
  174.         end
  175.     elseif isMouseInPosition(512, 617, 30, 30) and auth_page == 1 then
  176.         auth_save = auth_save or 0
  177.         if auth_save and auth_save == 0 then
  178.             auth_save = 1
  179.  
  180.             local xml = xmlCreateFile('account.xml', 'auth')
  181.             local login = editbox:getEditboxText('L_Login', tostring(login)) or ''
  182.             local pass = editbox:getEditboxText('L_Haslo', tostring(pass)) or ''
  183.             if not xml then return end
  184.  
  185.             xmlNodeSetValue(xmlCreateChild(xml, 'login'), login)
  186.             xmlNodeSetValue(xmlCreateChild(xml, 'passwd'), pass)
  187.             xmlSaveFile(xml)
  188.         else
  189.             auth_save = 0
  190.         end
  191.     elseif isMouseInPosition(215, 411, 341, 57) and auth_page == 3 then
  192.         setElementData(localPlayer, 'player:spawn', {-1971.24854, 479.79395, 35.17188})
  193.         triggerServerEvent('core:spawnPlayer', localPlayer, localPlayer)
  194.         auth.end_login()
  195.     elseif isMouseInPosition(215, 511, 341, 57) and auth_page == 3 then
  196.         auth.end_login()
  197.         setElementData(localPlayer, 'player:spawn', {947.36078, 1733.41956, 8.85156})
  198.         triggerServerEvent('core:spawnPlayer', localPlayer, localPlayer)
  199.     elseif isMouseInPosition(215, 611, 341, 57) and auth_page == 3 then
  200.         auth.end_login()
  201.         setElementData(localPlayer, 'player:spawn', {1, 2, 3})
  202.         triggerServerEvent('core:spawnPlayer', localPlayer, localPlayer)
  203.     end
  204. end
  205.  
  206. auth.loadAccounts = function()
  207.     local xml = xmlLoadFile('account.xml')
  208.     if not xml then return end
  209.     login = xmlNodeGetValue(xmlFindChild(xml, 'login', 0))
  210.     editbox:setEditboxText('L_Login', tostring(login))
  211.     pass = xmlNodeGetValue(xmlFindChild(xml, 'passwd', 0))
  212.     editbox:setEditboxText('L_Haslo', tostring(pass))
  213.     auth_save = 1
  214.     auth_login, auth_pass = login, pass
  215. end;
  216.  
  217. auth.toggle = function(b)
  218.     if b then
  219.         auth.loadAccounts()
  220.         tick = getTickCount();
  221.         showChat(false)
  222.         showCursor(true)
  223.         auth_music = playSound('assets/music/'..math.random(1,3)..'.mp3',true);
  224.         setSoundVolume(auth_music, 1)
  225.         addEventHandler('onClientRender', root, auth.render)
  226.         addEventHandler('onClientClick', root, auth.click)
  227.     else
  228.         tick = nil;
  229.         destroyElement(auth.textures['vinyl']); destroyElement(auth.textures['button']); destroyElement(auth.textures['checkon']); destroyElement(auth.textures['checkoff']); destroyElement(auth.textures['map']); destroyElement(auth.textures['pin']);
  230.         stopSound(auth_music)
  231.         showChat(true)
  232.         showCursor(false)
  233.  
  234.         removeEventHandler('onClientRender', root, auth.render)
  235.         removeEventHandler('onClientClick', root, auth.click)
  236.     end
  237. end;
  238.  
  239. auth.end_login = function(b)
  240.     if b then
  241.         auth_page = 3
  242.     else
  243.         auth.toggle()
  244.     end
  245. end;
  246.  
  247. auth.toggle(true)
  248.  
  249. addEvent('LOGIN', true)
  250. addEventHandler('LOGIN', resourceRoot, function(...)
  251. end);
Advertisement
Add Comment
Please, Sign In to add comment