Jump to content

[HELP] Login panel


Recommended Posts

 

A kérdés a következő lenne, hogy birnék az accountData-ba a játékos által beírt szöveget megadni. Benne van a scriptben amit Worthless is csinált (direkt letöltöttem és bemásoltam azt a részt), de úgy sem jó.

local sx, sy = guiGetScreenSize();
local relX, relY = sx/1680, sy/1050;

local isPanelVisible = true;
local panelState = "1"; -- 1 = Bejelentkezés, 2 = Regisztráció, 3 = Karakter létrehozás
showCursor(true);
setPlayerHudComponentVisible("all", false);
showChat(true);

local panelPosition = {0.79, 0.25};
local buttonColors = {
	[1] = tocolor(210, 155, 65, 150);
	[2] = tocolor(207, 83, 52, 150);
};

local headerText = "";

local accountData = { -- Beviteli mezők tartalma
	[1] = { -- Bejelentkezés
		[1] = "", -- Felhasználónév
		[2] = "", -- Jelszó
	},
	[2] = { -- Regisztráció
		[1] = "", -- Felhasználónév
		[2] = "", -- Jelszó
		[3] = "", -- E-Mail
	},
};
local dataPointer = false;

addEventHandler("onClientRender", root, function()
	dxDrawRectangle( sx*panelPosition[1], sy*panelPosition[2], relX*300, relY*500, tocolor( 0, 0, 0, 150 ) );

	dxDrawRectangle( sx*panelPosition[1], sy*panelPosition[2], relX*5, relY*500, tocolor( 210, 155, 65, 255 ) );

	dxDrawText("ViolantGaming", sx*(panelPosition[1]+0.08), sy*(panelPosition[2]+0.005), sx*(panelPosition[1]+0.1), sy*(panelPosition[2]+0.05), tocolor( 210, 155, 65, 255 ), relX*2, relY*2, "default-bold", "center");

	dxDrawText(headerText, sx*(panelPosition[1]+0.08), sy*(panelPosition[2]+0.03), sx*(panelPosition[1]+0.1), sy*(panelPosition[2]+0.6), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");


	-- Login felület
	if (panelState == "1") then

		headerText = "Bejelentkezés";
		-- Felhasználónév
		dxDrawText("Felhasználónév", sx*(panelPosition[1]+0.08), sy*(panelPosition[2]+0.075), sx*(panelPosition[1]+0.1), sy*(panelPosition[2]+0.07), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center"); 
		--dxDrawRectangle( sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.2), relX*275, relY*50, tocolor( 255, 255, 255, 255));
		dxDrawRectangle( sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.1), relX*275, relY*50, tocolor( 95, 95, 95, 150 ) );

		-- // Felső mező \\ --
		if (panelState == "1") then -- Bejelentkező ablak
			if (dataPointer == 1) then -- Mező kijelölve
				dxDrawText(accountData[1][1].."|", sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.11), sx*(panelPosition[1]+0.17), sy*(panelPosition[2]+0.9),tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
			else
				if (accountData == "") then
					
				else
					text = string.rep("*", string.len(accountData[2][2]));
					dxDrawText(accountData[1][1], sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.11), sx*(panelPosition[1]+0.17), sy*(panelPosition[2]+0.9), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
				end
			end
		end

		dxDrawRectangle( sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.2), relX*275, relY*50, tocolor( 95, 95, 95, 150 ) );
		dxDrawText("Jelszó", sx*(panelPosition[1]+0.08), sy*(panelPosition[2]+0.175), sx*(panelPosition[1]+0.1), sy*(panelPosition[2]+0.07), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
		-- // Bejelentkezés : Jelszó \\ --
		if (panelState == "1") then -- Regisztrációs ablak
			local text;
			if (dataPointer == 2) then -- Mező kijelölve
				text = string.rep("*", string.len(accountData[1][2]));
				dxDrawText(accountData[1][2].."|", sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.21), sx*(panelPosition[1]+0.17), sy*(panelPosition[2]+0.9), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
			else
				if (accountData == "") then
					
				else
					dxDrawText(accountData[1][2], sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.21), sx*(panelPosition[1]+0.17), sy*(panelPosition[2]+0.9), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
				end
			end
		end

		dxDrawRectangle( sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.34), relX*275, relY*50, buttonColors[1]); -- Bejelentkező gomb
		dxDrawRectangle( sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.40), relX*275, relY*50, buttonColors[2]); -- Regisztrációs gomb
		dxDrawText("Bejelentkezés", sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.35), sx*(panelPosition[1]+0.17), sy*(panelPosition[2]+0.9), tocolor( 255, 255, 255, 255 ), relX*2, relY*2, "default-bold", "center");
		dxDrawText("Regisztráció", sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.41), sx*(panelPosition[1]+0.17), sy*(panelPosition[2]+0.9), tocolor( 255, 255, 255, 255 ), relX*2, relY*2, "default-bold", "center");

	elseif (panelState == "2") then

		headerText = "Regisztráció";
		-- Felhasználónév
		dxDrawText("Felhasználónév", sx*(panelPosition[1]+0.08), sy*(panelPosition[2]+0.075), sx*(panelPosition[1]+0.1), sy*(panelPosition[2]+0.07), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center"); 
		dxDrawRectangle( sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.1), relX*275, relY*50, tocolor( 95, 95, 95, 150 ) );
		-- // Felhasználónév : Regisztráció \\ -- 
		if (panelState == "2") then -- Regisztrációs ablak
			if (dataPointer == 1) then -- Mező kijelölve
				dxDrawText(accountData[2][1].."|", sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.11), sx*(panelPosition[1]+0.17), sy*(panelPosition[2]+0.9), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
			else
				if (accountData == "") then
					
				else
					dxDrawText(accountData[2][1], sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.11), sx*(panelPosition[1]+0.17), sy*(panelPosition[2]+0.9), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
				end
			end
		end

		-- // Regisztrációs ablak : Jelszó \\ --
		dxDrawRectangle( sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.18), relX*275, relY*50, tocolor( 95, 95, 95, 150 ) );
		dxDrawText("Jelszó", sx*(panelPosition[1]+0.08), sy*(panelPosition[2]+0.16), sx*(panelPosition[1]+0.1), sy*(panelPosition[2]+0.07), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
		if (panelState == "2") then -- Regisztrációs ablak
			local text;
			if (dataPointer == 2) then -- Mező kijelölve
				text = string.rep("*", string.len(accountData[2][2]));
				dxDrawText(text.."|", sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.19), sx*(panelPosition[1]+0.17), sy*(panelPosition[2]+0.9), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
			else
				if (accountData == "") then
					
				else
					text = string.rep("*", string.len(accountData[2][2]));
					dxDrawText(text, sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.19), sx*(panelPosition[1]+0.17), sy*(panelPosition[2]+0.9), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
				end
			end
		end

		dxDrawRectangle( sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.26), relX*275, relY*50, tocolor( 95, 95, 95, 150 ) );
		dxDrawText("E-Mail", sx*(panelPosition[1]+0.08), sy*(panelPosition[2]+0.24), sx*(panelPosition[1]+0.1), sy*(panelPosition[2]+0.07), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
		if (panelState == "2") then -- Regisztrációs ablak
			if (dataPointer == 3) then -- Mező kijelölve
				dxDrawText(accountData[2][3].."|", sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.27), sx*(panelPosition[1]+0.17), sy*(panelPosition[2]+0.9), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
			else
				if (accountData == "") then
					
				else
					dxDrawText(accountData[2][3], sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.27), sx*(panelPosition[1]+0.17), sy*(panelPosition[2]+0.9), tocolor( 255, 255, 255, 255 ), relX*1.5, relY*1.5, "default-bold", "center");
				end
			end
		end
	
		dxDrawRectangle( sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.34), relX*275, relY*50, buttonColors[1]); -- Regisztrációs gomb
		dxDrawRectangle( sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.40), relX*275, relY*50, buttonColors[2]); -- Vissza gomb
		dxDrawText("Regisztráció", sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.35), sx*(panelPosition[1]+0.175), sy*(panelPosition[2]+0.34), tocolor( 255, 255, 255, 255 ), relX*2, relY*2, "default-bold", "center");
		dxDrawText("Visszalépés", sx*(panelPosition[1]+0.01), sy*(panelPosition[2]+0.41), sx*(panelPosition[1]+0.175), sy*(panelPosition[2]+0.34), tocolor( 255, 255, 255, 255 ), relX*2, relY*2, "default-bold", "center");
	
	end
end);

addEventHandler("onClientCursorMove", root,
	function (cX, cY)
		if (isPanelVisible) then

			if ( (cX >= panelPosition[1]+0.01) and (cY >= panelPosition[2]+0.34) and (cX <= panelPosition[1]+0.175) and (cY <= panelPosition[2]+0.39) ) then
				-- Gombon van a kurzor
				buttonColors[1] = tocolor(210, 155, 65, 255);
			else
				-- Nincs a gombon a kurzor
				buttonColors[1] = tocolor(210, 155, 65, 150);
			end

			if ( (cX >= panelPosition[1]+0.01) and (cY >= panelPosition[2]+0.40) and (cX <= panelPosition[1]+0.175) and (cY <= panelPosition[2]+0.45) ) then
				-- Gombon van a kurzor
				buttonColors[2] = tocolor(207, 83, 52, 255);
			else
				-- Nincs a gombon a kurzor
				buttonColors[2] = tocolor(207, 83, 52, 150);
			end

		end
end);

addEventHandler("onClientClick", root,
	function(button, state)

		if (isPanelVisible) then

			local cX, cY = getCursorPosition();

			if ( ( button == "left" ) and ( state == "down" ) ) then

				if (panelState == "1") then
				
					if ( (cX >= panelPosition[1]+0.01) and (cY >= panelPosition[2]+0.1) and (cX <= panelPosition[1]+0.175) and (cY <= panelPosition[2]+0.15) ) then
						dataPointer = 1;
					end

					if ( (cX >= panelPosition[1]+0.01) and (cY >= panelPosition[2]+0.2) and (cX <= panelPosition[1]+0.175) and (cY <= panelPosition[2]+0.25) ) then
						dataPointer = 2;
					end

				elseif (panelState == "2") then
					if ( (cX >= panelPosition[1]+0.01) and (cY >= panelPosition[2]+0.1) and (cX <= panelPosition[1]+0.175) and (cY <= panelPosition[2]+0.15) ) then
						dataPointer = 1;
					end

					if ( (cX >= panelPosition[1]+0.01) and (cY >= panelPosition[2]+0.16) and (cX <= panelPosition[1]+0.175) and (cY <= panelPosition[2]+0.22) ) then
						dataPointer = 2;
					end

					if ( (cX >= panelPosition[1]+0.01) and (cY >= panelPosition[2]+0.27) and (cX <= panelPosition[1]+0.175) and (cY <= panelPosition[2]+0.31) ) then
						dataPointer = 3;
					end
				end

				if ( (cX >= panelPosition[1]+0.01) and (cY >= panelPosition[2]+0.34) and (cX <= panelPosition[1]+0.175) and (cY <= panelPosition[2]+0.39) ) then

					if ( panelState == "1" ) then
						execLogin();
					elseif ( panelState == "2" ) then
						execRegister();
					end
				end

				if ( (cX >= panelPosition[1]+0.01) and (cY >= panelPosition[2]+0.40) and (cX <= panelPosition[1]+0.175) and (cY <= panelPosition[2]+0.45) ) then
					if ( panelState == "1" ) then
						panelState = "2";
					elseif ( panelState == "2" ) then
						panelState = "1";
					end
				end
			end
		end
	end
);

addEventHandler("onClientCharacter", resourceRoot,
	function(char)
		if (isPanelVisible == true) then
			if (dataPointer > 0) then
				accountData[panelState][dataPointer] = accountData[panelState][dataPointer][char]
			end
		end
	end
);

function execLogin()
	outputChatBox("Bejelentkező gomb működik!");
end
function execRegister()
	outputChatBox("Regisztrációs gomb működik!");
end
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...