Advertisement
Guest User

Untitled

a guest
Mar 5th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 28.66 KB | None | 0 0
  1. if(getElementData(localPlayer, "player:logged"))then return end;
  2.  
  3. local editbox = exports["fx-editbox"];
  4. local scroll = exports["fx-scroll"];
  5. local noti = exports["fx-notifications"];
  6. local buttons = exports["fx-buttons"];
  7.  
  8. local sw,sh = guiGetScreenSize();
  9. local zoom = 1;
  10. if sw < 1920 then
  11.     zoom = math.min(2, 1920 / sw);
  12. end;
  13.  
  14. local class = {};
  15. local self = {};
  16. setmetatable(self, {__index=class});
  17.  
  18.  
  19.  
  20. local anims, builtins = {}, {"Linear", "InQuad", "OutQuad", "InOutQuad", "OutInQuad", "InElastic", "OutElastic", "InOutElastic", "OutInElastic", "InBack", "OutBack", "InOutBack", "OutInBack", "InBounce", "OutBounce", "InOutBounce", "OutInBounce", "SineCurve", "CosineCurve"}
  21.  
  22. function table.find(t, v)
  23.     for k, a in ipairs(t) do
  24.         if a == v then
  25.             return k
  26.         end
  27.     end
  28.     return false
  29. end
  30.  
  31. function animate(f, t, easing, duration, onChange, onEnd)
  32.     assert(type(f) == "number", "Bad argument @ 'animate' [expected number at argument 1, got "..type(f).."]")
  33.     assert(type(t) == "number", "Bad argument @ 'animate' [expected number at argument 2, got "..type(t).."]")
  34.     assert(type(easing) == "string" or (type(easing) == "number" and (easing >= 1 or easing <= #builtins)), "Bad argument @ 'animate' [Invalid easing at argument 3]")
  35.     assert(type(duration) == "number", "Bad argument @ 'animate' [expected function at argument 4, got "..type(duration).."]")
  36.     assert(type(onChange) == "function", "Bad argument @ 'animate' [expected function at argument 5, got "..type(onChange).."]")
  37.     table.insert(anims, {from = f, to = t, easing = table.find(builtins, easing) and easing or builtins[easing], duration = duration, start = getTickCount( ), onChange = onChange, onEnd = onEnd})
  38.     return #anims
  39. end
  40.  
  41. function destroyAnimation(a)
  42.     if anims[a] then
  43.         table.remove(anims, a)
  44.     end
  45. end
  46.  
  47. addEventHandler("onClientRender", root, function( )
  48.     local now = getTickCount( )
  49.     for k,v in ipairs(anims) do
  50.         v.onChange(interpolateBetween(v.from, 0, 0, v.to, 0, 0, (now - v.start) / v.duration, v.easing))
  51.         if now >= v.start+v.duration then
  52.             if type(v.onEnd) == "function" then
  53.                 v.onEnd( )
  54.             end
  55.             table.remove(anims, k)
  56.         end
  57.     end
  58. end)
  59.  
  60.  
  61.  
  62. function isMouseInPosition ( x, y, width, height )
  63.     if ( not isCursorShowing( ) ) then
  64.         return false
  65.     end
  66.     local sx, sy = guiGetScreenSize ( )
  67.     local cx, cy = getCursorPosition ( )
  68.     local cx, cy = ( cx * sx ), ( cy * sy )
  69.     if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
  70.         return true
  71.     else
  72.         return false
  73.     end
  74. end
  75.  
  76. function transformText(text, max)
  77.     local x_tbl = {};
  78.     local x_new = "";
  79.  
  80.     for i,v in pairs(split(text, "\n")) do
  81.         if(#v > max)then
  82.             local x = 0;
  83.             local x2 = -max+1;
  84.             for i = 1,#v/max do
  85.                 x = x+max;
  86.                 x2 = x2+max;
  87.                 table.insert(x_tbl, string.sub(v, x2, x));
  88.             end;
  89.         end;
  90.     end;
  91.  
  92.     return x_tbl;
  93. end;
  94.  
  95. local cameras = {
  96.   {2035.0190429688,1343.0911865234,16.51189994812, 5000, 7500, 5}, -- spawn
  97.   {2105.5305175781,2031.8415527344,21.251699447632, 1000, 3000, 5}, -- urzad
  98.   {2166.3271484375,1990.3846435547,16.479099273682, -8000, -5000, 5}, -- sklep
  99.   {1662.2607421875,2174.9599609375,14.306599617004, 1000, 1500, 2}, -- mechanik
  100. }
  101.  
  102. local tick = getTickCount();
  103. local camera = math.random(1,#cameras);
  104. local intro_step = (cameras[camera][4]+cameras[camera][5])/2;
  105. local timer = false;
  106. local start = true;
  107.  
  108. function setNewCamera()
  109.   while(true)do
  110.     local new = math.random(1,#cameras);
  111.     if(new ~= camera)then
  112.       camera = new;
  113.       last_camera = camera;
  114.       tick = getTickCount();
  115.       intro_step = (cameras[camera][4]+cameras[camera][5])/2;
  116.  
  117.       fadeCamera(true);
  118.       break;
  119.     end;
  120.   end;
  121. end;
  122.  
  123. class.load = function()
  124.     self.img = {
  125.         dxCreateTexture("img/aktualizacje.png", "argb", false, "clamp"),
  126.         dxCreateTexture("img/regulamin.png", "argb", false, "clamp"),
  127.         dxCreateTexture("img/rejestracja.png", "argb", false, "clamp"),
  128.         dxCreateTexture("img/logowanie.png", "argb", false, "clamp"),
  129.         dxCreateTexture("img/background.png", "argb", false, "clamp"),
  130.         dxCreateTexture("img/save.png", "argb", false, "clamp"),
  131.         dxCreateTexture("img/save_1.png", "argb", false, "clamp"),
  132.         dxCreateTexture("img/welcome.png", "argb", false, "clamp"),
  133.     };
  134.  
  135.     self.selected = 0;
  136.     self.save = 0;
  137.     self.login, self.password = "", "";
  138.     self.news = {};
  139.     self.newsNumber = 1;
  140.     self.update = 3;
  141.  
  142.     self.rules = [[
  143.         #1# Korzystanie z czatu tekstowego/głosowego:
  144.         &1.1 Obowiązkowe jest zachowanie kultury osobistej na kanałach głosowych oraz tekstowych - używaj ich zgodnie z przeznaczeniem.
  145.         &1.2 Zakazuje się publikowania danych osobowych, kontaktowych lub zdjęć bez zgody danej osoby.
  146.         &1.3 Podszywanie się pod administracje bądź danego użytkownika w celu zdobycia jakichkolwiek informacji, będzie surowo karane.
  147.         &1.4 Reklamowanie innych serwerów Discord związanych z jakąkolwiek tematyką, jest surowo zabronione.
  148.         &1.5 Zwracaj się z szacunkiem do innych użytkowników.
  149.         &1.6 Zabronione jest zamieszczanie treści/postów obrażających inne orientacje, narodowości, religie, rasy ludzkie itd.
  150.         &1.7 Zabrania się tworzenia wielokrotnych kont na serwerze Discord, tzw "Multikonta"
  151.         &1.8 Zakazuje się obrażania użytkowników w jakikolwiek sposób.
  152.         &1.9 Zabrania się nagrywania rozmów użytkowników bez ich zgody.
  153.  
  154.         #2# Avatar/Nick nie może:
  155.         &2.1 Zawierać treści +18, wulgarnych oraz nawołujących do agresji/przemocy.
  156.         &2.2 Zwierać żadnych treści prowokujący, niestosowny itd.
  157.         &2.3 Obrażać innych użytkowników, religie oraz narodowości.
  158.         &2.4 Być specjalnie taki sam/podobny do nicku/avataru innej osoby.
  159.  
  160.         #3# Kanały tekstowe:
  161.         &3.1 Zabrania się pisania durnych pytań na kanale 🌍pytania.
  162.         &3.2 Zabrania się nadmiernego spamowania - floodowania.
  163.         &3.3 Zabrania się pisania na np. 🎦multimedia o sprawach nie związanych z tematyką.
  164.  
  165.         #4# Informacje końcowe:
  166.         &4.1 Administracja ma zawsze rację i jej decyzję są niepodważalne.
  167.         &4.2 Każdy członek discorda jest zobowiązany do godnego reprezentowania mienia serwera.
  168.         &4.3 Administracja ma prawo do wyrzucenia z discorda bez podania powodu.
  169.         &4.4 Nieznajomość regulaminu nie zwalnia z przestrzegania go.
  170.         &4.5 Za nieprzestrzeganie regulaminu będą wyciągane konsekwencje.
  171.         &4.6 Regulamin w każdej chwili może ulec zmianie.
  172.     ]]
  173.  
  174.     self.rulesNumber = 1;
  175.     self.acceptRules = 0;
  176.  
  177.     font = dxCreateFont("font.ttf", 11)
  178.  
  179.     font1 = dxCreateFont("font1.ttf", 9)
  180.  
  181.     self.tick = getTickCount();
  182.  
  183.     self.off = false;
  184.  
  185.     data.misc = playSound("music/music.mp3", true);
  186.  
  187.     self.render_fnc = function() self.render() end;
  188.     self.click_fnc = function(...) self.click(...) end;
  189.     addEventHandler("onClientRender", root, self.render_fnc);
  190.     addEventHandler("onClientClick", root, self.click_fnc);
  191.     setElementFrozen(localPlayer, true);
  192.  
  193.     showCursor(true);
  194.     fadeCamera(true);
  195.     showChat(false)
  196.     showPlayerHudComponent("all", false);
  197.  
  198.     setPlayerHudComponentVisible("money", false);
  199.  
  200.  
  201.     if (self.selected == 4) then
  202.     editbox:dxCreateEdit("EDIT-LOGIN1", "", "Wprowadź swój login...", sw/2-400/2/zoom, sh/2-330/2/zoom, 400/zoom, 50/zoom, false, 3, 0);
  203.     editbox:dxCreateEdit("EDIT-HASH1", "", "Wprowadź swoje hasło...", sw/2-400/2/zoom, sh/2-180/2/zoom, 400/zoom, 50/zoom, true, 3, 0);
  204.     buttons:createButton("BUTTON-LOGIN1", "Zaloguj się", sw/2, sh/2, 200/zoom, 40/zoom, 5, 0);
  205. end
  206. end;
  207.  
  208. data={ showed=nil, misc=nil}
  209.  
  210. class.render = function()
  211.     setElementData(localPlayer, "loguje", true)
  212.     if(self.off and (getTickCount()-self.off) > 3500)then
  213.         editbox:dxDestroyEdit("EDIT-LOGIN1");
  214.         editbox:dxDestroyEdit("EDIT-HASH1");
  215.         editbox:dxDestroyEdit("EDIT-HASH2");
  216.         buttons:destroyButton("BUTTON-LOGIN1");
  217.         buttons:destroyButton("BUTTON-REGISTER1");
  218.         buttons:destroyButton("BUTTON-RULES1");
  219.         editbox:dxDestroyEdit("EDIT-MAIL1");
  220.    
  221.         for i,v in pairs(self.img) do
  222.             if(isElement(v))then
  223.                 destroyElement(v);
  224.             end;
  225.         end;
  226.    
  227.         if(isElement(self.music))then
  228.             destroyElement(self.music);
  229.         end;
  230.    
  231.         showCursor(false);
  232.    
  233.         setElementFrozen(localPlayer, false);
  234.    
  235.         removeEventHandler("onClientRender", root, self.render_fnc);
  236.         removeEventHandler("onClientClick", root, self.click_fnc);
  237.  
  238.         setPlayerHudComponentVisible("all", false)
  239.  
  240.  
  241.  
  242.         setPlayerHudComponentVisible("crosshair", true)
  243.  
  244.         noti:addNotification("Pomyślnie zalogowano.", "success");
  245.  
  246.         setElementData(localPlayer, "user:showHud", true);
  247.     end;
  248.  
  249.     dxDrawImage(0, 0, sw, sh, self.img[5], 0, 0, 0, tocolor(255, 255, 255, 255), false);
  250.  
  251.     local a,y1 = 0, 0;
  252.     if((getTickCount()-self.tick) > 2000)then
  253.         a,y1 = interpolateBetween(0, 40, 0, 255, 50, 0, (getTickCount()-self.tick-2000)/500, "Linear");
  254.     end;
  255.  
  256.     local a_200 = a > 200 and 200 or a
  257.  
  258.     editbox:dxSetEditAlpha("EDIT-LOGIN1", a);
  259.     editbox:dxSetEditAlpha("EDIT-HASH1", a);
  260.     buttons:setButtonAlpha("BUTTON-LOGIN1", a);
  261.     screenW, screenH = guiGetScreenSize()
  262.  
  263.     local anims, builtins = {}, {"Linear", "InQuad", "OutQuad", "InOutQuad", "OutInQuad", "InElastic", "OutElastic", "InOutElastic", "OutInElastic", "InBack", "OutBack", "InOutBack", "OutInBack", "InBounce", "OutBounce", "InOutBounce", "OutInBounce", "SineCurve", "CosineCurve"}
  264.  
  265. function table.find(t, v)
  266.     for k, a in ipairs(t) do
  267.         if a == v then
  268.             return k
  269.         end
  270.     end
  271.     return false
  272. end
  273.  
  274. function animate(f, t, easing, duration, onChange, onEnd)
  275.     assert(type(f) == "number", "Bad argument @ 'animate' [expected number at argument 1, got "..type(f).."]")
  276.     assert(type(t) == "number", "Bad argument @ 'animate' [expected number at argument 2, got "..type(t).."]")
  277.     assert(type(easing) == "string" or (type(easing) == "number" and (easing >= 1 or easing <= #builtins)), "Bad argument @ 'animate' [Invalid easing at argument 3]")
  278.     assert(type(duration) == "number", "Bad argument @ 'animate' [expected function at argument 4, got "..type(duration).."]")
  279.     assert(type(onChange) == "function", "Bad argument @ 'animate' [expected function at argument 5, got "..type(onChange).."]")
  280.     table.insert(anims, {from = f, to = t, easing = table.find(builtins, easing) and easing or builtins[easing], duration = duration, start = getTickCount( ), onChange = onChange, onEnd = onEnd})
  281.     return #anims
  282. end
  283.  
  284. function destroyAnimation(a)
  285.     if anims[a] then
  286.         table.remove(anims, a)
  287.     end
  288. end
  289.  
  290.     if((getTickCount()-self.tick) > 2000)then
  291.         for i,v in pairs(self.img) do
  292.             if(i <= 4)then
  293.                 local newZoom = zoom;
  294.                 if(sw > 1366)then
  295.                   newZoom = newZoom*1.4;
  296.                 end;
  297.                 animate(screenW * -0.1568, screenW * 0.2427, "Linear", 1000, function(value) kuktas = value end)
  298.  
  299.                 local sY = (450/newZoom)*(i-3);
  300.                 if (self.selected==0) then
  301.                 dxDrawImage(screenW * 0.0000, screenH * 0.0000, screenW * 1.0000, screenH * 1.0000, ":fx-login/img/background.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
  302.                 dxDrawImage(screenW * 0.3839, screenH * 0.0620, screenW * 0.2083, screenH * 0.3704, ":fx-login/img/400.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
  303.                 dxDrawImage(kuktas, screenH * 0.4417, screenW * 0.1708, screenH * 0.0713, ":fx-login/img/button_wyb0.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) -- logowanie
  304.                 dxDrawImage(screenW * 0.4083, screenH * 0.5213, screenW * 0.1708, screenH * 0.0713, ":fx-login/img/button_wyb0.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) -- lista zmian
  305.                 dxDrawImage(screenW * 0.5594, screenH * 0.4417, screenW * 0.1708, screenH * 0.0713, ":fx-login/img/button_wyb0.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) -- rejestracja
  306.                 dxDrawImage(screenW * 0.4042, screenH * 0.3611, screenW * 0.1708, screenH * 0.0713, ":fx-login/img/button_wyb0.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) -- regulamin
  307.                 dxDrawText("Logowanie", screenW * 0.2651, screenH * 0.4454, screenW * 0.3911, screenH * 0.5037, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
  308.                 dxDrawText("Rejestracja", screenW * 0.5802, screenH * 0.4454, screenW * 0.7063, screenH * 0.5037, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
  309.                 dxDrawText("Lista zmian", screenW * 0.4255, screenH * 0.3648, screenW * 0.5516, screenH * 0.4231, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
  310.                 dxDrawText("Regulamin", screenW * 0.4313, screenH * 0.5250, screenW * 0.5573, screenH * 0.5833, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
  311.             end
  312.              --   if(self.selected == i)then
  313.                   --  if(isMouseInPosition(50/zoom, sh/2-(270+sY)/2/zoom, 192/zoom, 128/zoom))then
  314.                  --  --     dxDrawImage(y1/zoom, sh/2-(270+sY)/2/zoom, 192/zoom, 128/zoom, v, 0, 0, 0, tocolor(0, 72, 170, a_200), false);
  315.                  --   else
  316.                      --   dxDrawImage(y1/zoom, sh/2-(270+sY)/2/zoom, 192/zoom, 128/zoom, v, 0, 0, 0, tocolor(0, 72, 170, a), false);
  317.                     --end;
  318.                 --else
  319.                  --   if(isMouseInPosition(50/zoom, sh/2-(270+sY)/2/zoom, 192/zoom, 128/zoom))then
  320.                       --  dxDrawImage(y1/zoom, sh/2-(270+sY)/2/zoom, 192/zoom, 128/zoom, v, 0, 0, 0, tocolor(222, 222, 222, a_200), false);
  321.                   --  else
  322.                        -- dxDrawImage(y1/zoom, sh/2-(270+sY)/2/zoom, 192/zoom, 128/zoom, v, 0, 0, 0, tocolor(222, 222, 222, a), false);
  323.                    -- end;
  324.                -- end;
  325.  
  326.                 if(i == 1)then
  327.                     dxDrawImage((y1+114)/zoom, sh/2-(290+sY)/2/zoom, 64/zoom, 64/zoom, "img/circle.png", 0, 0, 0, tocolor(255, 0, 32, 255), false);
  328.                     dxDrawText(self.update, (y1+130)/zoom+1, sh/2-(290+sY)/2/zoom+1, 32/zoom+(y1+130)/zoom+1, 64/zoom+sh/2-(290+sY)/2/zoom+1, tocolor(0, 0, 0, 255), 1, font1, "center", "center", false);
  329.                     dxDrawText(self.update, (y1+130)/zoom, sh/2-(290+sY)/2/zoom, 32/zoom+(y1+130)/zoom, 64/zoom+sh/2-(290+sY)/2/zoom, tocolor(200, 200, 200, 255), 1, font1, "center", "center", false);
  330.                 end;
  331.             end;
  332.         end;
  333.     end;
  334.  
  335.     local w,h = 304,126;
  336.     local Y = (sh/2)-((h/2)/zoom);
  337.     if((getTickCount()-self.tick) > 1500)then
  338.         Y = interpolateBetween((sh/2)-((h/2)/zoom), 0, 0, 20/zoom, 0, 0, (getTickCount()-self.tick-1500)/500, "Linear");
  339.     end
  340.  
  341.     dxDrawImage(sw/2-w/2/zoom, Y, w/zoom, h/zoom, self.img[8], 0, 0, 0, tocolor(255, 255, 255, 255), false);
  342.  
  343.     if(self.selected == 1)then
  344.         dxDrawText("Aktualizacje", 0+1, 0+1, sw+1, sh/1.75+1, tocolor(0, 0, 0, 255), 1, font, "center", "center", false);
  345.         dxDrawText("Aktualizacje", 0, 0, sw, sh/1.75, tocolor(255, 255, 255, 255), 1, font, "center", "center", false);
  346.  
  347.         self.newsNumber = math.floor(scroll:dxScrollGetPosition("NEWS-SCROLL1") + 1);
  348.  
  349.         local text = "";
  350.         for i,v in pairs(self.news) do
  351.             if((self.newsNumber + 16) >= i and self.newsNumber <= i)then
  352.                 if(#text > 0)then
  353.                     text = text.."\n"..v.nick.." ("..v.date..") - "..v.text;
  354.                 else
  355.                     text = v.nick.." ("..v.date..") - "..v.text;
  356.                 end;
  357.             end;
  358.         end;
  359.  
  360.         dxDrawText(text, 0+1, sh/2-175/zoom+1, sw+1, sh+1, tocolor(0, 0, 0, 255), 1, font, "center", "top", false);
  361.         dxDrawText(text, 0, sh/2-175/zoom, sw, sh, tocolor(235, 235, 235, 255), 1, font, "center", "top", false);
  362.         dxDrawText("11.02 - Wszczęto prace nad serwerem\n12.02 - Dodano panel logowania oraz panel pomocy, a w nim statystyki gracza\n13.02 - Dodano licznik, interakcje oraz notyfikacje", 500/zoom+1, sh/2-175/zoom+1, sw-500/zoom+1, sh+1, tocolor(0, 0, 0, 255), 1, font1, "center", "top", false, false);
  363.         dxDrawText("11.02 - Wszczęto prace nad serwerem\n12.02 - Dodano panel logowania oraz panel pomocy, a w nim statystyki gracza\n13.02 - Dodano licznik, interakcje oraz notyfikacje", 500/zoom, sh/2-175/zoom, sw-500/zoom, sh, tocolor(235, 235, 235, 255), 1, font1, "center", "top", false, false);
  364.    
  365.     elseif(self.selected == 2)then
  366.         dxDrawText("Regulamin", 0+1, 0+1, sw+1, sh/1.75+1, tocolor(0, 0, 0, 255), 1, font, "center", "center", false);
  367.         dxDrawText("Regulamin", 0, 0, sw, sh/1.75, tocolor(255, 255, 255, 255), 1, font, "center", "center", false);
  368.  
  369.         self.rulesNumber = math.floor(scroll:dxScrollGetPosition("RULES-SCROLL1") + 1);
  370.  
  371.         local text = "";
  372.         for i,v in pairs(split(self.rules, "\n")) do
  373.             if((self.rulesNumber + 16) >= i and self.rulesNumber <= i)then
  374.                 if(#text > 0)then
  375.                     text = text.."\n"..v;
  376.                 else
  377.                     text = v;
  378.                 end;
  379.             end;
  380.         end;
  381.  
  382.         dxDrawText(text, 500/zoom+1, sh/2-175/zoom+1, sw-500/zoom+1, sh+1, tocolor(0, 0, 0, 255), 1, font1, "center", "top", false, false);
  383.         dxDrawText(text, 500/zoom, sh/2-175/zoom, sw-500/zoom, sh, tocolor(235, 235, 235, 255), 1, font1, "center", "top", false, false);
  384.     elseif(self.selected == 3)then
  385.         dxDrawText("Rejestracja", 0+1, 0+1, sw+1, sh/1.75+1, tocolor(0, 0, 0, 255), 1, font, "center", "center", false);
  386.         dxDrawText("Rejestracja", 0, 0, sw, sh/1.75, tocolor(255, 255, 255, 255), 1, font, "center", "center", false);
  387.  
  388.         if(self.acceptRules == 1)then
  389.             dxDrawImage(sw/2-235/zoom/2, sh/2+270/2/zoom+5/zoom, 25/zoom, 25/zoom, self.img[7], 0, 0, 0, tocolor(255, 255, 255, a), false);
  390.         else
  391.             dxDrawImage(sw/2-235/zoom/2, sh/2+270/2/zoom+5/zoom, 25/zoom, 25/zoom, self.img[6], 0, 0, 0, tocolor(255, 255, 255, a), false);
  392.         end;
  393.  
  394.         dxDrawText("Zaakceptuj regulamin", 1, sh/2+270/2/zoom+1+7/zoom, sw+1, sh+1, tocolor(0, 0, 0, a), 1, font1, "center", "top", false, false, false, true);
  395.         dxDrawText("Zaakceptuj #0048aaregulamin", 0, sh/2+270/2/zoom+7/zoom, sw, sh, tocolor(200, 200, 200, a), 1, font1, "center", "top", false, false, false, true);
  396.     elseif(self.selected == 4)then
  397.         dxDrawText("Logowanie", 0+1, 0+1, sw+1, sh/1.75+1, tocolor(0, 0, 0, a), 1, font, "center", "center", false);
  398.         dxDrawText("Logowanie", 0, 0, sw, sh/1.75, tocolor(255, 255, 255, a), 1, font, "center", "center", false);
  399.  
  400.         if(self.save == 1)then
  401.             dxDrawImage(sw/2-194/zoom, sh/2+7/zoom, 25/zoom, 25/zoom, self.img[7], 0, 0, 0, tocolor(255, 255, 255, a), false);
  402.         else
  403.             dxDrawImage(sw/2-194/zoom, sh/2+7/zoom, 25/zoom, 25/zoom, self.img[6], 0, 0, 0, tocolor(255, 255, 255, a), false);
  404.         end;
  405.  
  406.         dxDrawText("Zapamiętaj mnie", sw/2-160/zoom+1, sh/2+1, 200/zoom+sw/2+1, 40/zoom+sh/2+1, tocolor(0, 0, 0, a), 1, font1, "left", "center", false);
  407.         dxDrawText("Zapamiętaj mnie", sw/2-160/zoom, sh/2, 200/zoom+sw/2, 40/zoom+sh/2, tocolor(200, 200, 200, a), 1, font1, "left", "center", false);
  408.     end;
  409. end;
  410.  
  411. class.click = function(button, state)
  412.     if(button == "left" and state == "down" and (getTickCount()-self.tick) > 2000 and not self.off)then
  413.         if(isMouseInPosition(sw/2-194/zoom, sh/2+7/zoom, 25/zoom, 25/zoom) and self.selected == 4)then
  414.             self.save = self.save == 1 and 0 or 1;
  415.         elseif(isMouseInPosition(sw/2-235/zoom/2, sh/2+270/2/zoom+5/zoom, 25/zoom, 25/zoom) and self.selected == 3)then
  416.             self.acceptRules = self.acceptRules == 1 and 0 or 1;
  417.         elseif(isMouseInPosition(sw/2+5/zoom, sh/2+290/2/zoom, 80/zoom, 20/zoom) and self.selected == 3)then
  418.             editbox:dxDestroyEdit("EDIT-LOGIN1");
  419.             editbox:dxDestroyEdit("EDIT-HASH1");
  420.             editbox:dxDestroyEdit("EDIT-HASH2");
  421.             buttons:destroyButton("BUTTON-REGISTER1");
  422.             editbox:dxDestroyEdit("EDIT-MAIL1");
  423.  
  424.             self.selected = 2;
  425.  
  426.             local x = {};
  427.             for i,v in pairs(split(self.rules, "\n")) do
  428.                 table.insert(x, v);
  429.             end;
  430.  
  431.             scroll:dxCreateScroll("RULES-SCROLL1", sw-50/zoom, sh/2-175/zoom, 10/zoom, 10/zoom, 0, 17, x, 377/zoom);
  432.         elseif(isMouseInPosition(sw/2, sh/2, 200/zoom, 40/zoom) and self.selected == 4)then
  433.             local login = editbox:dxGetEditText("EDIT-LOGIN1") or "";
  434.             local pass = editbox:dxGetEditText("EDIT-HASH1") or "";
  435.             if(#login < 3)then
  436.                 addNoti("Login powinien posiadać przynajmniej 4 znaki.");
  437.             elseif(#pass < 5)then
  438.                 addNoti("Hasło powinno posiadać przynajmniej 7 znaków.");
  439.             else
  440.                 triggerServerEvent("logging:checkAccount", resourceRoot, login, pass, self.save);
  441.             end;
  442.         elseif(isMouseInPosition(sw/2-200/2/zoom, sh/2+390/2/zoom, 200/zoom, 40/zoom) and self.selected == 3)then
  443.             local login = editbox:dxGetEditText("EDIT-LOGIN1") or "";
  444.             local pass = editbox:dxGetEditText("EDIT-HASH2") or "";
  445.             local pass2 = editbox:dxGetEditText("EDIT-HASH1") or "";
  446.  
  447.             if(#login < 3)then
  448.                 addNoti("Login powinien posiadać przynajmniej 4 znaki.");
  449.             elseif(pass ~= pass2)then
  450.                 addNoti("Powtórzone hasło nie jest takie same.");
  451.             elseif(#pass < 5)then
  452.                 addNoti("Hasło powinno posiadać przynajmniej 7 znaków.");
  453.             elseif(self.acceptRules ~= 1)then
  454.                 addNoti("Najpierw zaakceptuj regulamin serwera.");
  455.             else
  456.                 triggerServerEvent("logging:newAccount", resourceRoot, login, pass,pass);
  457.             end;
  458.         end;
  459.  
  460.         for i,v in pairs(self.img) do
  461.             if(i <= 4)then
  462.               local newZoom = zoom;
  463.               if(sw > 1366)then
  464.                 newZoom = newZoom*1.4;
  465.               end;
  466.  
  467.                 local sY = (450/newZoom)*(i-3);
  468.                 if(self.selected ~= i)then
  469.                     if(isMouseInPosition(50/zoom, sh/2-(270+sY)/2/zoom, 192/zoom, 128/zoom))then
  470.                         if(self.selected == 3)then
  471.                             editbox:dxDestroyEdit("EDIT-LOGIN1");
  472.                             editbox:dxDestroyEdit("EDIT-HASH1");
  473.                             editbox:dxDestroyEdit("EDIT-HASH2");
  474.                             buttons:destroyButton("BUTTON-REGISTER1");
  475.                             editbox:dxDestroyEdit("EDIT-MAIL1");
  476.                         elseif(self.selected == 4)then
  477.                             editbox:dxDestroyEdit("EDIT-LOGIN1");
  478.                             editbox:dxDestroyEdit("EDIT-HASH1");
  479.                             buttons:destroyButton("BUTTON-LOGIN1");
  480.                         elseif(self.selected == 1)then
  481.                             scroll:dxDestroyScroll("NEWS-SCROLL1");
  482.                         elseif(self.selected == 2)then
  483.                             scroll:dxDestroyScroll("RULES-SCROLL1");
  484.                             buttons:destroyButton("BUTTON-RULES1");
  485.                         end;
  486.  
  487.                         self.selected = i;
  488.  
  489.                         if(self.selected == 3)then
  490.                             editbox:dxCreateEdit("EDIT-LOGIN1", "", "Wprowadź swój login...", sw/2-400/2/zoom, sh/2-330/2/zoom, 400/zoom, 50/zoom, false, 3, 255);
  491.                             editbox:dxCreateEdit("EDIT-HASH1", "", "Wprowadź swoje hasło...", sw/2-400/2/zoom, sh/2-180/2/zoom, 400/zoom, 50/zoom, true, 3, 255);
  492.                             editbox:dxCreateEdit("EDIT-HASH2", "", "Powtórz swoje hasło...", sw/2-400/2/zoom, sh/2-30/2/zoom, 400/zoom, 50/zoom, true, 3, 255);
  493.                             buttons:createButton("BUTTON-REGISTER1", "Zarejestruj się", sw/2-200/2/zoom, sh/2+390/2/zoom, 200/zoom, 40/zoom, 5, 255);
  494.                             editbox:dxCreateEdit("EDIT-MAIL1", "", "Wprowadź swój e-mail...", sw/2-400/2/zoom, sh/2+120/2/zoom, 400/zoom, 50/zoom, false, 3, 255)
  495.                         elseif(self.selected == 4)then
  496.                             editbox:dxCreateEdit("EDIT-LOGIN1", self.login, "Wprowadź swój login...", sw/2-400/2/zoom, sh/2-330/2/zoom, 400/zoom, 50/zoom, false, 3, 0);
  497.                             editbox:dxCreateEdit("EDIT-HASH1", self.password, "Wprowadź swoje hasło...", sw/2-400/2/zoom, sh/2-180/2/zoom, 400/zoom, 50/zoom, true, 3, 0);
  498.                             buttons:createButton("BUTTON-LOGIN1", "Zaloguj się", sw/2, sh/2, 200/zoom, 40/zoom, 5, 0);
  499.                         elseif(self.selected == 1)then
  500.                             scroll:dxCreateScroll("NEWS-SCROLL1", sw-50/zoom, sh/2-175/zoom, 10/zoom, 10/zoom, 0, 17, self.news, 377/zoom);
  501.                         elseif(self.selected == 2)then
  502.                             local x = {};
  503.                             for i,v in pairs(split(self.rules, "\n")) do
  504.                                 table.insert(x, v);
  505.                             end;
  506.  
  507.                             scroll:dxCreateScroll("RULES-SCROLL1", sw-50/zoom, sh/2-175/zoom, 10/zoom, 10/zoom, 0, 17, x, 377/zoom);
  508.                         end;
  509.                     end;
  510.                 end;
  511.             end;
  512.         end;
  513.     end;
  514. end;
  515.  
  516. function addNoti(text)
  517.     noti:addNotification(text, "error", 2);
  518. end;
  519. addEvent("logging.addNoti", true)
  520. addEventHandler("logging.addNoti", resourceRoot, addNoti);
  521.  
  522. addEvent("logging:result", true)
  523. addEventHandler("logging:result", resourceRoot, function(text)
  524.     self.off = getTickCount();
  525.     editbox:dxDestroyEdit("EDIT-LOGIN1");
  526.     editbox:dxDestroyEdit("EDIT-HASH1");
  527.     editbox:dxDestroyEdit("EDIT-HASH2");
  528.     scroll:dxDestroyScroll("NEWS-SCROLL1");
  529.     scroll:dxDestroyScroll("RULES-SCROLL1");
  530.     buttons:destroyButton("BUTTON-LOGIN1");
  531.     buttons:destroyButton("BUTTON-REGISTER1");
  532.     buttons:destroyButton("BUTTON-RULES1");
  533.     editbox:dxDestroyEdit("EDIT-MAIL1");
  534.     noti:addNotification("Pomyślnie wczytano dane, trwa logowanie...", "success", 2);
  535.     removeEventHandler("onClientRender", root, self.render_fnc);
  536.     stopSound(data.misc)
  537.     setCameraTarget(localPlayer)
  538.     showCursor(false)
  539.     showChat(true)
  540.     setElementFrozen(localPlayer, false);
  541.     setElementData(localPlayer,"loguje", false)
  542.  
  543. end)
  544.  
  545. class.load();
  546.  
  547. addEventHandler("onClientResourceStop", resourceRoot, function()
  548.     editbox:dxDestroyEdit("EDIT-LOGIN1");
  549.     editbox:dxDestroyEdit("EDIT-HASH1");
  550.     editbox:dxDestroyEdit("EDIT-HASH2");
  551.     scroll:dxDestroyScroll("NEWS-SCROLL1");
  552.     scroll:dxDestroyScroll("RULES-SCROLL1");
  553.     buttons:destroyButton("BUTTON-LOGIN1");
  554.     buttons:destroyButton("BUTTON-REGISTER1");
  555.     buttons:destroyButton("BUTTON-RULES1");
  556. end)
  557.  
  558. -- saves
  559.  
  560. function loadDateFromXML()
  561.     local xml = xmlLoadFile("data.xml")
  562.     if xml then
  563.         local myLogin = xmlFindChild(xml, "login", 0)
  564.         local myPassword = xmlFindChild(xml, "password", 0)
  565.         local dateLogin = xmlNodeGetValue(myLogin) or ""
  566.         local datePass = xmlNodeGetValue(myPassword) or ""
  567.         datePass = base64Decode(datePass)
  568.  
  569.         xmlUnloadFile(xml)
  570.         return {dateLogin, datePass}
  571.     end
  572.     return {"", ""}
  573. end
  574.  
  575. function saveDateToXML(login, password)
  576.     password = base64Encode(password)
  577.  
  578.     local xml = xmlLoadFile("data.xml")
  579.     if not xml then
  580.         xml = xmlCreateFile("data.xml", "data")
  581.     end
  582.  
  583.     local myLogin = xmlFindChild(xml, "login", 0)
  584.     if not myLogin then
  585.         myLogin = xmlCreateChild(xml, "login")
  586.     end
  587.  
  588.     local myPassword = xmlFindChild(xml, "password", 0)
  589.     if not myPassword then
  590.         myPassword = xmlCreateChild(xml, "password")
  591.     end
  592.  
  593.     xmlNodeSetValue(myLogin, login)
  594.     xmlNodeSetValue(myPassword, password)
  595.     xmlSaveFile(xml)
  596.     xmlUnloadFile(xml)
  597. end
  598. addEvent("logging.saveDates", true)
  599. addEventHandler("logging.saveDates", resourceRoot, saveDateToXML)
  600.  
  601. addEvent("logging.setDates", true)
  602. addEventHandler("logging.setDates", resourceRoot, function()
  603.     local data = loadDateFromXML() or {"", ""};
  604.     self.login, self.password = unpack(data);
  605.     self.save = 1;
  606.  
  607.     editbox:dxSetEditText("EDIT-LOGIN1", self.login);
  608.     editbox:dxSetEditText("EDIT-HASH1", self.password);
  609. end)
  610.  
  611. addEvent("logging.setNews", true)
  612. addEventHandler("logging.setNews", resourceRoot, function(r)
  613.     for i,v in pairs(r) do
  614.         v.date = string.sub(v.date, 1, #v.date-3);
  615.     end;
  616.  
  617.     self.news = r;
  618. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement