Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.01 KB | None | 0 0
  1.  
  2. ----------------------------------
  3. -----------| Settings |-----------
  4. ----------------------------------
  5.  
  6. blackLoginScreen = false            -- Set to 'true' to display a black screen to the player untill they log in or choose to play as a guest.
  7.  
  8. enableKickPlayer = true         -- Set whether to kick the player after they fail to login specified amount of times.
  9.  
  10. disallowLogout = false          -- Set whether to show the userpanel to the players if they log out of their accounts.
  11.  
  12. removeBlackScreenTime = 4       -- The time it takes for the black screen to dissapear - If you choose to display the black screen. [IN SECONDS]
  13.  
  14. maxLoginAttempts = 5            -- Set the maximum incorrect login attempts before the player gets kicked - If player kicking is enabled.
  15.  
  16. ----------------------------------
  17.  
  18.  
  19.  
  20. -- Set the text you want displayed in the "rules" window here - use '\n' to go into the next line
  21. infoText = "Siema!\nOtwieramy server MTA:SA na naszej ulubionej sieci HolySkill.pl\nZapraszam kazdego do gry!\nPozdro\nOski"
  22.  
  23. guiSetInputEnabled(true)
  24.  
  25. -- Screen and GUI window sizes
  26. screenWidth,screenHeight = guiGetScreenSize()
  27. mainWidth,mainHeight = 439,350
  28. regWidth,regHeight = 439,440
  29. statWidth,statHeight = 439,500
  30.  
  31.  
  32. -- Generate the XML file name
  33. function getServerName()
  34.     triggerServerEvent("onClientLoginLoaded",getLocalPlayer())
  35. end
  36. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),getServerName)
  37.  
  38. function setXmlFileName(sName)
  39.     xmlFileName = tostring("login_"..sName..".xml")
  40.     loginPanel()
  41. end
  42. addEvent("onGetServerData",true)
  43. addEventHandler("onGetServerData",getRootElement(),setXmlFileName)
  44.  
  45.  
  46. ----------------------------------
  47.  
  48. addEvent("onRequestIncreaseAttempts",true)
  49. addEvent("onRequestDisplayPanel",true)
  50.  
  51. function loginPanel()
  52.         -- Check if autologin is enabled - If yes, then log the player in, else create and show the userpanel
  53.         local xmlFile = xmlLoadFile(xmlFileName)
  54.         if xmlFile then
  55.             status = xmlNodeGetAttribute(xmlFile,"autologin")
  56.             if (status == "true") then
  57.                 local username = tostring(xmlNodeGetAttribute(xmlFile,"username"))
  58.                 local password = tostring(xmlNodeGetAttribute(xmlFile,"password"))
  59.                 if not (username == "") and not (password == "") then
  60.                     triggerServerEvent("onRequestAutologin",getLocalPlayer(),username,password)
  61.                 end
  62.             else
  63.                 if blackLoginScreen == true then
  64.                     setCameraMatrix(-1798.4619140625,890.6220703125,78.623817443848,-1775.4619140625,918.6220703125,24.623817443848,0,70)
  65.                 end
  66.                     setCameraMatrix(-1798.4619140625,890.6220703125,78.623817443848,-1775.4619140625,918.6220703125,24.623817443848,0,70)
  67.                    
  68.                 mainWindow = guiCreateWindow(0.3492,0.3104,0.3383,0.3531,"Panel Logowania by Nero657 (c)",true)
  69.                 guiSetAlpha(mainWindow,1)
  70.                 guiWindowSetMovable(mainWindow,false)
  71.                 guiWindowSetSizable(mainWindow,false)
  72.                 imglogowanie = guiCreateStaticImage(0.0208,0.0383,0.9215,0.2773,"logowanie.png",true,mainWindow)
  73.                 lblLogin = guiCreateLabel(0.0462,0.4277,0.164,0.0619,"LOGIN:",true,mainWindow)
  74.                 guiLabelSetVerticalAlign(lblLogin,"center")
  75.                 guiSetFont(lblLogin,"default-bold-small")
  76.                 lblHaslo = guiCreateLabel(0.0462,0.5487,0.1755,0.0855,"HASŁO:",true,mainWindow)
  77.                 guiLabelSetVerticalAlign(lblHaslo,"center")
  78.                 guiSetFont(lblHaslo,"default-bold-small")
  79.                 editPassword = guiCreateEdit(0.2217,0.5575,0.6028,0.0737,"",true,mainWindow)
  80.                 guiEditSetMasked(editPassword,true)
  81.                 guiEditSetMaxLength(editPassword,20)
  82.                 editUsername = guiCreateEdit(0.2217,0.4277,0.6028,0.0737,"",true,mainWindow)
  83.                 guiEditSetMaxLength(editUsername,20)
  84.                 btnLogin = guiCreateButton(0.0462,0.7227,0.4365,0.1534,"LOGOWANIE",true,mainWindow)
  85.                 guiSetFont(btnLogin,"default-bold-small")
  86.                 btnToggleRegister = guiCreateButton(0.5058,0.7227,0.4365,0.1534,"REJSTRACJA",true,mainWindow)
  87.                 guiSetFont(btnToggleRegister,"default-bold-small")
  88.                 infolbl = guiCreateLabel(0.0208,0.9351,0.7945,0.0442,"Copyright by Nero657 2012",true,mainWindow)
  89.  
  90.  
  91. -----------------------------------------------------------------------------------------------------------------------------------------------------
  92.  
  93.                
  94.  
  95.                
  96.                 registerWindow = guiCreateWindow(0.2859,0.2927,0.4305,0.4969,"Panel Logowania by Nero657 (c)",true)
  97.                 guiSetAlpha(registerWindow,1)
  98.                 guiWindowSetSizable(registerWindow,false)
  99.                 guiWindowSetMovable(registerWindow,false)
  100.                 registerimg = guiCreateStaticImage(0.029,0.0587,0.9201,0.2851,"rejstracja.png",true,registerWindow)
  101.                 editRegistrationUsername = guiCreateEdit(0.2396,0.3983,0.5009,0.065,"",true,registerWindow)
  102.                 guiEditSetMaxLength(editRegistrationUsername,20)
  103.                 editRegistrationPassword = guiCreateEdit(0.2396,0.4843,0.5009,0.065,"",true,registerWindow)
  104.                 guiEditSetMasked(editRegistrationPassword,true)
  105.                 guiEditSetMaxLength(editRegistrationPassword,20)
  106.                 editRegistrationRepeatPassword = guiCreateEdit(0.2396,0.5702,0.5009,0.065,"",true,registerWindow)
  107.                 guiEditSetMasked(editRegistrationRepeatPassword,true)
  108.                 guiEditSetMaxLength(editRegistrationRepeatPassword,20)
  109.                 lblLogin = guiCreateLabel(0.0181,0.3983,0.2033,0.065,"Twój login:",true,registerWindow)
  110.                 guiLabelSetVerticalAlign(lblLogin,"center")
  111.                 guiSetFont(lblLogin,"default-bold-small")
  112.                 lblHaslo = guiCreateLabel(0.0181,0.4843,0.2033,0.065,"Twoje haslo:",true,registerWindow)
  113.                 guiLabelSetVerticalAlign(lblHaslo,"center")
  114.                 guiSetFont(lblHaslo,"default-bold-small")
  115.                 lblPowtorzHaslo = guiCreateLabel(0.0181,0.5702,0.2214,0.065,"Potwierdz twoje haslo:",true,registerWindow)
  116.                 guiLabelSetVerticalAlign(lblPowtorzHaslo,"center")
  117.                 guiSetFont(lblPowtorzHaslo,"default-bold-small")
  118.                 btnConfirmRegistration = guiCreateButton(0.0544,0.717,0.5281,0.109,"REJSTRACJA",true,registerWindow)
  119.                 guiSetFont(btnConfirmRegistration,"default-bold-small")
  120.                 btnCancel = guiCreateButton(0.6897,0.8826,0.274,0.086,"Powrot do\nlogowania",true,registerWindow)
  121.                 reg = guiCreateLabel(0.3811,0.6562,0.4356,0.0398,"Rejestrując się akcetpujesz REGULAMIN",true,registerWindow)
  122.                 guiSetFont(reg,"default-bold-small")
  123.                 regBtn = guiCreateButton(0.6007,0.717,0.3394,0.109,"REGULAMIN",true,registerWindow)
  124.                 maxlabel = guiCreateLabel(0.7586,0.4088,0.216,0.0545,"(max 20 znaków)",true,registerWindow)
  125.                 maxlabel3 = guiCreateLabel(0.7586,0.5807,0.216,0.0545,"(max 20  znaków)",true,registerWindow)
  126.                 maxlabel2 = guiCreateLabel(0.7586,0.4948,0.216,0.0545,"(max 20  znaków)",true,registerWindow)
  127.                 info = guiCreateLabel(0.0327,0.9413,0.3666,0.0524,"Copyright by Nero657 2012",true,registerWindow)
  128.  
  129.  
  130.  
  131.  
  132. -----------------------------------------------------///////STATY//////----------------------------------------------------------------------------
  133.  
  134.                 statystyki = guiCreateWindow(0.3688,0.2406,0.3148,0.4667,"Statystyki by Nero657 (c)",true)
  135.                 guiSetAlpha(statystyki,1)
  136.                 statimg = guiCreateStaticImage(0.0372,0.067,0.8859,0.2879,"staty.png",true,statystyki)
  137.                 stat_label = guiCreateLabel(0.0794,0.3638,0.8238,0.4219,"",true,statystyki)
  138.                 guiLabelSetColor(stat_label,112,122,122)
  139.                 guiLabelSetVerticalAlign(stat_label,"center")
  140.                 guiSetFont(stat_label,"default-bold-small")
  141.                 buttonok = guiCreateButton(0.5285,0.8504,0.4069,0.1071,"Przejdź dalej",true,statystyki)
  142.                 guiSetFont(buttonok,"default-bold-small")
  143.                 infolbl2 = guiCreateLabel(0.0521,0.942,0.4169,0.0513,"Copyright by Nero657",true,statystyki)
  144.  
  145. -----------------------------------------------------------------------------------------------------------------------------------------------------
  146. -----------------------------------------------------///////widescr//////----------------------------------------------------------------------------
  147.  
  148.                 wideScreenGUI = guiCreateStaticImage(0,0,1,1,"widescreen.png",true,getRootElement())
  149.                 guiMoveToBack (wideScreenGUI)
  150.  
  151.  
  152. -----------------------------------------------------------------------------------------------------------------------------------------------------
  153.                 guiSetVisible(mainWindow, true)
  154.                 guiSetVisible(registerWindow, false)
  155.                 guiSetVisible(statystyki, false)
  156.                 guiSetInputEnabled(true)
  157.  
  158.                 showCursor(true)
  159.                 addEventHandler("onClientGUIClick",btnLogin,onClickLogin)
  160.                 addEventHandler("onClientGUIClick",btnToggleRegister,onClickRegisterToggle)
  161.                 addEventHandler("onClientGUIClick",btnConfirmRegistration,onClickRegisterConfirm)
  162.                 addEventHandler("onClientGUIClick",btnCancel,onClickCancel)
  163.                 addEventHandler("onRequestIncreaseAttempts",getRootElement(),increaseAttempts)
  164.                 addEventHandler( "onClientGUIClick", buttonok, zamknijoknostaty )
  165.                 attemptedLogins = 0
  166.             end
  167.             xmlUnloadFile(xmlFile)
  168.         else
  169.             xmlFileHandler(true)
  170.         end
  171.         addEventHandler("onRequestDisplayPanel",getRootElement(),logoutHandler)
  172. end
  173. --addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),loginPanel)
  174.  
  175. function enableWideScreen (player)
  176.   if (getLocalPlayer() == player) then
  177.     guiSetVisible (wideScreenGUI,true)
  178.     guiMoveToBack (wideScreenGUI)
  179.   end
  180. end
  181.  
  182. function disableWideScreen (player)
  183.     guiSetVisible (wideScreenGUI,false)
  184. end
  185.  
  186. addEventHandler ("onClientGUIClick",getRootElement(),
  187. function(button,state,absx,absy)
  188.   if (source == wideScreenGUI) then
  189.     guiMoveToBack (wideScreenGUI)
  190.   end
  191. end)
  192.  
  193.  
  194.  
  195.  
  196.  
  197. function ustaw(name,login,playerSkin,czasOnline,dataRejstracji,ostatniaWizyta)
  198. guiSetText(stat_label,"Nick: "..name.."\nLogin: "..login.."\nSkin: "..playerSkin.."\nCzas Online: "..czasOnline.."\nData rejstracji: "..dataRejstracji.."\nData ostatniej wizyty:"..ostatniaWizyta.."")
  199.  
  200.  
  201. end
  202. addEvent("ustaw",true)
  203. addEventHandler("ustaw",getRootElement(),ustaw)
  204.  
  205.  
  206.  
  207. function pokazstaty()
  208. guiSetVisible(statystyki, true)
  209. guiSetEnabled ( buttonok, false )
  210. timer = setTimer ( guiSetEnabled, 10000, 1, buttonok, true )
  211. setTimer ( guiSetText,10000,1,buttonok,"OK")
  212. setTimer(
  213. function()
  214. if isTimer(timer) then
  215. remaining, a, b = getTimerDetails(timer)
  216. local czas = math.floor(tonumber(remaining/1000))
  217. guiSetText(buttonok, "Poczekaj ("..czas..")sek.")
  218. end
  219.     end, 1000, 11,timer,buttonok )
  220.  
  221. triggerServerEvent ("koncwe",getRootElement(),getLocalPlayer())
  222. end
  223. addEvent("ShowStaty", true)
  224. addEventHandler("ShowStaty",getRootElement(),pokazstaty)
  225.  
  226. -- LOGIN PLAYER
  227. function onClickLogin(button,state)
  228.     if(button == "left" and state == "up") then
  229.         if (source == btnLogin) then
  230.             username = guiGetText(editUsername)
  231.             password = guiGetText(editPassword)
  232.             triggerServerEvent("onRequestLogin",getLocalPlayer(),username,password,enableKickPlayer,attemptedLogins,maxLoginAttempts)
  233.             xmlFileHandler()
  234.         end
  235.     end
  236. end
  237.  
  238. function zamknijoknostaty()
  239. if source == buttonok then
  240. guiSetVisible(statystyki, false)
  241. showCursor(false)
  242. setCameraTarget ( getLocalPlayer() )
  243. disableWideScreen (player)
  244. end
  245. end
  246.  
  247. -- REGISTER PLAYER
  248. function onClickRegisterConfirm(button,state)
  249.     if(button == "left" and state == "up") then
  250.         if (source == btnConfirmRegistration) then
  251.             username = guiGetText(editRegistrationUsername)
  252.             password = guiGetText(editRegistrationPassword)
  253.             passwordConfirm = guiGetText(editRegistrationRepeatPassword)
  254.             triggerServerEvent("onRequestRegister",getLocalPlayer(),username,password,passwordConfirm)
  255.         end
  256.     end
  257. end
  258.  
  259.  
  260.  
  261. -- Open registration window
  262. function onClickRegisterToggle(button,state)
  263.     if(button == "left" and state == "up") then
  264.         if (source == btnToggleRegister) then
  265.             guiSetVisible(registerWindow, true)
  266.             guiBringToFront(registerWindow)
  267.             guiSetInputEnabled(true)
  268.             showCursor(true)
  269.         end
  270.     end
  271. end
  272.  
  273.  
  274.  
  275. -- Cancel registration
  276. function onClickCancel(button,state)
  277.     if(button == "left" and state == "up") then
  278.         if (source == btnCancel) then
  279.             guiSetVisible(mainWindow, true)
  280.             guiSetVisible(registerWindow, false)
  281.             guiSetInputEnabled(true)
  282.             showCursor(true)
  283.         end
  284.     end
  285. end
  286.  
  287.  
  288.  
  289.  
  290.  
  291. -- Show login window
  292. function showLoginWindow()
  293.     guiSetVisible(mainWindow, true)
  294.     guiSetVisible(registerWindow, false)
  295.     guiSetInputEnabled(true)
  296.     enableWideScreen()
  297.     showCursor(true)
  298. end
  299. addEvent("showLoginWindow", true)
  300. addEventHandler("showLoginWindow",getRootElement(),showLoginWindow)
  301.  
  302.  
  303.  
  304. -- Hide login window
  305. function hideLoginWindow()
  306.     guiSetInputEnabled(false)
  307.     guiSetVisible(mainWindow, false)
  308.     guiSetVisible(registerWindow, false)
  309.     if blackLoginScreen == true then
  310.          setCameraMatrix(-1798.4619140625,890.6220703125,78.623817443848,-1775.4619140625,918.6220703125,24.623817443848,0,70)
  311.     end
  312.     setCameraMatrix(-1798.4619140625,890.6220703125,78.623817443848,-1775.4619140625,918.6220703125,24.623817443848,0,70)
  313. end
  314. addEvent("hideLoginWindow", true)
  315. addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)
  316.  
  317.  
  318.  
  319. -- Hide register window
  320. function hideRegisterWindow()
  321.     guiSetInputEnabled(true)
  322.     guiSetVisible(mainWindow, true)
  323.     guiSetVisible(registerWindow, false)
  324.     showCursor(true)
  325. end
  326. addEvent("hideRegisterWindow", true)
  327. addEventHandler("hideRegisterWindow", getRootElement(), hideRegisterWindow)
  328.  
  329.  
  330. -- Show login panel when a player logs out if 'dissalowLogout' is set to TRUE
  331. function logoutHandler()
  332.     if (disallowLogout == true) then
  333.         loginPanel()
  334.         setTimer(outputChatBox,600,1,"#0000FF* #FFFFFFWarning! You have logged out. Please login again.",255,255,255,true)
  335.     end
  336. end
  337.  
  338. -----------------------------------------------------------------------------------------------|
  339.  
  340. -- XML File Handler
  341. function xmlFileHandler(gReturn)
  342.     local xmlFile = xmlLoadFile(xmlFileName)
  343.     if not xmlFile then
  344.         xmlFile = xmlCreateFile(xmlFileName,"settings")
  345.         xmlNodeSetAttribute(xmlFile,"autologin","false")
  346.     end
  347.     xmlNodeSetAttribute(xmlFile,"username",tostring(guiGetText(editUsername)))
  348.     xmlNodeSetAttribute(xmlFile,"password",tostring(guiGetText(editPassword)))
  349.     xmlSaveFile(xmlFile)
  350.     xmlUnloadFile(xmlFile)
  351.     if (gReturn) then
  352.         if (gReturn == true) then
  353.             loginPanel()
  354.         else
  355.             return
  356.         end
  357.     end
  358. end
  359.  
  360.  
  361. -- Increase Login Attepts
  362. function increaseAttempts()
  363.     attemptedLogins = attemptedLogins+1
  364. end
  365.  
  366. ------------------------------------------------------------------------------------------------------------------------------
  367.  
  368.  
  369. infoWnd = guiCreateWindow(0.3773,0.4824,0.2727,0.2393,"Informacja",true)
  370. buttzamknijboxlogin = guiCreateButton(0.2865,0.7796,0.3782,0.1388,"OK",true,infoWnd)
  371. img = guiCreateStaticImage(0.0831,0.2857,0.3037,0.3429,"info.png",true,infoWnd)
  372. login = guiCreateMemo(0.4212,0.1143,0.4814,0.6204,"",true,infoWnd)
  373. guiMemoSetReadOnly(login,true)
  374. guiSetVisible(infoWnd, false)
  375. showCursor(false)
  376.  
  377. function logininfo(co)
  378. guiSetVisible(infoWnd, true)
  379. guiSetText(login, tostring(co))
  380. showCursor(true)
  381. guiBringToFront ( infoWnd )
  382. end
  383.  
  384. function zamknijlogin_panel(player)
  385. if source == buttzamknijboxlogin then
  386. guiSetVisible(infoWnd, false)
  387. end
  388. end
  389. addEventHandler( "onClientGUIClick", buttzamknijboxlogin, zamknijlogin_panel )
  390.  
  391. addEvent("msgBoxLogin", true)
  392. addEventHandler("msgBoxLogin", getRootElement(), logininfo)
  393. ----------------------------------------------------------------------------
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421. local gR = getRootElement()
  422. local gRR = getResourceRootElement( getThisResource() )
  423. local gMe = getLocalPlayer()
  424.  
  425. local plane = createObject(1681,3660,-850,350,0,0,0)
  426.  
  427. setElementDimension( plane, 1 )
  428.  
  429. function showintro()
  430.   showPlayerHudComponent( "radar", false )
  431.   fadeCamera( false, 0.5, 0, 0, 0 )
  432.   setElementDimension( gMe,1 )
  433.   setTimer(
  434.     function ()
  435.         fadeCamera( true, 1.2, 0, 0, 0 )
  436.         moveObject( plane, 9000,-1701,-255,14.2)
  437.         setTimer(
  438.             function ()
  439.                 fadeCamera( false, 1.0, 0, 0, 0 )
  440.             end
  441.         , 7500, 1 )
  442.         addEventHandler( 'onClientPreRender', gR, updateCam1 )
  443.         setTimer(
  444.             function ()
  445.                 fadeCamera( true, 0.5, 0, 0, 0 )
  446.                 addEventHandler( 'onClientPreRender', gR, updateCam2 )
  447.                 setTimer(
  448.                     function ()
  449.  
  450.                         --addEventHandler( 'onClientPreRender', gR, updateCam2 )
  451.                         setTimer(
  452.                             function ()
  453.                                 addEventHandler( 'onClientPreRender', gR, updateCam3 )
  454.                        
  455.                                 setTimer(
  456.                                     function()
  457.                                         removeEventHandler( 'onClientPreRender', gR, updateCam1 )
  458.                                         removeEventHandler( 'onClientPreRender', gR, updateCam2 )
  459.                                         removeEventHandler( 'onClientPreRender', gR, updateCam3 )
  460.                                         setElementDimension( gMe,0 )
  461.                                         setCameraTarget( gMe, gMe )
  462.                                         showPlayerHudComponent( "radar", true )
  463.                                    
  464.                                         fadeCamera( true, 1.5, 0, 0, 0 )
  465.                                         setCameraTarget (gMe,gMe)
  466.                                     end
  467.                                 , 10500, 1 )
  468.                             end
  469.                         , 8500, 1 )
  470.                     end
  471.                 , 9000, 1 )
  472.             end
  473.         , 8000, 1 )
  474.     end
  475.   , 1000, 1 )
  476. end
  477.  
  478. addCommandHandler("intro",
  479.     function ()
  480.         showintro()
  481.     end
  482. )
  483.  
  484. function updateCam1()
  485.   local cx, cy, cz = getElementPosition( thing )
  486.   local tx, ty, tz = getElementPosition( plane )
  487.   setCameraMatrix ( cx, cy, cz, tx, ty, tz )
  488. end
  489.  
  490. function updateCam2()
  491.   local cx, cy, cz = getElementPosition( thing2 )
  492.   local tx, ty, tz = getElementPosition( thing )
  493.   setCameraMatrix ( cx, cy, cz, tx, ty, tz )
  494. end
  495.  
  496. function updateCam3()
  497.   local cx, cy, cz = getElementPosition( thing2 )
  498.   local tx, ty, tz = getElementPosition( thing )
  499.   setCameraMatrix ( cx, cy, cz, tx, ty, tz )
  500. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement