SHARE
TWEET

Untitled

a guest Sep 11th, 2019 883 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if getElementData(localPlayer, "user:logged") or getElementData(localPlayer, "user:uid") then return end
  2.  
  3. Login_Client = {}
  4. Login_Client.__index = Login_Client
  5.  
  6. function Login_Client:new (...)
  7.   local object = setmetatable({}, {__index = self})
  8.   if object.construct then
  9.     object:construct(...)
  10.   end
  11.   return object
  12. end
  13.  
  14. function Login_Client:Background ()
  15.   Fog:renderFogRectangle()
  16.   self.FFTData = getSoundFFTData(self.music, 2048, 130)
  17.   if not self.FFTData then return end
  18.   for key, value in pairs(self.FFTData) do
  19.     opacity = Elements:Round((value * 1920), 5) > 110 and 110 or Elements:Round((value * 1920), 5)
  20.     alpha = interpolateBetween(opacity, 220, opacity, 220, opacity, 220, (getTickCount()/570), "CosineCurve")
  21.   end
  22.   Fog:setFogSpeed(4.6)
  23.   dxDrawImage(0, 0, self.screen.x, self.screen.y, self.textures['background'])
  24.   dxDrawRectangle(0, 0, self.screen.x, self.screen.y, tocolor(102, 105, 107, 110))
  25.   dxDrawImage(0, 0, self.screen.x, self.screen.y, self.textures['lights'], 0, 0, 0, tocolor(255, 255, 255, alpha), true)
  26. end
  27.  
  28. function Login_Client:Music (bool)
  29.   if bool == true then
  30.     if not self.music then
  31.       self.music = playSound("sounds/music.mp3", true)
  32.       setSoundVolume(self.music, self.volume)
  33.     end
  34.     addEventHandler("onClientRender", root, self.VUPFunct)
  35.     removeEventHandler("onClientRender", root, self.VDNFunct)
  36.   else
  37.     addEventHandler("onClientRender", root, self.VDNFunct)
  38.     removeEventHandler("onClientRender", root, self.VUPFunct)
  39.   end
  40. end
  41.  
  42. function Login_Client:VUP ()
  43.   self.volume = self.volume + 0.0075
  44.   setSoundVolume(self.music, self.volume)
  45.   if self.volume >= 1 then
  46.     removeEventHandler("onClientRender", root, self.VUPFunct)
  47.   end
  48. end
  49.  
  50. function Login_Client:VDN ()
  51.   self.volume = self.volume - 0.0075
  52.   setSoundVolume(self.music, self.volume)
  53.   if self.volume <= 0 then
  54.     removeEventHandler("onClientRender", root, self.VDNFunct)
  55.     destroyElement(self.music)
  56.     self.music = false
  57.   end
  58. end
  59.  
  60. function Login_Client:RenderAnimations ()
  61.  
  62.   if self.Main ~= true then
  63.     self.MainAlpha = interpolateBetween(255, 0, 0, 0, 0, 0, (getTickCount() - self.LoginTick) / 620, "Linear")
  64.   else
  65.     self.MainAlpha = interpolateBetween(0, 0, 0, 255, 0, 0, (getTickCount() - self.LoginTick) / 620, "Linear")
  66.     self.LoginPosX = interpolateBetween(self.screen.x - 860/1080*self.screen.y, 0, 0, self.screen.x - 600/1080*self.screen.y, 0, 0, (getTickCount() - self.LoginTick) / 720, "OutQuad")
  67.     self.RegisterPosY = interpolateBetween(self.screen.y/2 - 350/1080*self.screen.y, 0, 0, self.screen.y/2 - 220/1080*self.screen.y, 0, 0, (getTickCount() - self.LoginTick) / 720, "OutQuad")
  68.     self.ChangesPosY = interpolateBetween(self.screen.y - 340/1080*self.screen.y, 0, 0, self.screen.y - 520/1080*self.screen.y, 0, 0, (getTickCount() - self.LoginTick) / 720, "OutQuad")
  69.   end
  70.  
  71.   if self.Login ~= true then
  72.     self.LoginAlpha = interpolateBetween(255, 0, 0, 0, 0, 0, (getTickCount() - self.LoginTick) / 620, "Linear")
  73.   else
  74.     self.LoginAlpha = interpolateBetween(0, 0, 0, 255, 0, 0, (getTickCount() - self.LoginTick) / 620, "Linear")
  75.   end
  76.  
  77.   if self.Register ~= true then
  78.     self.RegisterAlpha = interpolateBetween(255, 0, 0, 0, 0, 0, (getTickCount() - self.LoginTick) / 620, "Linear")
  79.   else
  80.     self.RegisterAlpha = interpolateBetween(0, 0, 0, 255, 0, 0, (getTickCount() - self.LoginTick) / 620, "Linear")
  81.   end
  82.  
  83.   if self.Changes ~= true then
  84.     self.ChangesAlpha = interpolateBetween(255, 0, 0, 0, 0, 0, (getTickCount() - self.LoginTick) / 620, "Linear")
  85.   else
  86.     self.ChangesAlpha = interpolateBetween(0, 0, 0, 255, 0, 0, (getTickCount() - self.LoginTick) / 620, "Linear")
  87.   end
  88.  
  89.   if self.Banned ~= true then
  90.     self.BannedAlpha = interpolateBetween(255, 0, 0, 0, 0, 0, (getTickCount() - self.LoginTick) / 620, "Linear")
  91.   else
  92.     self.BannedAlpha = interpolateBetween(0, 0, 0, 255, 0, 0, (getTickCount() - self.LoginTick) / 620, "Linear")
  93.   end
  94.  
  95. end
  96.  
  97. function Login_Client:RenderMain ()
  98.   if self.Main ~= true and getTickCount() - self.LoginTick > 720 then
  99.     self.LoginTick = getTickCount()
  100.     if self.Login ~= false then
  101.       removeEventHandler("onClientRender", root, self.mainRender)
  102.       addEventHandler("onClientRender", root, self.loginRender)
  103.     elseif self.Register ~= false then
  104.       removeEventHandler("onClientRender", root, self.mainRender)
  105.       addEventHandler("onClientRender", root, self.registerRender)
  106.     elseif self.Changes ~= false then
  107.       removeEventHandler("onClientRender", root, self.mainRender)
  108.       addEventHandler("onClientRender", root, self.changesRender)
  109.     elseif self.Banned ~= false then
  110.       removeEventHandler("onClientRender", root, self.mainRender)
  111.       addEventHandler("onClientRender", root, self.bannedRender)
  112.     end
  113.   end
  114.   local h = (512/1080*self.screen.y)*(1.0/1080*self.screen.y)
  115.   dxDrawImage( 130/1080*self.screen.y, self.screen.y/2 - (434/self.zoom)/2, (371/self.zoom), (434/self.zoom), self.textures['logo'], 0, 0, 0, tocolor(255, 255, 255, self.MainAlpha))
  116.   Elements:DrawMainButton( self.LoginPosX, 443/1080*self.screen.y, self.textures['buttons']['login']['hover'], self.textures['buttons']['login']['nohover'], self.textures['buttons']['login']['nohover'], self.MainAlpha)
  117.   Elements:DrawMainButton( self.screen.x - 390/1080*self.screen.y, self.RegisterPosY, self.textures['buttons']['register']['hover'], self.textures['buttons']['register']['nohover'], self.textures['buttons']['register']['nohover'], self.MainAlpha)
  118.   Elements:DrawMainButton( self.screen.x - 390/1080*self.screen.y, self.ChangesPosY, self.textures['buttons']['changes']['hover'], self.textures['buttons']['changes']['nohover'], self.textures['buttons']['changes']['nohover'], self.MainAlpha)
  119. end
  120.  
  121. function Login_Client:RenderBanned ()
  122.  
  123.   local w, h = 271/self.zoom, 334/self.zoom
  124.   dxDrawImage( self.screen.x/2 - w/2, (self.screen.y/2 - h/2) - 305/1080*self.screen.y, w, h, self.textures['logo'], 0, 0, 0, tocolor(255, 255, 255, self.BannedAlpha))
  125.  
  126.   dxDrawText("ZBANOWANY", 0, 656/1080*self.screen.y, self.screen.x, 280/1080*self.screen.y, tocolor(255, 255, 255, self.BannedAlpha), 1, self.fonts['light_login'], "center", "center")
  127.   dxDrawText("Zostałeś zbanowany na tym serwerze!\n\nGracz: " .. getElementData(localPlayer, "ban:playernick") .. " (".. getElementData(localPlayer, "ban:playerserial") ..")\nPowód bana: " .. getElementData(localPlayer, "ban:reason") .. "\nZbanowany przez: " .. getElementData(localPlayer, "ban:playerbannedby") .. "\nData ważności bana: " .. getElementData(localPlayer, "ban:date"), 0, 512/1080*self.screen.y, self.screen.x, 280/1080*self.screen.y, tocolor(255, 255, 255, self.BannedAlpha), 1, self.fonts['normal_button'], "center", "top")
  128.   GUI:renderButton(self.DisconnectButton)
  129.   GUI:setButtonPosition(self.DisconnectButton, self.screen.x/2 - (190/1080*self.screen.y)/2, 784/1080*self.screen.y)
  130.   GUI:setButtonTexturesColor(self.DisconnectButton, tocolor(255, 255, 255, self.BannedAlpha))
  131.  
  132. end
  133.  
  134. function Login_Client:RenderLogin ()
  135.  
  136.   if self.Login == false and getTickCount() - self.LoginTick > 720 then
  137.     removeEventHandler("onClientRender", root, self.loginRender)
  138.     GUI:destroyButton(self.loginBackButton)
  139.     GUI:destroyButton(self.loginEnterButton)
  140.     GUI:destroyEditBox(self.loginEditbox)
  141.     GUI:destroyEditBox(self.passwordEditbox)
  142.     GUI:destroyCheckbox(self.rememberMeCheckBox)
  143.     collectgarbage("collect")
  144.  
  145.     if self.Destroy ~= true then
  146.       collectgarbage()
  147.       addEventHandler("onClientRender", root, self.mainRender)
  148.     end
  149.     self.LoginTick = getTickCount()
  150.   end
  151.  
  152.   local w, h = 271/self.zoom, 334/self.zoom
  153.   dxDrawImage( self.screen.x/2 - w/2, (self.screen.y/2 - h/2) - 305/1080*self.screen.y, w, h, self.textures['logo'], 0, 0, 0, tocolor(255, 255, 255, self.LoginAlpha))
  154.  
  155.   dxDrawText("AUTORYZACJA", 0, 656/1080*self.screen.y, self.screen.x, 280/1080*self.screen.y, tocolor(255, 255, 255, self.LoginAlpha), 1, self.fonts['light_login'], "center", "center")
  156.  
  157.   GUI:renderEditBox(self.loginEditbox)
  158.   GUI:setEditBoxAlpha(self.loginEditbox, self.LoginAlpha)
  159.  
  160.   GUI:renderEditBox(self.passwordEditbox)
  161.   GUI:setEditBoxAlpha(self.passwordEditbox, self.LoginAlpha)
  162.  
  163.   GUI:renderButton(self.loginBackButton)
  164.   GUI:renderButton(self.loginEnterButton)
  165.  
  166.   GUI:renderCheckbox(self.rememberMeCheckBox)
  167.   GUI:setCheckboxTexturesColor(self.rememberMeCheckBox, tocolor(255, 255, 255, self.LoginAlpha), self.LoginAlpha )
  168.  
  169.   GUI:setButtonPosition(self.loginEnterButton, self.screen.x/2 - (404/1080*self.screen.y)/2, 748/1080*self.screen.y)
  170.   GUI:setButtonTexturesColor(self.loginEnterButton, tocolor(255, 255, 255, self.LoginAlpha))
  171.  
  172.   GUI:setEditBoxPosition(self.loginEditbox, self.screen.x/2 - (200/1080*self.screen.y)/2 + (52/1080*self.screen.y), 525/1080*self.screen.y)
  173.   GUI:setEditBoxPosition(self.passwordEditbox, self.screen.x/2 - (200/1080*self.screen.y)/2 + (52/1080*self.screen.y), 601/1080*self.screen.y)
  174.  
  175.   GUI:setButtonPosition(self.loginBackButton, self.screen.x/2 + (74/1080*self.screen.y)/2, 750/1080*self.screen.y)
  176.   GUI:setButtonTexturesColor(self.loginBackButton, tocolor(255, 255, 255, self.LoginAlpha))
  177.  
  178.     if isElement(self.rememberMeCheckBox) then
  179.       local radius, width = GUI:getCheckBoxRadius(self.rememberMeCheckBox), GUI:getCheckBoxTextWidth(self.rememberMeCheckBox)
  180.       GUI:setCheckboxPosition(self.rememberMeCheckBox, (self.screen.x/2 - radius/2) - (width*0.33) - 25/1080*self.screen.y, 700/1080*self.screen.y )
  181.     end
  182. end
  183.  
  184. function Login_Client:RenderRegister ()
  185.   if self.Register == false and getTickCount() - self.LoginTick > 720 then
  186.     removeEventHandler("onClientRender", root, self.registerRender)
  187.     GUI:destroyButton(self.registerBackButton)
  188.     GUI:destroyButton(self.registerEnterButton)
  189.     GUI:destroyEditBox(self.Register_Login_Editbox)
  190.     GUI:destroyEditBox(self.Register_Password_Editbox)
  191.     GUI:destroyEditBox(self.Register_PasswordAgain_Editbox)
  192.     GUI:destroyEditBox(self.Register_Email_Editbox)
  193.     GUI:destroyCheckbox(self.acceptRegulations)
  194.     GUI:destroyButton(self.registerBackButton)
  195.     collectgarbage("collect")
  196.     if self.Destroy ~= true then
  197.       collectgarbage()
  198.       addEventHandler("onClientRender", root, self.mainRender)
  199.     end
  200.     self.LoginTick = getTickCount()
  201.   end
  202.  
  203.   local w, h = 271/self.zoom, 334/self.zoom
  204.   dxDrawImage( self.screen.x/2 - w/2, (self.screen.y/2 - h/2) - 314/1080*self.screen.y, w, h, self.textures['logo'], 0, 0, 0, tocolor(255, 255, 255, self.RegisterAlpha))
  205.  
  206.   dxDrawText("REJESTRACJA", 0, 629/1080*self.screen.y, self.screen.x, 280/1080*self.screen.y, tocolor(255, 255, 255, self.RegisterAlpha), 1, self.fonts['light_login'], "center", "center")
  207.  
  208.   GUI:renderEditBox(self.Register_Login_Editbox)
  209.   GUI:setEditBoxPosition(self.Register_Login_Editbox, self.screen.x/2 + (510/1080*self.screen.y)/2 + (56/1080*self.screen.y), 507/1080*self.screen.y)
  210.   GUI:setEditBoxAlpha(self.Register_Login_Editbox, self.RegisterAlpha )
  211.  
  212.   GUI:renderEditBox(self.Register_Password_Editbox)
  213.   GUI:setEditBoxPosition(self.Register_Password_Editbox, self.screen.x/2 - (410/1080*self.screen.y)/2 + (56/1080*self.screen.y), 581/1080*self.screen.y)
  214.   GUI:setEditBoxAlpha(self.Register_Password_Editbox, self.RegisterAlpha )
  215.  
  216.   GUI:renderEditBox(self.Register_PasswordAgain_Editbox)
  217.   GUI:setEditBoxPosition(self.Register_PasswordAgain_Editbox, self.screen.x/2 - (410/1080*self.screen.y)/2 + (56/1080*self.screen.y), 656/1080*self.screen.y)
  218.   GUI:setEditBoxAlpha(self.Register_PasswordAgain_Editbox, self.RegisterAlpha )
  219.  
  220.   GUI:renderEditBox(self.Register_Email_Editbox)
  221.   GUI:setEditBoxPosition(self.Register_Email_Editbox, self.screen.x/2 - (410/1080*self.screen.y)/2 + (56/1080*self.screen.y), 731/1080*self.screen.y)
  222.   GUI:setEditBoxAlpha(self.Register_Email_Editbox, self.RegisterAlpha )
  223.  
  224.   GUI:renderCheckbox(self.acceptRegulations)
  225.   GUI:setCheckboxTexturesColor(self.acceptRegulations, tocolor(255, 255, 255, self.RegisterAlpha), self.RegisterAlpha )
  226.  
  227.   GUI:renderButton(self.registerBackButton)
  228.   GUI:setButtonPosition(self.registerBackButton, self.screen.x/2 + (75/1080*self.screen.y)/2, self.screen.y - 211/1080*self.screen.y)
  229.   GUI:setButtonTexturesColor(self.registerBackButton, tocolor(255, 255, 255, self.RegisterAlpha))
  230.  
  231.   GUI:renderButton(self.registerEnterButton)
  232.   GUI:setButtonPosition(self.registerEnterButton, self.screen.x/2 - (406/1080*self.screen.y)/2, self.screen.y - 211/1080*self.screen.y)
  233.   GUI:setButtonTexturesColor(self.registerEnterButton, tocolor(255, 255, 255, self.RegisterAlpha))
  234.  
  235.   if isElement(self.acceptRegulations) then
  236.       local radius, width = GUI:getCheckBoxRadius(self.acceptRegulations), GUI:getCheckBoxTextWidth(self.acceptRegulations)
  237.       GUI:setCheckboxPosition(self.acceptRegulations, (self.screen.x/2 - radius/2) - (width*0.34) - 25/1080*self.screen.y, self.screen.y - 250/1080*self.screen.y )
  238.   end
  239. end
  240.  
  241. function Login_Client:RenderChanges ()
  242.  
  243.   if self.Changes == false and getTickCount() - self.LoginTick > 720 then
  244.     removeEventHandler("onClientRender", root, self.changesRender)
  245.     GUI:destroyButton(self.changesBackButton)
  246.     collectgarbage("collect")
  247.     if self.Destroy ~= true then
  248.       collectgarbage()
  249.       addEventHandler("onClientRender", root, self.mainRender)
  250.     end
  251.     self.LoginTick = getTickCount()
  252.   end
  253.  
  254.   GUI:renderButton(self.changesBackButton)
  255.   GUI:setButtonPosition(self.changesBackButton, self.screen.x/2 - (190/1080*self.screen.y)/2, 940/1080*self.screen.y)
  256.   GUI:setButtonTexturesColor(self.changesBackButton, tocolor(255, 255, 255, self.ChangesAlpha))
  257.  
  258.   dxDrawText("ZMIANY", 170/1080*self.screen.y, 340/1080*self.screen.y, 1020/1080*self.screen.y, 160/1080*self.screen.y, tocolor(255, 255, 255, self.ChangesAlpha), 1, self.fonts['light_title'], "left", "bottom")
  259.  
  260.   local offsetTable = {}
  261.   offsetTable["data"] = 170/1080*self.screen.y
  262.   dxDrawText("DATA", offsetTable["data"], 340/1080*self.screen.y, 1020/1080*self.screen.y, 200/1080*self.screen.y, tocolor(255, 255, 255, self.ChangesAlpha), 1, self.fonts['changes_grid'], "left", "bottom")
  263.  
  264.   offsetTable["category"] =  offsetTable["data"]+dxGetTextWidth("DATA", 1.0, self.fonts['changes_grid'])+100/1080*self.screen.y
  265.   dxDrawText("KATEGORIA", offsetTable["category"], 340/1080*self.screen.y, 1020/1080*self.screen.y, 200/1080*self.screen.y, tocolor(255, 255, 255, self.ChangesAlpha), 1, self.fonts['changes_grid'], "left", "bottom")
  266.  
  267.   offsetTable["change"] =  offsetTable["category"]+dxGetTextWidth("KATEGORIA", 1.0, self.fonts['changes_grid'])+50/1080*self.screen.y
  268.   dxDrawText("ZMIANA", offsetTable["change"], 340/1080*self.screen.y, 1020/1080*self.screen.y, 200/1080*self.screen.y, tocolor(255, 255, 255, self.ChangesAlpha), 1, self.fonts['changes_grid'], "left", "bottom")
  269.  
  270.   dxDrawImage(170/1080*self.screen.y, 220/1080*self.screen.y, self.screen.x-350/1080*self.screen.y, 2/1080*self.screen.y, self.textures['line'], 0, 0, 0, tocolor(255, 255, 255, self.ChangesAlpha), true)
  271.  
  272.   self.index = 0
  273.   for key, value in ipairs(self.changesLog) do
  274.     self.index = self.index + 1
  275.     local sy = 38/1080 * self.screen.y * self.index
  276.     dxDrawText(value.changeDate, offsetTable["data"], 200/1080*self.screen.y + sy, 1020/1080*self.screen.y, 290/1080*self.screen.y, tocolor(255, 255, 255, self.ChangesAlpha), 1, self.fonts['changes_text'], "left", "top")
  277.     dxDrawText(value.changeType, offsetTable["category"], 200/1080*self.screen.y + sy, 1020/1080*self.screen.y, 290/1080*self.screen.y, tocolor(255, 255, 255, self.ChangesAlpha), 1, self.fonts['changes_text'], "left", "top")
  278.     dxDrawText(value.changeText, offsetTable["change"], 200/1080*self.screen.y + sy, 1020/1080*self.screen.y, 290/1080*self.screen.y, tocolor(255, 255, 255, self.ChangesAlpha), 1, self.fonts['changes_text'], "left", "top")
  279.   end
  280. end
  281.  
  282. function Login_Client:onLogin()
  283.     local login = GUI:getEditBoxText(self.loginEditbox)
  284.     local password = GUI:getEditBoxText(self.passwordEditbox)
  285.     if string.len(login) == 0 or string.len(password) == 0 then
  286.         exports["ps_hud"]:showPlayerNotification("Musisz wypełnić wszystkie pola tekstowe!", "error", true, 6500)
  287.     else
  288.         exports["ps_hud"]:showPlayerNotification("Trwa weryfikacja danych, proszę czekać...", "info", true, 4100)
  289.         setTimer(function()
  290.           triggerServerEvent("onPlayerLoginAccount", resourceRoot, login, password)
  291.         end, 800, 1)
  292.         self:saveXML(login, password, self.rememberMeCheckBox)
  293.     end
  294. end
  295.  
  296. function Login_Client:loadXML ()
  297.   if not self.xmlFile then
  298.     self.xmlFile = xmlCreateFile("userdata.xml", "userdata")
  299.     usernameChild = xmlCreateChild(self.xmlFile, "username")
  300.     passwordChild = xmlCreateChild(self.xmlFile, "password")
  301.     checkboxChild = xmlCreateChild(self.xmlFile, "state")
  302.     xmlSaveFile(self.xmlFile)
  303.   else
  304.     usernameChild = xmlFindChild(self.xmlFile, "username", 0)
  305.     passwordChild = xmlFindChild(self.xmlFile, "password", 0)
  306.     checkboxChild = xmlFindChild(self.xmlFile, "state", 0)
  307.   end
  308.   if xmlNodeGetValue(checkboxChild) == "true" then
  309.     GUI:setCheckboxSelected(self.rememberMeCheckBox, true)
  310.   end
  311.   usernameLoad = xmlNodeGetValue(usernameChild)
  312.   passwordLoad = xmlNodeGetValue(passwordChild)
  313.   if usernameLoad ~= "" then
  314.     GUI:setEditBoxText(self.loginEditbox, usernameLoad)
  315.   end
  316.   if passwordLoad ~= "" then
  317.     GUI:setEditBoxText(self.passwordEditbox, passwordLoad)
  318.   end
  319. end
  320.  
  321. function Login_Client:saveXML (login, password)
  322.   if GUI:getCheckBoxSelected(self.rememberMeCheckBox) == true then
  323.     xmlNodeSetValue(usernameChild, login)
  324.     xmlNodeSetValue(passwordChild, password)
  325.     xmlNodeSetValue(checkboxChild, "true")
  326.     xmlSaveFile(self.xmlFile)
  327.   else
  328.     xmlNodeSetValue(usernameChild, "")
  329.     xmlNodeSetValue(passwordChild, "")
  330.     xmlNodeSetValue(checkboxChild, "")
  331.     xmlSaveFile(self.xmlFile)
  332.   end
  333. end
  334.  
  335. function Login_Client:onRegister()
  336.     local login = GUI:getEditBoxText(self.Register_Login_Editbox)
  337.     local password = GUI:getEditBoxText(self.Register_Password_Editbox)
  338.     local password_again = GUI:getEditBoxText(self.Register_PasswordAgain_Editbox)
  339.     local email = GUI:getEditBoxText(self.Register_Email_Editbox)
  340.     local accept = GUI:getCheckBoxSelected(self.acceptRegulations)
  341.     if string.len(login) == 0 or string.len(password) == 0 or string.len(password_again) == 0 or string.len(email) == 0 then
  342.         exports["ps_hud"]:showPlayerNotification("Musisz wypełnić wszystkie pola tekstowe!", "error", true, 6500)
  343.     elseif string.len(login) < 5 then
  344.         exports["ps_hud"]:showPlayerNotification("Minimalna ilość znaków loginu to 5!", "error", true, 6500)
  345.     elseif string.len(password) < 5 or string.len(password_again) < 5 then
  346.         exports["ps_hud"]:showPlayerNotification("Minimalna ilość znaków hasła to 5!", "error", true, 6500)
  347.     elseif password ~= password_again then
  348.         exports["ps_hud"]:showPlayerNotification("Hasła muszą być identyczne!", "error", true, 6500)
  349.     elseif password == login then
  350.         exports["ps_hud"]:showPlayerNotification("Login nie może być taki sam jak hasło!", "error", true, 6500)
  351.     elseif Elements:validEmail(email) == false then
  352.         exports["ps_hud"]:showPlayerNotification("Adres email jest nieprawidłowy!", "error", true, 6500)
  353.     elseif accept == false then
  354.         exports["ps_hud"]:showPlayerNotification("Wymagana jest akceptacja regulaminu serwera!", "error", true, 6500)
  355.     else
  356.         exports["ps_hud"]:showPlayerNotification("Trwa weryfikacja danych, proszę czekać...", "info", true, 4100)
  357.         setTimer(function()
  358.           triggerServerEvent("onPlayerCreateAccount", resourceRoot, login, password, email)
  359.         end, 800, 1)
  360.     end
  361. end
  362.  
  363. function Login_Client:onBackMenu()
  364.     self.LoginTick = getTickCount()
  365.     self.Main = true
  366.     self.Login = false
  367.     self.Register = false
  368.     self.Changes = false
  369. end
  370.  
  371. function Login_Client:construct (...)
  372.   GUI = exports["ps_gui"]
  373.   Fog = exports["shader_2dfog"]
  374.  
  375.   Elements = Login_Elements_Client:new()
  376.  
  377.   self.zoom = GUI:getInterfaceScale()
  378.   self.screen = Vector2(guiGetScreenSize())
  379.   self.onLogIn = function(...) return self:onLogin(...) end
  380.   self.onRegisterIn = function(...) return self:onRegister(...) end
  381.   self.onEventBackMenu = function(...) return self:onBackMenu(...) end
  382.   self.saveLoginData = function(...) return self:saveLoginXML(...) end
  383.   self.VUPFunct = function(...) return self:VUP(...) end
  384.   self.VDNFunct = function(...) return self:VDN(...) end
  385.  
  386.   addEvent("onPlayerSaveLoginData", true)
  387.   addEventHandler("onPlayerSaveLoginData", root, self.saveLoginData)
  388.  
  389.   addEvent("showPlayerIsBanned", true)
  390.   addEventHandler("showPlayerIsBanned", root, function()
  391.     self.LoginTick = getTickCount()
  392.     self.Main = false
  393.     self.Destroy = true
  394.     self.Login = false
  395.     self.Register = false
  396.     self.Changes = false
  397.     self.Banned = true
  398.     self.DisconnectButton = GUI:createButton("Rozłącz z serwera", self.screen.x, self.screen.y, 165/1080*self.screen.y, 52/1080*self.screen.y)
  399.     GUI:setButtonFont(self.DisconnectButton, self.fonts['bold_button'], 0.7)
  400.     GUI:setButtonTextures(self.DisconnectButton, {default=self.textures['buttons']['normal_button']['nohover'], hover=self.textures['buttons']['normal_button']['hover'], press=self.textures['buttons']['normal_button']['nohover']})
  401.     addEventHandler("onPlayerClickButton", self.DisconnectButton, function()
  402.       triggerEvent("onPlayerShowBlackScreen", localPlayer)
  403.       self:Music(false)
  404.       self.Main = false
  405.       self.Login = false
  406.       self.Register = false
  407.       self.Changes = false
  408.       self.Banned = false
  409.       setTimer(function()
  410.         triggerServerEvent("onPlayerClickDisconnect", resourceRoot)
  411.       end, 4125, 1)
  412.     end)
  413.   end)
  414.  
  415.   addEventHandler("onClientResourceStart", resourceRoot, function()
  416.  
  417.     showChat(false)
  418.     showCursor(true)
  419.     fadeCamera(false)
  420.     setElementAlpha(localPlayer, 0)
  421.     Fog:refreshInstance(180)
  422.     showPlayerHudComponent("all", false)
  423.     triggerServerEvent("onPlayerCheckIsBanned", resourceRoot, getPlayerSerial(localPlayer))
  424.     triggerEvent("onResourcesDownloadedStop", resourceRoot)
  425.  
  426.     self.music = false
  427.     self.volume = 0
  428.     self:Music(true)
  429.  
  430.     self.LoginTick = getTickCount()
  431.     self.Main = true
  432.     self.hexagon = Hexagon:new()
  433.     collectgarbage()
  434.  
  435.     addEventHandler("onClientClick", root, function(button, state)
  436.       local hx, hy, hsize = self.LoginPosX + ( (200/1080*self.screen.y)/2)+32/1080*self.screen.y, 443/1080*self.screen.y - 23/1080*self.screen.y, 129/1080*self.screen.y
  437.       if self.Main == true and self.hexagon:colission(hx, hy + hsize, hsize, 122) then -- Logowanie
  438.         if getKeyState("mouse1") ~= true then
  439.           self.LoginTick = getTickCount()
  440.           self.loginBackButton = GUI:createButton("Wróć", self.screen.x, self.screen.y, 165/1080*self.screen.y, 52/1080*self.screen.y)
  441.           self.loginEnterButton = GUI:createButton("Zaloguj", self.screen.x, self.screen.y, 165/1080*self.screen.y, 55/1080*self.screen.y)
  442.  
  443.           self.loginEditbox = GUI:createEditBox("", self.screen.x/2, 400/1080*self.screen.y, 348/1080*self.screen.y, 52/1080*self.screen.y, "Login")
  444.           GUI:setEditBoxVertical(self.loginEditbox, "left")
  445.           GUI:setEditBoxIcon(self.loginEditbox, ":ps_gui/images/icons/person.png", 52/1080*self.screen.y)
  446.           GUI:setEditBoxFont(self.loginEditbox, self.fonts['editbox_font'], 1)
  447.           GUI:setEditBoxAlpha(self.loginEditbox, 0)
  448.  
  449.           self.passwordEditbox = GUI:createEditBox("", self.screen.x/2, 600/1080*self.screen.y, 348/1080*self.screen.y, 52/1080*self.screen.y, "Hasło")
  450.           GUI:setEditBoxVertical(self.passwordEditbox, "left")
  451.           GUI:setEditBoxIcon(self.passwordEditbox, ":ps_gui/images/icons/key.png", 52/1080*self.screen.y)
  452.           GUI:setEditBoxFont(self.passwordEditbox, self.fonts['editbox_font'], 1)
  453.           GUI:setEditBoxAlpha(self.passwordEditbox, 0)
  454.           GUI:setEditBoxMasked(self.passwordEditbox, true, "*")
  455.  
  456.           GUI:setButtonTextures(self.loginEnterButton, {default=self.textures['buttons']['normal_button']['nohover'], hover=self.textures['buttons']['normal_button']['hover'], press=self.textures['buttons']['normal_button']['nohover']})
  457.           GUI:setButtonFont(self.loginEnterButton, self.fonts['normal_button'], 0.85)
  458.  
  459.           GUI:setButtonTextures(self.loginBackButton, {default=self.textures['buttons']['normal_button']['nohover'], hover=self.textures['buttons']['normal_button']['hover'], press=self.textures['buttons']['normal_button']['nohover']})
  460.           GUI:setButtonFont(self.loginBackButton, self.fonts['normal_button'], 0.85)
  461.  
  462.           self.rememberMeCheckBox = GUI:createCheckbox(self.screen.x/2, 370/1080*self.screen.y, 17/1080*self.screen.y, "Zapamiętaj mnie", false)
  463.           GUI:setCheckboxTexturesColor(self.rememberMeCheckBox, tocolor(255, 255, 255, 0) )
  464.           GUI:setCheckboxFont(self.rememberMeCheckBox, self.fonts['normal_button'], 0.79)
  465.           GUI:setCheckboxTextures(self.rememberMeCheckBox, {off = ":ps_gui/images/checkbox_off.png", on = ":ps_gui/images/checkbox_on.png"} )
  466.  
  467.           addEventHandler("onPlayerClickButton", self.loginEnterButton, self.onLogIn )
  468.           addEventHandler("onPlayerClickButton", self.loginBackButton, self.onEventBackMenu )
  469.  
  470.           self.xmlFile = xmlLoadFile("userdata.xml")
  471.           self:loadXML()
  472.  
  473.           self.Main = false
  474.           self.Login = true
  475.           self.Register = false
  476.           self.Changes = false
  477.         end
  478.       end
  479.  
  480.       local hx, hy, hsize = (self.screen.x - 390/1080*self.screen.y) + ( (200/1080*self.screen.y)/2)+32/1080*self.screen.y, self.RegisterPosY - 23/1080*self.screen.y, 129/1080*self.screen.y
  481.       if self.Main == true and self.hexagon:colission(hx, hy + hsize, hsize, 122) then -- Rejestracja
  482.         if getKeyState("mouse1") ~= true then
  483.           self.LoginTick = getTickCount()
  484.           self.registerBackButton = GUI:createButton("Wróć", self.screen.x, self.screen.y, 165/1080*self.screen.y, 55/1080*self.screen.y)
  485.           self.registerEnterButton = GUI:createButton("Zarejestruj", self.screen.x, self.screen.y, 165/1080*self.screen.y, 55/1080*self.screen.y)
  486.  
  487.           addEventHandler("onPlayerClickButton", self.registerEnterButton, self.onRegisterIn )
  488.           addEventHandler("onPlayerClickButton", self.registerBackButton, self.onEventBackMenu )
  489.  
  490.           self.Register_Login_Editbox = GUI:createEditBox("", self.screen.x/2, 600/1080*self.screen.y, 348/1080*self.screen.y, 52/1080*self.screen.y, "Login")
  491.           GUI:setEditBoxVertical(self.Register_Login_Editbox, "left")
  492.           GUI:setEditBoxIcon(self.Register_Login_Editbox, ":ps_gui/images/icons/person.png", 52/1080*self.screen.y)
  493.           GUI:setEditBoxFont(self.Register_Login_Editbox, self.fonts['editbox_font'], 1)
  494.           GUI:setEditBoxAlpha(self.Register_Login_Editbox, 0)
  495.  
  496.           self.Register_Password_Editbox = GUI:createEditBox("", self.screen.x/2, 600/1080*self.screen.y, 348/1080*self.screen.y, 52/1080*self.screen.y, "Hasło")
  497.           GUI:setEditBoxVertical(self.Register_Password_Editbox, "left")
  498.           GUI:setEditBoxIcon(self.Register_Password_Editbox, ":ps_gui/images/icons/key.png", 52/1080*self.screen.y)
  499.           GUI:setEditBoxFont(self.Register_Password_Editbox, self.fonts['editbox_font'], 1)
  500.           GUI:setEditBoxAlpha(self.Register_Password_Editbox, 0)
  501.           GUI:setEditBoxMasked(self.Register_Password_Editbox, true, "*")
  502.  
  503.           self.Register_PasswordAgain_Editbox = GUI:createEditBox("", self.screen.x/2, 600/1080*self.screen.y, 348/1080*self.screen.y, 52/1080*self.screen.y, "Powtórz hasło")
  504.           GUI:setEditBoxVertical(self.Register_PasswordAgain_Editbox, "left")
  505.           GUI:setEditBoxIcon(self.Register_PasswordAgain_Editbox, ":ps_gui/images/icons/key.png", 52/1080*self.screen.y)
  506.           GUI:setEditBoxFont(self.Register_PasswordAgain_Editbox, self.fonts['editbox_font'], 1)
  507.           GUI:setEditBoxAlpha(self.Register_PasswordAgain_Editbox, 0)
  508.           GUI:setEditBoxMasked(self.Register_PasswordAgain_Editbox, true, "*")
  509.  
  510.           self.Register_Email_Editbox = GUI:createEditBox("", self.screen.x/2, 600/1080*self.screen.y, 348/1080*self.screen.y, 52/1080*self.screen.y, "E-mail")
  511.           GUI:setEditBoxVertical(self.Register_Email_Editbox, "left")
  512.           GUI:setEditBoxIcon(self.Register_Email_Editbox, ":ps_gui/images/icons/mail.png", 52/1080*self.screen.y)
  513.           GUI:setEditBoxFont(self.Register_Email_Editbox, self.fonts['editbox_font'], 1)
  514.           GUI:setEditBoxAlpha(self.Register_Email_Editbox, 0)
  515.           GUI:setEditBoxRule(self.Register_Email_Editbox, "%p*[^@.%a%d]")
  516.  
  517.           self.acceptRegulations = GUI:createCheckbox(self.screen.x/2, 348/1080*self.screen.y, 17/1080*self.screen.y, "Akceptuję regulamin", false)
  518.           GUI:setCheckboxTexturesColor(self.acceptRegulations, tocolor(255, 255, 255, 0) )
  519.           GUI:setCheckboxFont(self.acceptRegulations, self.fonts['normal_button'], 0.80)
  520.           GUI:setCheckboxTextures(self.acceptRegulations, {off = ":ps_gui/images/checkbox_off.png", on = ":ps_gui/images/checkbox_on.png"} )
  521.  
  522.           GUI:setButtonTextures(self.registerBackButton, {default=self.textures['buttons']['normal_button']['nohover'], hover=self.textures['buttons']['normal_button']['hover'], press=self.textures['buttons']['normal_button']['nohover']})
  523.           GUI:setButtonFont(self.registerBackButton, self.fonts['normal_button'], 0.85)
  524.  
  525.           GUI:setButtonTextures(self.registerEnterButton, {default=self.textures['buttons']['normal_button']['nohover'], hover=self.textures['buttons']['normal_button']['hover'], press=self.textures['buttons']['normal_button']['nohover']})
  526.           GUI:setButtonFont(self.registerEnterButton, self.fonts['normal_button'], 0.85)
  527.  
  528.           self.Main = false
  529.           self.Login = false
  530.           self.Register = true
  531.           self.Changes = false
  532.         end
  533.       end
  534.  
  535.       local hx, hy, hsize = (self.screen.x - 390/1080*self.screen.y) + ( (200/1080*self.screen.y)/2)+32/1080*self.screen.y, self.ChangesPosY - 23/1080*self.screen.y, 129/1080*self.screen.y
  536.       if self.Main == true and self.hexagon:colission(hx, hy + hsize, hsize, 122) then -- Zmiany
  537.         if getKeyState("mouse1") ~= true then
  538.           self.LoginTick = getTickCount()
  539.           self.changesBackButton = GUI:createButton("Wróć", self.screen.x, self.screen.y, 190/1080*self.screen.y, 55/1080*self.screen.y, 5)
  540.           GUI:setButtonTextures(self.changesBackButton, {default=self.textures['buttons']['normal_button']['nohover'], hover=self.textures['buttons']['normal_button']['hover'], press=self.textures['buttons']['normal_button']['nohover']})
  541.           GUI:setButtonFont(self.changesBackButton, self.fonts['normal_button'], 0.85)
  542.           addEventHandler("onPlayerClickButton", self.changesBackButton, self.onEventBackMenu )
  543.           self.Main = false
  544.           self.Login = false
  545.           self.Register = false
  546.           self.Changes = true
  547.         end
  548.       end
  549.     end)
  550.   end)
  551.  
  552.   self.backgroundRender = function() self:Background() end
  553.   addEventHandler("onClientRender", root, self.backgroundRender)
  554.  
  555.   self.animationsRender = function() self:RenderAnimations() end
  556.   addEventHandler("onClientRender", root, self.animationsRender)
  557.  
  558.   self.mainRender = function() self:RenderMain() end
  559.   addEventHandler("onClientRender", root, self.mainRender, true, "low-3")
  560.  
  561.   self.loginRender = function() self:RenderLogin() end
  562.   self.registerRender = function() self:RenderRegister() end
  563.   self.changesRender = function() self:RenderChanges() end
  564.   self.bannedRender = function() self:RenderBanned() end
  565.  
  566.   self.textures = {
  567.     ['logo'] = GUI:createInterfaceTexture(":ps_login/images/logo.png"),
  568.     ['background'] = GUI:createInterfaceTexture(":ps_login/images/background.png"),
  569.     ['lights'] = GUI:createInterfaceTexture(":ps_login/images/lights.png"),
  570.     ['line'] = GUI:createInterfaceTexture(":ps_login/images/changes/changes_line.png"),
  571.     ['buttons'] = {
  572.       ['login'] = {
  573.         ['hover'] = GUI:createInterfaceTexture(":ps_login/images/main/login_button_active.png"),
  574.         ['nohover'] = GUI:createInterfaceTexture(":ps_login/images/main/login_button.png")
  575.       },
  576.       ['register'] = {
  577.         ['hover'] = GUI:createInterfaceTexture(":ps_login/images/main/register_button_active.png"),
  578.         ['nohover'] = GUI:createInterfaceTexture(":ps_login/images/main/register_button.png")
  579.       },
  580.       ['changes'] = {
  581.         ['hover'] = GUI:createInterfaceTexture(":ps_login/images/main/changes_button_active.png"),
  582.         ['nohover'] = GUI:createInterfaceTexture(":ps_login/images/main/changes_button.png")
  583.       },
  584.       ['normal_button'] = {
  585.         ['hover'] = GUI:createInterfaceTexture(":ps_gui/images/button_active.png"),
  586.         ['nohover'] = GUI:createInterfaceTexture(":ps_gui/images/button.png")
  587.       },
  588.     },
  589.   }
  590.  
  591.   self.fonts = {
  592.     ['light_login'] = GUI:setInterfaceFont("light", 30.93/1080*self.screen.y),
  593.     ['light_title'] = GUI:setInterfaceFont("bold", 31/1080*self.screen.y),
  594.     ['normal_button'] = GUI:setInterfaceFont("normal", 21/1080*self.screen.y),
  595.     ['bold_button'] = GUI:setInterfaceFont("bold", 21/1080*self.screen.y),
  596.     ['editbox_font'] = GUI:setInterfaceFont("normal", 16/1080*self.screen.y),
  597.     ['changes_grid'] = GUI:setInterfaceFont("light", 20/1080*self.screen.y),
  598.     ['changes_text'] = GUI:setInterfaceFont("normal", 19/1080*self.screen.y)
  599.   }
  600.  
  601.   self.changesLog = ChangesLogs
  602.  
  603.   addEvent("destroyLoginBackground", true)
  604.   addEventHandler("destroyLoginBackground", root, function()
  605.     self:Music(false)
  606.     Fog:destroyFogRectangle()
  607.     removeEventHandler("onClientRender", root, self.backgroundRender)
  608.   end)
  609.  
  610.   addEvent("onPlayerLoginResults", true)
  611.   addEventHandler("onPlayerLoginResults", resourceRoot, function(bool, text, type)
  612.  
  613.     if not text then text = "" end
  614.     if not type then type = "info" end
  615.  
  616.     if bool then
  617.       self.LoginTick = getTickCount()
  618.       self.Main = false
  619.       self.Login = false
  620.       self.Register = false
  621.       self.Changes = false
  622.       self.Destroy = true
  623.       showCursor(false)
  624.       triggerEvent("onPlayerShowBlackScreen", localPlayer)
  625.       setTimer(function()
  626.         triggerEvent("onPlayerHideBlackScreen", localPlayer)
  627.         Spawns = Spawns_Client:new()
  628.         Spawns:ShowSpawnsGUI()
  629.       end, 3800, 1)
  630.     else
  631.       exports["ps_hud"]:showPlayerNotification(text, type, true, 5600)
  632.       return
  633.     end
  634.  
  635.   end)
  636.  
  637.   addEventHandler("onClientResourceStop", resourceRoot, function()
  638.     showChat(true)
  639.     showCursor(false)
  640.     fadeCamera(true)
  641.     setElementAlpha(localPlayer, 255)
  642.     Fog:destroyFogRectangle()
  643.     GUI:destroyButton(self.loginEnterButton)
  644.     GUI:destroyButton(self.loginBackButton)
  645.     GUI:destroyButton(self.registerBackButton)
  646.     GUI:destroyButton(self.changesBackButton)
  647.     GUI:destroyEditBox(self.loginEditbox)
  648.     GUI:destroyEditBox(self.passwordEditbox)
  649.     GUI:destroyCheckbox(self.rememberMeCheckBox)
  650.     GUI:destroyButton(self.registerBackButton)
  651.     GUI:destroyButton(self.registerEnterButton)
  652.     GUI:destroyButton(self.DisconnectButton)
  653.     GUI:destroyEditBox(self.Register_Login_Editbox)
  654.     GUI:destroyEditBox(self.Register_Password_Editbox)
  655.     GUI:destroyEditBox(self.Register_PasswordAgain_Editbox)
  656.     GUI:destroyEditBox(self.Register_Email_Editbox)
  657.     GUI:destroyCheckbox(self.acceptRegulations)
  658.     collectgarbage("collect")
  659.   end)
  660.  
  661. end
  662.  
  663. Login_Client:new()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top