Wysłany: 2018-04-16, 16:21
Rumper
Majster od pysa
Wiek: 15 Na forum: 3315 dni Posty: 231
Nick w MP: Rumper
Piwa : 592
Witam,bo mam taki problem ?e zrobi?em grafike do panelu logowania i za pomoc? dxDrawRectangle zrobi?em te guziki do panelu logowania,przenios?em te? klikni?cie w gui i nadal nie dzia?a.
KOD:
if getElementData ( localPlayer , "player:uid" ) then return end
local root = getRootElement ()
local resourceRoot = getResourceRootElement ( getThisResource ())
local screenWidth , screenHeight = guiGetScreenSize ()
local screenW , screenH = guiGetScreenSize ()
local blurStrength = 20
local myScreenSource = dxCreateScreenSource ( screenWidth , screenHeight )
blurShader , blurTec = dxCreateShader ( "shaders/BlurShader.fx" )
function renderblur ()
if blur == true then
dxUpdateScreenSource ( myScreenSource )
dxSetShaderValue ( blurShader , "ScreenSource" , myScreenSource );
dxSetShaderValue ( blurShader , "BlurStrength" , blurStrength );
dxSetShaderValue ( blurShader , "UVSize" , screenWidth , screenHeight );
dxDrawImage ( 0 , 0 , screenWidth , screenHeight , blurShader )
end
end
addEventHandler ( "onClientRender" , root , renderblur )
addEventHandler ( "onClientResourceStop" , resourceRoot ,
function()
if ( blurShader ) then
destroyElement ( blurShader )
blurShader = nil
end
end )
x , y = 2313.58 , 1282.80 -- my width
intro_step = math . random ( 0 , 850 )
local sx , sy = guiGetScreenSize ()
local data ={ showed = nil , button ={}, info = nil , misc = nil , }
function isMouseIn ( psx , psy , pssx , pssy , abx , aby )
if not isCursorShowing () then return end
cx , cy = getCursorPosition ()
cx , cy = cx * sx , cy * sy
if cx >= psx and cx <= psx + pssx and cy >= psy and cy <= psy + pssy then
return true , cx , cy
else
return false
end
end
local dist = 100
local angler = 0
function getPointFromDistanceRotation ( x , y , dist , angler )
local a = math . rad ( 90 - angler )
local dx = math . cos ( a ) * dist ;
local dy = math . sin ( a ) * dist ;
return x + dx , y + dy ;
end
function roundedRectangle ( x , y , w , h , color )
dxDrawRectangle ( x , y , w , h , color , false )
dxDrawRectangle ( x + 2 , y - 1 , w - 4 , 1 , color , false )
dxDrawRectangle ( x + 2 , y + h , w - 4 , 1 , color , false )
dxDrawRectangle ( x - 1 , y + 2 , 1 , h - 4 , color , false )
dxDrawRectangle ( x + w , y + 2 , 1 , h - 4 , color , false )
end
function renderLoginBox ()
blur = true
dxDrawText ( "U?ytkownik" , sx * 280 / 1024 , sy * 270 / 768 , sx * 760 / 1024 , sy * 302 / 768 , white , 1.30 , "default-bold" , "center" , "center" , false )
dxDrawText ( "Has?o" , sx *- 240 / 1024 , sy * 480 / 768 , sx * 1280 / 1024 , sy * 302 / 768 , white , 1.30 , "default-bold" , "center" , "center" , false )
dxDrawText ( "Zaloguj si?" , sx * 685 / 2024 , sy * 1015 / 1200 , sx * 230 / 2504 , sy * 45 / 768 , white , 1.00 , "default-bold" , "center" , "center" , false )
dxDrawText ( "Zarejestruj si?" , sx * 1140 / 784 , sy * 1013 / 1200 , sx * 130 / 1024 , sy * 45 / 768 , white , 1.00 , "default-bold" , "center" , "center" , false )
dxDrawImage ( 200 , 181 , 1280 , 600 , "siema.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
-- dxDrawImage ( sw / 2 - 295 , sh / 2 + 70 , 594 , 307 , "siema.png" , angle , 0 , - 120 )
dxDrawText ( "Aktuliazcje" , 270 , 348 , 504 , 381 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , "bankgothic" , "left" , "top" , false , false , true , false , false )
dxDrawText ( "Regulamin" , 1219 , 346 , 1439 , 392 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , "pricedown" , "left" , "top" , false , false , true , false , false )
dxDrawRectangle ( 731 , 525 , 159 , 62 , tocolor ( 24 , 254 , 0 , 255 ), true )
dxDrawText ( "Zaloguj sie" , 782 , 547 , 900 , 577 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , "default" , "left" , "top" , false , false , true , false , false )
dxDrawRectangle ( 731 , 606 , 159 , 52 , tocolor ( 24 , 254 , 0 , 255 ), true )
dxDrawText ( "Zarejestruj sie" , 772 , 616 , 831 , 663 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , "default" , "left" , "top" , false , false , true , false , false )
local x , y = getPointFromDistanceRotation ( 2313.58 , 1282.80 , dist , angler )
setCameraMatrix ( x , y , 107.72 + 0.9 , 2323.69 , 1285.66 , 107.72 + 0.9 )
angler =( angler + 0.1 )
end
addEventHandler ( "onClientClick" , root , function( btn , state )
if btn == "left" and state == "down" then
if isMouseIn ( sx * 731 / 2524 , sy * 525 / 1188 , sx * 159 / 1024 , sy * 62 / 768 ) and data . showed then
local login = guiGetText ( data . button [ 1 ])
local pass = guiGetText ( data . button [ 2 ])
if string . len ( login ) < 2 or string . len ( pass ) < 2 then
data . info = "Wype?nij wszystkie pola!"
return
end
triggerServerEvent ( "logging:checkAccount" , resourceRoot , login , pass )
end
if isMouseIn ( sx * 731 / 2544 , sy * 606 / 1188 , sx * 159 / 1024 , sy * 768 ) and data . showed then
local login = guiGetText ( data . button [ 1 ])
local pass = guiGetText ( data . button [ 2 ])
if string . len ( login ) > 22 or string . len ( pass ) > 22 and string . len ( login ) < 3 or string . len ( pass ) < 3 then
data . info = "Login/Has?o musz? mie? mniej ni? od 3 do 22 znak?w."
return
end
triggerServerEvent ( "logging:newAccount" , resourceRoot , login , pass )
end
end
end )
addEvent ( "logging:result" , true )
addEventHandler ( "logging:result" , resourceRoot , function( value , info )
if not info then info = "" end
if value then
data . showed = false
showZones ( data . misc )
-- Usuwamy elementy
destroyElement ( data . button [ 1 ])
destroyElement ( data . button [ 2 ])
removeEventHandler ( "onClientRender" , root , renderLoginBox )
else
data . info = tostring ( info )
setTimer (function() data . info = nil end , 3000 , 1 )
end
end )
addEventHandler ( "onClientResourceStart" , resourceRoot , function()
showChat ( false )
showCursor ( true )
fadeCamera ( true )
data . showed = true
setElementAlpha ( localPlayer , 0 )
data . misc = playSound ( "misc/intro.mp3" , true )
setSoundVolume ( data . misc , 1.0 )
setPlayerHudComponentVisible ( "all" , false )
guiSetInputMode ( "no_binds_when_editing" )
setElementData ( localPlayer , "status" , "Loguje si?" )
-- setElementData ( localPlayer , "player:logged" , false )
addEventHandler ( "onClientRender" , root , renderLoginBox )
data . button [ 1 ]= guiCreateEdit ( 0.40 , 0.40 , 0.22 , 0.04 , "" , true )
data . button [ 2 ]= guiCreateEdit ( 0.40 , 0.53 , 0.22 , 0.04 , "" , true )
guiEditSetMasked ( data . button [ 2 ], true )
end )
Wysłany: 2018-04-16, 16:47
Cobey
Wiek: 25 Na forum: 3302 dni Posty: 86
Nick w MP: Anonimowa
Piwa : 285
wpierw musisz wyskalowa?,bez skalowania nie zadziala ci to
dodaj na samej g?rze:
local sx,sy = guiGetScreenSize()
local px,py = (sx/1366),(sy/768)
gdy to dodasz,to do ka?dego kodu dodaj:
*px*py*px*py
dxDrawText("Zarejestruj sie", 772, 616, 831, 663, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
czyli po dodaniu:
dxDrawText("Zarejestruj sie", 772*px, 616*py, 831*px, 663*py, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
Podpis
13.04.2018 [*] ArtWorld
Więcej szczegółów
Wystawiono 1 piw(a):Rumper
Wysłany: 2018-04-16, 17:07
Kalizman
Wiek: 23 Na forum: 3651 dni Posty: 1394
Piwa : 4619
Linijka 96 oraz 105 to linijki w kt?rych ustawiasz po?o?enie opcji zaloguj i zarejestruj.
Powinno dzia?a?.
addEventHandler ( "onClientClick" , root , function( btn , state )
if btn == "left" and state == "down" then
if isMouseIn ( 731 , 525 , 159 , 62 ) and data . showed then
local login = guiGetText ( data . button [ 1 ])
local pass = guiGetText ( data . button [ 2 ])
if string . len ( login ) < 2 or string . len ( pass ) < 2 then
data . info = "Wype?nij wszystkie pola!"
return
end
triggerServerEvent ( "logging:checkAccount" , resourceRoot , login , pass )
end
if isMouseIn ( 731 , 606 , 159 , 52 ) and data . showed then
local login = guiGetText ( data . button [ 1 ])
local pass = guiGetText ( data . button [ 2 ])
if string . len ( login ) > 22 or string . len ( pass ) > 22 and string . len ( login ) < 3 or string . len ( pass ) < 3 then
data . info = "Login/Has?o musz? mie? mniej ni? od 3 do 22 znak?w."
return
end
triggerServerEvent ( "logging:newAccount" , resourceRoot , login , pass )
end
end
end )
Dodam tylko, ?e na Twojej rozdzielczo?ci w kt?rej grasz w MTA b?dzie ten przycisk, a na innych mniejszych lub wi?kszych b?dzie si? gdzie? indziej znajdowa?, oraz by? mo?e (r?wnie? w zale?no?ci od rozdzielczo?ci ekranu gracza) nie b?d? sprawnie dzia?a?y te dwie opcje, dlatego musisz wyskalowa? te przyciski (dxDrawRectangle) jak i napisy (dxDrawText), aby ka?dy gracz na Twoim serwerze nie mia? problem?w z panelem logowania.
Więcej szczegółów
Wystawiono 1 piw(a):Rumper
Wysłany: 2018-04-16, 17:09
Cobey
Wiek: 25 Na forum: 3302 dni Posty: 86
Nick w MP: Anonimowa
Piwa : 285
Kalizman , o tym m?wi?,najlepiej wyskalowa? wszystko;p
Podpis
13.04.2018 [*] ArtWorld
Wysłany: 2018-04-16, 21:09
Rumper
Majster od pysa
Wiek: 15 Na forum: 3315 dni Posty: 231
Nick w MP: Rumper
Piwa : 592
Dzi?ki wielkie , lec? dla was
Do zamkni?cia
Tagi: panel :: logowania
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: