Advertisement
Guest User

Untitled

a guest
Jan 1st, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. local login = {button = {},window = {}, staticimage = {},edit = {},label = {}};
  2. local sW,sH = guiGetScreenSize();
  3. local theKey = "aAabdbBkcdrqCfhdD";
  4. local sound = playSound("sound.mp3")
  5. setSoundVolume(sound, 0.5)
  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. local screenW, screenH = guiGetScreenSize()
  17. login.window[1] = guiCreateStaticImage((screenW - 394) / 2, (screenH - 456) / 2, 394, 456,"bg.png",false);
  18. login.label[4] = guiCreateStaticImage(-85, -60, 580, 400, "logo.png", false, login.window[1]);
  19. login.label[1] = guiCreateLabel(7, 186, 377, 15, "BlackProject.com", false, login.window[1]);
  20. login.label[2] = guiCreateLabel(7, 211, 377, 15, "Username", false, login.window[1]);
  21. login.label[3] = guiCreateLabel(7, 271, 377, 15, "Password", false, login.window[1]);
  22. login.edit[1] = guiCreateEdit(7, 230, 377, 36, "", false, login.window[1]);
  23. login.edit[2] = guiCreateEdit(7, 291, 377, 36, "", false, login.window[1]);
  24. login.button[1] = guiCreateButton(7, 342, 377, 47, "Login", false, login.window[1]);
  25. login.button[2] = guiCreateButton(7, 399, 377, 47, "Register", false, login.window[1]);
  26. guiSetAlpha(login.window[1], 0.9);
  27. guiEditSetMasked(login.edit[2], true);
  28. for i = 1, 3 do
  29. guiSetFont(login.label[i], "default-bold-small");
  30. guiLabelSetHorizontalAlign(login.label[i], "center", false);
  31. guiLabelSetVerticalAlign(login.label[i], "center");
  32. if (i ~= 3) then
  33. guiSetFont(login.button[i], "default-bold-small");
  34. end
  35. end
  36. showCursor(true);
  37. showChat(false);
  38. local xml = xmlLoadFile("udata.xml");
  39. if not xml then
  40. xml = xmlCreateFile("udata.xml", "acc");
  41. xmlNodeSetAttribute(xml, "user", "");
  42. xmlNodeSetAttribute(xml, "pass", "");
  43. xmlSaveFile(xml);
  44. end
  45. guiSetText(login.edit[1], tostring(xmlNodeGetAttribute(xml, "user")));
  46. guiSetText(login.edit[2], teaDecode(tostring(xmlNodeGetAttribute(xml, "pass")), theKey));
  47. xmlUnloadFile(xml);
  48. end);
  49.  
  50. addEventHandler("onClientGUIClick", resourceRoot, function()
  51. if (source == login.button[1]) then
  52. local username = guiGetText(login.edit[1]);
  53. local password = guiGetText(login.edit[2]);
  54. if (username ~= "" and password ~= "") then
  55. saveLoginInfo(username, password);
  56. triggerServerEvent("dayz:loginplayer", localPlayer, username, password);
  57. else
  58. guiLabelSetColor(login.label[1], 255, 0, 0);
  59. guiSetText(login.label[1], "Please fill all fields!");
  60. end
  61. elseif (source == login.button[2]) then
  62. local username = guiGetText(login.edit[1]);
  63. local password = guiGetText(login.edit[2]);
  64. if (username ~= "" and password ~= "") then
  65. saveLoginInfo(username, password);
  66. triggerServerEvent("dayz:registerplayer", localPlayer, username, password);
  67. else
  68. guiLabelSetColor(login.label[1], 255, 0, 0);
  69. guiSetText(login.label[1], "Please fill all fields!");
  70. end
  71. end
  72. end);
  73.  
  74. addEventHandler("dayz:updatelogin", root, function(text)
  75. guiSetText(login.label[1], text);
  76. guiLabelSetColor(login.label[1], 255, 0, 0);
  77. end);
  78.  
  79. addEventHandler("dayz:disablelogin", root, function()
  80. stopSound(sound)
  81. guiSetVisible(login.window[1], false);
  82. removeEventHandler("onClientRender", root, drawDx);
  83. showCursor(false);
  84. showChat(true);
  85. end);
  86.  
  87. function saveLoginInfo(username, password)
  88. local xml = xmlLoadFile("udata.xml");
  89. if not xml then
  90. xml = xmlCreateFile("udata.xml", "acc");
  91. end
  92. xmlNodeSetAttribute(xml, "user", username);
  93. xmlNodeSetAttribute(xml, "pass", teaEncode(password, theKey));
  94. xmlSaveFile(xml);
  95. xmlUnloadFile(xml);
  96. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement