Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local login = {button = {},window = {}, staticimage = {},edit = {},label = {}};
- local sW,sH = guiGetScreenSize();
- local theKey = "aAabdbBkcdrqCfhdD";
- local sound = playSound("sound.mp3")
- setSoundVolume(sound, 0.5)
- addEvent("dayz:updatelogin", true);
- addEvent("dayz:disablelogin", true);
- function drawDx()
- dxDrawImage(0, 0, sW, sH, "background.jpg");
- end
- addEventHandler("onClientRender", root, drawDx);
- addEventHandler("onClientResourceStart", resourceRoot, function()
- local screenW, screenH = guiGetScreenSize()
- login.window[1] = guiCreateStaticImage((screenW - 394) / 2, (screenH - 456) / 2, 394, 456,"bg.png",false);
- login.label[4] = guiCreateStaticImage(-85, -60, 580, 400, "logo.png", false, login.window[1]);
- login.label[1] = guiCreateLabel(7, 186, 377, 15, "BlackProject.com", false, login.window[1]);
- login.label[2] = guiCreateLabel(7, 211, 377, 15, "Username", false, login.window[1]);
- login.label[3] = guiCreateLabel(7, 271, 377, 15, "Password", false, login.window[1]);
- login.edit[1] = guiCreateEdit(7, 230, 377, 36, "", false, login.window[1]);
- login.edit[2] = guiCreateEdit(7, 291, 377, 36, "", false, login.window[1]);
- login.button[1] = guiCreateButton(7, 342, 377, 47, "Login", false, login.window[1]);
- login.button[2] = guiCreateButton(7, 399, 377, 47, "Register", false, login.window[1]);
- guiSetAlpha(login.window[1], 0.9);
- guiEditSetMasked(login.edit[2], true);
- for i = 1, 3 do
- guiSetFont(login.label[i], "default-bold-small");
- guiLabelSetHorizontalAlign(login.label[i], "center", false);
- guiLabelSetVerticalAlign(login.label[i], "center");
- if (i ~= 3) then
- guiSetFont(login.button[i], "default-bold-small");
- end
- end
- showCursor(true);
- showChat(false);
- local xml = xmlLoadFile("udata.xml");
- if not xml then
- xml = xmlCreateFile("udata.xml", "acc");
- xmlNodeSetAttribute(xml, "user", "");
- xmlNodeSetAttribute(xml, "pass", "");
- xmlSaveFile(xml);
- end
- guiSetText(login.edit[1], tostring(xmlNodeGetAttribute(xml, "user")));
- guiSetText(login.edit[2], teaDecode(tostring(xmlNodeGetAttribute(xml, "pass")), theKey));
- xmlUnloadFile(xml);
- end);
- addEventHandler("onClientGUIClick", resourceRoot, function()
- if (source == login.button[1]) then
- local username = guiGetText(login.edit[1]);
- local password = guiGetText(login.edit[2]);
- if (username ~= "" and password ~= "") then
- saveLoginInfo(username, password);
- triggerServerEvent("dayz:loginplayer", localPlayer, username, password);
- else
- guiLabelSetColor(login.label[1], 255, 0, 0);
- guiSetText(login.label[1], "Please fill all fields!");
- end
- elseif (source == login.button[2]) then
- local username = guiGetText(login.edit[1]);
- local password = guiGetText(login.edit[2]);
- if (username ~= "" and password ~= "") then
- saveLoginInfo(username, password);
- triggerServerEvent("dayz:registerplayer", localPlayer, username, password);
- else
- guiLabelSetColor(login.label[1], 255, 0, 0);
- guiSetText(login.label[1], "Please fill all fields!");
- end
- end
- end);
- addEventHandler("dayz:updatelogin", root, function(text)
- guiSetText(login.label[1], text);
- guiLabelSetColor(login.label[1], 255, 0, 0);
- end);
- addEventHandler("dayz:disablelogin", root, function()
- stopSound(sound)
- guiSetVisible(login.window[1], false);
- removeEventHandler("onClientRender", root, drawDx);
- showCursor(false);
- showChat(true);
- end);
- function saveLoginInfo(username, password)
- local xml = xmlLoadFile("udata.xml");
- if not xml then
- xml = xmlCreateFile("udata.xml", "acc");
- end
- xmlNodeSetAttribute(xml, "user", username);
- xmlNodeSetAttribute(xml, "pass", teaEncode(password, theKey));
- xmlSaveFile(xml);
- xmlUnloadFile(xml);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement