Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. local sound = playSound("intro.mp3", false, false)
  2.  
  3. local login = {button = {},window = {},edit = {},label = {}};
  4. local sW,sH = guiGetScreenSize();
  5. local theKey = "aAabdbBkcdrqCfhdD";
  6.  
  7. addEvent("dayz:updatelogin", true);
  8. addEvent("dayz:disablelogin", true);
  9.  
  10. function drawDx()
  11. dxDrawImage(0, 0, sW, sH, "background.jpg");
  12. end
  13. addEventHandler("onClientRender", root, drawDx);
  14.  
  15. addEventHandler("onClientResourceStart", resourceRoot, function()
  16. login.window[1] = guiCreateGridList((sW-299)/2, (sH-204)/2, 299, 204, false);
  17. login.label[1] = guiCreateLabel(16, 15, 266, 35, "MTA-DayZ", false, login.window[1]);
  18. login.label[2] = guiCreateLabel(16, 55, 102, 30, "Login", false, login.window[1]);
  19. login.label[3] = guiCreateLabel(16, 94, 102, 30, "Password", false, login.window[1]);
  20. login.edit[1] = guiCreateEdit(126, 60, 156, 25, "", false, login.window[1]);
  21. login.edit[2] = guiCreateEdit(126, 99, 156, 25, "", false, login.window[1]);
  22. login.button[1] = guiCreateButton(17, 146, 111, 44, "Login", false, login.window[1]);
  23. login.button[2] = guiCreateButton(171, 146, 111, 44, "Register", false, login.window[1]);
  24. guiSetAlpha(login.window[1], 0.7);
  25. guiEditSetMasked(login.edit[2], true);
  26. for i = 1, 3 do
  27. guiSetFont(login.label[i], "default-bold-small");
  28. guiLabelSetHorizontalAlign(login.label[i], "center", false);
  29. guiLabelSetVerticalAlign(login.label[i], "center");
  30. if (i ~= 3) then
  31. guiSetFont(login.button[i], "default-bold-small");
  32. end
  33. end
  34. showCursor(true);
  35. showChat(false);
  36. local xml = xmlLoadFile("udata.xml");
  37. if not xml then
  38. xml = xmlCreateFile("udata.xml", "acc");
  39. xmlNodeSetAttribute(xml, "user", "");
  40. xmlNodeSetAttribute(xml, "pass", "");
  41. xmlSaveFile(xml);
  42. end
  43. guiSetText(login.edit[1], tostring(xmlNodeGetAttribute(xml, "user")));
  44. guiSetText(login.edit[2], teaDecode(tostring(xmlNodeGetAttribute(xml, "pass")), theKey));
  45. xmlUnloadFile(xml);
  46. end);
  47.  
  48. addEventHandler("onClientGUIClick", resourceRoot, function()
  49. if (source == login.button[1]) then
  50. local username = guiGetText(login.edit[1]);
  51. local password = guiGetText(login.edit[2]);
  52. if (username ~= "" and password ~= "") then
  53. saveLoginInfo(username, password);
  54. triggerServerEvent("dayz:loginplayer", localPlayer, username, password);
  55. else
  56. guiLabelSetColor(login.label[1], 255, 0, 0);
  57. guiSetText(login.label[1], "Proszę wypełnić wszystkie pola!!");
  58. end
  59. elseif (source == login.button[2]) then
  60. local username = guiGetText(login.edit[1]);
  61. local password = guiGetText(login.edit[2]);
  62. if (username ~= "" and password ~= "") then
  63. saveLoginInfo(username, password);
  64. triggerServerEvent("dayz:registerplayer", localPlayer, username, password);
  65. else
  66. guiLabelSetColor(login.label[1], 255, 0, 0);
  67. guiSetText(login.label[1], "Proszę wypełnić wszystkie pola!!");
  68. end
  69. end
  70. end);
  71.  
  72. addEventHandler("dayz:updatelogin", root, function(text)
  73. guiSetText(login.label[1], text);
  74. guiLabelSetColor(login.label[1], 255, 0, 0);
  75. end);
  76.  
  77. addEventHandler("dayz:disablelogin", root, function()
  78. guiSetVisible(login.window[1], false);
  79. removeEventHandler("onClientRender", root, drawDx);
  80. showCursor(false);
  81. showChat(true);
  82. end);
  83.  
  84. function saveLoginInfo(username, password)
  85. local xml = xmlLoadFile("udata.xml");
  86. if not xml then
  87. xml = xmlCreateFile("udata.xml", "acc");
  88. end
  89. xmlNodeSetAttribute(xml, "user", username);
  90. xmlNodeSetAttribute(xml, "pass", teaEncode(password, theKey));
  91. xmlSaveFile(xml);
  92. xmlUnloadFile(xml);
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement