Wysłany: 2025-04-05, 21:52
MjuziQu
Wiek: 21 Na forum: 448 dni Posty: 5
Potrzebuje przekonwertować dxDrawText "Login" oraz dxDrawText "Hasło" (tak jak na załączonym obrazku) tak aby dało się wpisywać text login,hasło
Kod: s=Vector2(guiGetScreenSize())
function isMouseInPosition (x,y,width,height)
if (not isCursorShowing()) then
return false
end
local cx, cy = getCursorPosition ()
local cx, cy = (cx*s.x), (cy*s.y)
return ((cx >= x and cx<=x+width) and (cy>y and cy<= y+height))
end
switch="off.png"
el={
["bg"]={0,0,1920,1080},
["blogin"]={832, 611, 255, 41},
["brejestracja"]={832, 664, 255, 40},
["txtlogin"]={840, 611, 1077, 651},
["txtrejestracja"]={840, 664, 1077, 704},
["txtloginwpis"]={860, 511, 1077, 543},
["txtrejestrwpis"]={860, 557, 1077, 589},
}
addEventHandler("onClientRender", root,function()
if open then
dxDrawImage(el["bg"][1], el["bg"][2], el["bg"][3], el["bg"][4], ":loginscreen/images/loginscreen.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawImage(1050, 594, 33, 15, ":loginscreen/images/"..switch, 0, 0, 0, tocolor(255, 255, 255, 255), false)
if isMouseInPosition (el["blogin"][1], el["blogin"][2], el["blogin"][3], el["blogin"][4]) then
dxDrawImage(el["blogin"][1], el["blogin"][2], el["blogin"][3], el["blogin"][4], ":loginscreen/images/lb.png", 0, 0, 0, tocolor(255, 255, 255, 200), false)
else
dxDrawImage(el["blogin"][1], el["blogin"][2], el["blogin"][3], el["blogin"][4], ":loginscreen/images/lb.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end
if isMouseInPosition (el["brejestracja"][1], el["brejestracja"][2], el["brejestracja"][3], el["brejestracja"][4]) then
dxDrawImage(el["brejestracja"][1], el["brejestracja"][2], el["brejestracja"][3], el["brejestracja"][4], ":loginscreen/images/rb.png", 0, 0, 0, tocolor(255, 255, 255, 200), false)
else
dxDrawImage(el["brejestracja"][1], el["brejestracja"][2], el["brejestracja"][3], el["brejestracja"][4], ":loginscreen/images/rb.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end
dxDrawText("LOGIN", el["txtlogin"][1], el["txtlogin"][2], el["txtlogin"][3], el["txtlogin"][4], tocolor(255, 255, 255, 255), 1.40, "default-bold", "center", "center", false, false, false, false, false)
dxDrawText("REJESTRACJA", el["txtrejestracja"][1], el["txtrejestracja"][2], el["txtrejestracja"][3], el["txtrejestracja"][4], tocolor(255, 255, 255, 255), 1.40, "default-bold", "center", "center", false, false, false, false, false)
dxDrawText("Login", el["txtloginwpis"][1], el["txtloginwpis"][2], el["txtloginwpis"][3], el["txtloginwpis"][4], tocolor(255, 255, 255, 255), 1.40, "default-bold", "left", "center", false, false, false, false, false)
dxDrawText("Hasło", el["txtrejestrwpis"][1], el["txtrejestrwpis"][2], el["txtrejestrwpis"][3], el["txtrejestrwpis"][4], tocolor(255, 255, 255, 255), 1.40, "default-bold", "left", "center", false, false, false, false, false)
end
end)
addEventHandler("onClientResourceStart",resourceRoot,function()
open = true
showCursor(true)
end)
addEventHandler("onClientResourceStart",resourceRoot,function()
showCursor(true)
end)
addEventHandler("onClientResourceStop",resourceRoot,function()
showCursor(true)
end)
addEventHandler("onClientClick",root,function(b,state)
if b == "left" and state == "up" then
if isMouseInPosition(1050, 594, 33, 15) then
if switch == "off.png" then
switch = "on.png"
else
switch = "off.png"
end
end
end
end)
Wysłany: 2025-04-27, 11:31
Ondzio
Wiek: 25 Na forum: 1488 dni Posty: 11
Nick w MP: Ondzio.
Piwa : 3
Dodaj zmienne:
Kod: local loginText = ""
local passwordText = ""
local activeInput = nil -- "login" lub "password"
Zamiast stałego napisu "Login" i "Hasło" robimy:
Kod: dxDrawText(loginText == "" and "Login" or loginText, el["txtloginwpis"][1], el["txtloginwpis"][2], el["txtloginwpis"][3], el["txtloginwpis"][4], tocolor(255, 255, 255, 255), 1.40, "default-bold", "left", "center", false, false, false, false, false)
dxDrawText(passwordText == "" and "Hasło" or string.rep("*", #passwordText), el["txtrejestrwpis"][1], el["txtrejestrwpis"][2], el["txtrejestrwpis"][3], el["txtrejestrwpis"][4], tocolor(255, 255, 255, 255), 1.40, "default-bold", "left", "center", false, false, false, false, false)
Dodajemy do oneClientClick:
Kod: addEventHandler("onClientClick", root, function(b, state)
if b == "left" and state == "up" then
if isMouseInPosition(el["txtloginwpis"][1], el["txtloginwpis"][2], el["txtloginwpis"][3] - el["txtloginwpis"][1], el["txtloginwpis"][4] - el["txtloginwpis"][2]) then
activeInput = "login"
elseif isMouseInPosition(el["txtrejestrwpis"][1], el["txtrejestrwpis"][2], el["txtrejestrwpis"][3] - el["txtrejestrwpis"][1], el["txtrejestrwpis"][4] - el["txtrejestrwpis"][2]) then
activeInput = "password"
else
activeInput = nil
end
end
end)
Dodaj:
Kod: addEventHandler("onClientCharacter", root, function(character)
if open and activeInput then
if activeInput == "login" then
loginText = loginText .. character
elseif activeInput == "password" then
passwordText = passwordText .. character
end
end
end)
Teraz obsługa backspace:
Kod: addEventHandler("onClientKey", root, function(button, press)
if not press then return end
if open and activeInput then
if button == "backspace" then
if activeInput == "login" then
loginText = string.sub(loginText, 1, -2)
elseif activeInput == "password" then
passwordText = string.sub(passwordText, 1, -2)
end
end
end
end)
Efekt:
Klikasz na napis „Login” lub „Hasło” ➔ aktywujesz pisanie w tym polu,
Możesz wpisywać tekst,
W haśle automatycznie zamienia znaki na *,
Backspace działa i kasuje wpisane znaki.
Gdyby coś było nie tak napisz a przygotuje Ci cały kompletny plik
Tagi: jak :: dostosować :: panel :: logowania :: (pilne!)
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: