Fl!k
Wiek: 26 Na forum: 3592 dni Posty: 162
Piwa : 18
Witam posiadam problem z logowaniem poniewa? loguje sie wszysko okej ale gdy sie zaloguje i wybiore spawn to mnie nie tepa i mam czarny ekran (w konsoli nie ma ?adnych b??d?w)
client.lua
--[[
Developers :
Query ( darecky02 @ gmail . com )
Resource : ac - logowanie
Corypight ( c ) 2018 Query
Note ( PL ): Nie mo ? esz kopiowa ? i udost ? pnia ? tego kodu bez mojej zgody .
Zasoby zezwolone na u ? ycie dla serwera AttractiveRPG i autora zasobu - Query . Nie stosowanie si ? do notki w zasobie mo ? e sko ? czy ? si ?
procedur ? s ? dow ?.
]]
-- tu sie zaczyna powolutku kod
if getElementData ( localPlayer , "player:uid" ) then return end
local tick222 = getTickCount ()
editBox = {}
editBox . __index = editBox
editBox . instances = {}
sx , sy = guiGetScreenSize ()
x , y = ( sx / 1366 ), ( sy / 768 )
local root = getRootElement ()
local resourceRoot = getResourceRootElement ( getThisResource ())
local screenWidth , screenHeight = guiGetScreenSize ()
local sw , sh = guiGetScreenSize ()
local w , h =( sw / 1680 ), ( sh / 1050 )
local font = dxCreateFont ( "f.ttf" , 12 * w )
local fontt = dxCreateFont ( "f.ttf" , 10 * w )
local font2 = dxCreateFont ( "f.ttf" , 23 * w )
local tick = getTickCount ()
local logo = false
local reg = false
local zmiana = false
local sx , sy = guiGetScreenSize ()
local data ={ showed = nil , button ={}, info = nil }
local miejscaspawn ={
{ "Spawn urz?d" , 1129.01 , - 1488.70 , 22.77 },
{ "Przechowalnia" , 1021.95 , - 1344.72 , 13.55 },
}
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 sm = {}
sm . moov = 0
sm . object1 , sm . object2 = nil , nil
local function removeCamHandler ()
if( sm . moov == 1 ) then
sm . moov = 0
end
end
local function camRender ()
if ( sm . moov == 1 ) then
local x1 , y1 , z1 = getElementPosition ( sm . object1 )
local x2 , y2 , z2 = getElementPosition ( sm . object2 )
setCameraMatrix ( x1 , y1 , z1 , x2 , y2 , z2 )
end
end
addEventHandler ( "onClientPreRender" , root , camRender )
function smoothMoveCamera ( x1 , y1 , z1 , x1t , y1t , z1t , x2 , y2 , z2 , x2t , y2t , z2t , time )
if( sm . moov == 1 ) then return false end
sm . object1 = createObject ( 1337 , x1 , y1 , z1 )
sm . object2 = createObject ( 1337 , x1t , y1t , z1t )
setElementAlpha ( sm . object1 , 0 )
setElementAlpha ( sm . object2 , 0 )
setObjectScale ( sm . object1 , 0.01 )
setObjectScale ( sm . object2 , 0.01 )
moveObject ( sm . object1 , time , x2 , y2 , z2 , 0 , 0 , 0 , "InOutQuad" )
moveObject ( sm . object2 , time , x2t , y2t , z2t , 0 , 0 , 0 , "InOutQuad" )
sm . moov = 1
setTimer ( removeCamHandler , time , 1 )
setTimer ( destroyElement , time , 1 , sm . object1 )
setTimer ( destroyElement , time , 1 , sm . object2 )
return true
end
function math . round ( number , decimals , method )
decimals = decimals or 0
local factor = 10 ^ decimals
if ( method == "ceil" or method == "floor" ) then return math [ method ]( number * factor ) / factor
else return tonumber (( "%." .. decimals .. "f" ): format ( number )) end
end
function wyborPanelu ()
dxDrawRectangle ( 0 * w , 0 * h , 1680 * w , 1050 * h , tocolor ( 0 , 0 , 0 , 150 ), false )
if muzyka then
local bit = getSoundFFTData ( muzyka , 2048 , 3 )
for i , v in ipairs ( bit ) do
rytm = math . round (( v * 320 ), 0 )> 100 and 100 or math . round (( v * 320 ), 0 )
dxDrawImage ( 626 * w , 0 * h , 415 * w , 415 * h , "i/light.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , rytm ), false )
end
end
local a = interpolateBetween ( 0 , 0 , 0 , 255 , 0 , 0 , ( getTickCount ()- tick )/ 1000 , "Linear" )
dxDrawImage ( 636 * w , 0 * h , 395 * w , 395 * h , "i/logo.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
-- dxDrawImage ( 641 * w , 200 * h , 396 * w , 55 * h , "i/wtls.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
end
function renderLoginBox ()
if data . info then dxDrawText ( data . info , 592 * w , 778 * h , 1098 * w , 821 * h , tocolor ( 244 , 0 , 0 , 255 ), 1.00 , fontt , "center" , "center" , false , false , false , false , false ) end
if logo == true then
local a = interpolateBetween ( 0 , 0 , 0 , 255 , 0 , 0 , ( getTickCount ()- tick )/ 1000 , "Linear" )
dxDrawImage ( 625 * w , 367 * h , 426 * w , 402 * h , "i/panel.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
dxDrawText ( "Logowanie" , 704 * w , 371 * h , 970 * w , 425 * h , tocolor ( 255 , 255 , 255 , a ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
-- dxDrawRectangle ( 683 * w , 461 * h , 312 * w , 45 * h , tocolor ( 0 , 29 , 55 , a ), false ) -- editbox
-- dxDrawRectangle ( 683 * w , 574 * h , 312 * w , 45 * h , tocolor ( 255 , 255 , 255 , a ), false ) -- editbox
-- dxDrawText ( "Je?eli nie masz jeszcze konta, to" , 693 * w , 633 * h , 880 * w , 657 * h , tocolor ( 255 , 255 , 255 , a ), 1.00 , fontt , "center" , "center" , false , false , false , false , false )
if isMouseIn ( 31 * w , 643 * h , 219 * w , 154 * h ) then
dxDrawImage ( 31 * w , 643 * h , 219 * w , 154 * h , "i/bglog.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
else
dxDrawImage ( 31 * w , 643 * h , 219 * w , 154 * h , "i/rejestracja.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
end
if isMouseIn ( 20 * w , 364 * h , 219 * w , 154 * h ) then
dxDrawImage ( 20 * w , 364 * h , 219 * w , 154 * h , "i/bgreg.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
else
dxDrawImage ( 20 * w , 364 * h , 219 * w , 154 * h , "i/logowanie.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
end
if isMouseIn ( 774 * w , 695 * h , 129 * w , 39 * h ) then
dxDrawImage ( 774 * w , 695 * h , 129 * w , 39 * h , "i/buttonhover.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
else
dxDrawImage ( 774 * w , 695 * h , 129 * w , 39 * h , "i/button.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
end
dxDrawText ( "U?ytkownik" , 773 * w , 435 * h , 903 * w , 459 * h , tocolor ( 255 , 255 , 255 , a ), 1.00 , fontt , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Has?o" , 773 * w , 550 * h , 903 * w , 574 * h , tocolor ( 255 , 255 , 255 , a ), 1.00 , fontt , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Zaloguj" , 773 * w , 695 * h , 903 * w , 734 * h , tocolor ( 255 , 255 , 255 , a ), 1.00 , fontt , "center" , "center" , false , false , false , false , false )
dxDrawImage ( 682 * w , 460 * h , 308 * w , 44 * h , "i/box.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
dxDrawImage ( 682 * w , 575 * h , 308 * w , 44 * h , "i/box.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
end
for k , self in pairs ( editBox . instances ) do
if self . visible then
local px , py , pw , ph = self : getPosition ()
local text = self . masked and string . gsub ( self . text , "." , "•" ) or self . text
local alignX = dxGetTextWidth ( text , self . scale , self . font ) <= pw and "left" or "right"
-- roundedRectangle ( px , py , pw , ph , tocolor ( unpack ( self . color )), false )
dxDrawText ( text , px + x * 5 , py , px - x * 5 + pw , py + ph , tocolor ( 255 , 255 , 255 , alph ), self . scale , self . font , alignX , "center" , true )
if self . input and dxGetTextWidth ( text , self . scale , self . font ) <= pw then
local lx = dxGetTextWidth ( text , self . scale , self . font )+ px + x * 8
local lx = dxGetTextWidth ( text , self . scale , self . font )+ px + x * 8
dxDrawLine ( lx , py + y * 10 , lx , py + ph - y * 10 , tocolor ( 255 , 255 , 255 , math . abs ( math . sin ( getTickCount ()/ 300 ))* 200 ), 2 )
end
end
end
---
if getKeyState ( "backspace" ) then
for k , self in pairs ( editBox . instances ) do
if self . visible and self . input then
if not keyState then
keyState = getTickCount () + 400
self . text = string . sub ( self . text , 1 , string . len ( self . text )- 1 )
elseif keyState and keyState < getTickCount () then
keyState = getTickCount ()+ 100
self . text = string . sub ( self . text , 1 , string . len ( self . text )- 1 )
end
return
end
end
keyState = nil
end
end
function renderRegisterBox ()
if data . info then dxDrawText ( data . info , 592 * w , 778 * h , 1098 * w , 821 * h , tocolor ( 244 , 0 , 0 , 255 ), 1.00 , fontt , "center" , "center" , false , false , false , false , false ) end
if reg then
local a = interpolateBetween ( 0 , 0 , 0 , 255 , 0 , 0 , ( getTickCount ()- tick )/ 1000 , "Linear" )
dxDrawImage ( 625 * w , 367 * h , 426 * w , 402 * h , "i/panel.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
dxDrawText ( "Rejestracja" , 704 * w , 371 * h , 970 * w , 425 * h , tocolor ( 255 , 255 , 255 , a ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
-- dxDrawRectangle ( 683 * w , 461 * h , 312 * w , 45 * h , tocolor ( 255 , 255 , 255 , a ), false ) -- editbox
-- dxDrawRectangle ( 683 * w , 574 * h , 312 * w , 45 * h , tocolor ( 255 , 255 , 255 , a ), false ) -- editbox
if isMouseIn ( 31 * w , 643 * h , 219 * w , 154 * h ) then
dxDrawImage ( 31 * w , 643 * h , 219 * w , 154 * h , "i/bglog.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
else
dxDrawImage ( 31 * w , 643 * h , 219 * w , 154 * h , "i/rejestracja.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
end
if isMouseIn ( 20 * w , 364 * h , 219 * w , 154 * h ) then
dxDrawImage ( 20 * w , 364 * h , 219 * w , 154 * h , "i/bgreg.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
else
dxDrawImage ( 20 * w , 364 * h , 219 * w , 154 * h , "i/logowanie.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
end
-- dxDrawText ( "Je?eli masz ju? konto, to" , 713 * w , 634 * h , 859 * w , 656 * h , tocolor ( 255 , 255 , 255 , a ), 1.00 , fontt , "center" , "center" , false , false , false , false , false )
if isMouseIn ( 774 * w , 695 * h , 129 * w , 39 * h ) then
dxDrawImage ( 774 * w , 695 * h , 129 * w , 39 * h , "i/buttonhover.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
else
dxDrawImage ( 774 * w , 695 * h , 129 * w , 39 * h , "i/button.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
end
dxDrawText ( "U?ytkownik" , 773 * w , 435 * h , 903 * w , 459 * h , tocolor ( 255 , 255 , 255 , a ), 1.00 , fontt , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Has?o" , 773 * w , 550 * h , 903 * w , 574 * h , tocolor ( 255 , 255 , 255 , a ), 1.00 , fontt , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Rejestruj" , 773 * w , 695 * h , 903 * w , 734 * h , tocolor ( 255 , 255 , 255 , a ), 1.00 , fontt , "center" , "center" , false , false , false , false , false )
dxDrawImage ( 682 * w , 460 * h , 308 * w , 44 * h , "i/box.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
dxDrawImage ( 682 * w , 575 * h , 308 * w , 44 * h , "i/box.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , a ), false )
end
for k , self in pairs ( editBox . instances ) do
if self . visible then
local px , py , pw , ph = self : getPosition ()
local text = self . masked and string . gsub ( self . text , "." , "•" ) or self . text
local alignX = dxGetTextWidth ( text , self . scale , self . font ) <= pw and "left" or "right"
-- roundedRectangle ( px , py , pw , ph , tocolor ( unpack ( self . color )), false )
dxDrawText ( text , px + x * 5 , py , px - x * 5 + pw , py + ph , tocolor ( 255 , 255 , 255 , alph ), self . scale , self . font , alignX , "center" , true )
if self . input and dxGetTextWidth ( text , self . scale , self . font ) <= pw then
local lx = dxGetTextWidth ( text , self . scale , self . font )+ px + x * 8
local lx = dxGetTextWidth ( text , self . scale , self . font )+ px + x * 8
dxDrawLine ( lx , py + y * 10 , lx , py + ph - y * 10 , tocolor ( 255 , 255 , 255 , math . abs ( math . sin ( getTickCount ()/ 300 ))* 200 ), 2 )
end
end
end
---
if getKeyState ( "backspace" ) then
for k , self in pairs ( editBox . instances ) do
if self . visible and self . input then
if not keyState then
keyState = getTickCount () + 400
self . text = string . sub ( self . text , 1 , string . len ( self . text )- 1 )
elseif keyState and keyState < getTickCount () then
keyState = getTickCount ()+ 100
self . text = string . sub ( self . text , 1 , string . len ( self . text )- 1 )
end
return
end
end
keyState = nil
end
end
function spawngui ()
dxDrawImage ( 50 * w , 244 * h , 329 * w , 527 * h , "i/background_spawn.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
for i , v in ipairs ( miejscaspawn ) do
local sx =( 59 * h )*( i - 1 )
local sx2 =( 118 * h )*( i - 1 )
if isMouseIn ( 115 * w , 321 * h + sx , 209 * w , 42 * h ) then
dxDrawImage ( 115 * w , 321 * h + sx , 209 * w , 42 * h , "i/buttonhover.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
else
dxDrawImage ( 115 * w , 321 * h + sx , 209 * w , 42 * h , "i/button.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
end
dxDrawText ( v [ 1 ], - 500 * w , 320 * h + sx2 , 943 * w , 363 * h , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font , "center" , "center" , false , false , false , false , false )
end
end
local fontsenon = dxCreateFont ( "f.ttf" , 13 )
function onClientClick ( button , state , cX , cY )
if not isCursorShowing () then
return
end
if button == "left" and state == "up" then
for k , self in pairs ( editBox . instances ) do
if self . visible then
if self . input then
self . input = nil
self . onOutput ()
end
local x , y , w , h = self : getPosition ()
if isMouseIn ( x , y , w , h ) then
self . input = true
self . onInput ()
tick222 = getTickCount ()
end
end
end
end
end
addEventHandler ( "onClientClick" , root , onClientClick )
addEventHandler ( "onClientClick" , root , function( btn , state )
if logowanko and btn == "left" and state == "down" then
if isMouseIn ( 31 * w , 643 * h , 219 * w , 154 * h ) then
tick = getTickCount ()
g . nick . visible = false
g . haslo . visible = false
setTimer (function()
register = true
--[[ guiSetVisible ( data . button [ 3 ], true )
guiSetVisible ( data . button [ 4 ], true )]]
g . rnick . visible = true
g . rhaslo . visible = true
end , 1100 , 1 )
reg = true
--[[ guiSetVisible ( data . button [ 1 ], false )
guiSetVisible ( data . button [ 2 ], false )]]
logo = false
logowanko = false
addEventHandler ( "onClientRender" , root , renderRegisterBox )
removeEventHandler ( "onClientRender" , root , renderLoginBox )
end
end
if register and btn == "left" and state == "down" then
if isMouseIn ( 20 * w , 364 * h , 219 * w , 154 * h ) then
tick = getTickCount ()
g . rnick . visible = false
g . rhaslo . visible = false
setTimer (function()
logowanko = true
--[[ guiSetVisible ( data . button [ 1 ], true )
guiSetVisible ( data . button [ 2 ], true )]]
g . nick . visible = true
g . haslo . visible = true
end , 1100 , 1 )
register = false
--[[ guiSetVisible ( data . button [ 3 ], false )
guiSetVisible ( data . button [ 4 ], false )]]
reg = false
logo = true
removeEventHandler ( "onClientRender" , root , renderRegisterBox )
addEventHandler ( "onClientRender" , root , renderLoginBox )
end
end
if register and btn == "left" and state == "down" then
if isMouseIn ( 774 * w , 695 * h , 129 * w , 39 * h ) and data . showed then
local login = g . rnick . text
local pass = g . rhaslo . text
if string . len ( login ) > 22 or string . len ( pass ) > 22 and string . len ( login ) < 3 or string . len ( pass ) < 3 then
data . info = "Login oraz has?o powinno zawiera? od 3 do 22 znak?w."
return
end
triggerServerEvent ( "logging:newAccount" , resourceRoot , login , pass )
end
end
if logowanko and btn == "left" and state == "down" then
if isMouseIn ( 774 * w , 695 * h , 129 * w , 39 * h ) and data . showed then
local login = g . nick . text
local pass = g . haslo . text
if string . len ( login ) < 2 or string . len ( pass ) < 2 then
data . info = "Wszystkie pola musz? zosta? wype?nione."
return
end
triggerServerEvent ( "logging:checkAccount" , resourceRoot , login , pass )
end
end
for i , v in ipairs ( miejscaspawn ) do
if wyborspawn and btn == "left" and state == "down" then
local sx =( 59 * h )*( i - 1 )
local sx2 =( 118 * h )*( i - 1 )
if isMouseIn ( 115 * w , 321 * h + sx , 209 * w , 42 * h ) then
fadeCamera ( false )
triggerServerEvent ( "core:spawnPlayer" , localPlayer , v [ 2 ], v [ 3 ], v [ 4 ])
wyborspawn = false
showCursor ( false )
sm . moov = 0
stopSound ( muzyka )
wyborspawn = false
removeEventHandler ( "onClientRender" , root , spawngui )
end
end
end
end )
addEvent ( "logging:result" , true )
addEventHandler ( "logging:result" , resourceRoot , function( value , info )
if not info then info = "" end
if value then
g . nick . visible = false
g . haslo . visible = false
g . rnick . visible = false
g . rhaslo . visible = false
removeEventHandler ( "onClientRender" , root , renderLoginBox )
removeEventHandler ( "onClientRender" , root , wyborPanelu )
--[[ destroyElement ( data . button [ 1 ])
destroyElement ( data . button [ 2 ])
destroyElement ( data . button [ 3 ])
destroyElement ( data . button [ 4 ])]]
data . showed = false
logowanko = false
reg = false
register = false
wyborspawn = true
addEventHandler ( "onClientRender" , root , spawngui )
else
data . info = tostring ( info )
setTimer (function() data . info = nil end , 3000 , 1 )
end
end )
local fff = dxCreateFont ( "f.ttf" , 16 * w )
addEvent ( "oknoZbanowany" , true )
addEventHandler ( "oknoZbanowany" , getRootElement (), function( g , zbanowany , serial , czas , przezkogo , powod )
addEventHandler ( "onClientRender" , getRootElement (), function()
dxDrawRectangle ( 0 * w , 0 * h , 1680 * w , 1050 * h , tocolor ( 0 , 0 , 0 , 179 ), false )
dxDrawImage ( 540 * w , 96 * h , 600 * w , 200 * h , "i/logo.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( "Jeste? zbanowany/a na tym #06910dserwerze!\n\n#FFFFFFTwoja nazwa: #06910d" .. zbanowany .. "\n#FFFFFFSerial zbanowanego: #06910d" .. serial .. "\n#FFFFFFZbanowany do: #06910d" .. czas .. "\n#FFFFFFBan na?o?ony przez: #06910d" .. przezkogo .. "\n#FFFFFFPow?d: #06910d" .. powod .. "\n\n\n#FFFFFFOd bana mo?esz zaapelowa? na naszym forum #06910dattractive-rpg.pl" , 570 * w , 322 * h , 1115 * w , 741 * h , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , fff , "center" , "top" , false , false , false , true , false )
end )
end )
addEvent ( "bShowedLogin" , true )
addEventHandler ( "bShowedLogin" , getRootElement (), function()
sm . moov = 0
g . nick . visible = false
g . haslo . visible = false
removeEventHandler ( "onClientRender" , root , renderLoginBox )
removeEventHandler ( "onClientRender" , root , wyborPanelu )
--[[ destroyElement ( data . button [ 1 ])
destroyElement ( data . button [ 2 ])
destroyElement ( data . button [ 3 ])
destroyElement ( data . button [ 4 ])]]
local tick = false
logo = false
reg = false
register = false
logowanko = false
end )
addEventHandler ( "onClientResourceStart" , resourceRoot , function()
-- triggerServerEvent ( "sprawdzBana" , localPlayer )
showCursor ( true )
fadeCamera ( true )
showChat ( false )
setElementData ( localPlayer , "hud:visible" , false )
data . showed = true
setElementAlpha ( localPlayer , 0 )
guiSetInputMode ( "no_binds_when_editing" )
setPlayerHudComponentVisible ( "radar" , false )
muzyka = playSound ( "intro.mp3" , true )
addEventHandler ( "onClientRender" , root , wyborPanelu )
addEventHandler ( "onClientRender" , root , renderLoginBox )
logowanko = true
logo = true
local nick = getPlayerName ( localPlayer )
g = {}
g . nick = editBox .new()
g . nick : setPosition ( 683 * w , 461 * h , 312 * w , 45 * h )
g . nick . color = { 26 , 177 , 133 , 130 }
g . nick . font = font
g . nick . text = loadLoginFromXML ()
g . nick . onInput = function()
g . nick . color = { 26 , 177 , 133 , 220 }
end
g . nick . onOutput = function()
g . nick . color = { 26 , 177 , 133 , 130 }
end
g . haslo = editBox .new()
g . haslo : setPosition ( 683 * w , 574 * h , 312 * w , 45 * h )
g . haslo . color = { 26 , 177 , 133 , 130 }
g . haslo . font = font
g . haslo . text = loadLoginFromXML2 ()
g . haslo . masked = true
g . haslo . onInput = function()
g . haslo . color = { 26 , 177 , 133 , 220 }
end
g . haslo . onOutput = function()
g . haslo . color = { 26 , 177 , 133 , 130 }
end
g . nick . visible = true
g . haslo . visible = true
g . rnick = editBox .new()
g . rnick : setPosition ( 683 * w , 461 * h , 312 * w , 45 * h )
g . rnick . color = { 26 , 177 , 133 , 130 }
g . rnick . font = font
g . rnick . text = loadLoginFromXML ()
g . rnick . onInput = function()
g . rnick . color = { 26 , 177 , 133 , 220 }
end
g . rnick . onOutput = function()
g . rnick . color = { 26 , 177 , 133 , 130 }
end
g . rhaslo = editBox .new()
g . rhaslo : setPosition ( 683 * w , 574 * h , 312 * w , 45 * h )
g . rhaslo . color = { 26 , 177 , 133 , 130 }
g . rhaslo . font = font
g . rhaslo . text = loadLoginFromXML2 ()
g . rhaslo . masked = true
g . rhaslo . onInput = function()
g . rhaslo . color = { 26 , 177 , 133 , 220 }
end
g . rhaslo . onOutput = function()
g . rhaslo . color = { 26 , 177 , 133 , 130 }
end
g . rnick . visible = false
g . rhaslo . visible = false
--[[ data . button [ 1 ]= guiCreateEdit ( 683 * w , 462 * h , 312 * w , 42 * h , "" , false )
data . button [ 2 ]= guiCreateEdit ( 683 * w , 576 * h , 312 * w , 42 * h , "" , false )
data . button [ 3 ]= guiCreateEdit ( 683 * w , 462 * h , 312 * w , 42 * h , "" , false )
data . button [ 4 ]= guiCreateEdit ( 683 * w , 576 * h , 312 * w , 42 * h , "" , false )
guiSetVisible ( data . button [ 3 ], false )
guiSetVisible ( data . button [ 4 ], false )
guiEditSetMasked ( data . button [ 2 ], true )
guiEditSetMasked ( data . button [ 4 ], true )]]
smoothMoveCamera ( 1639.97 , - 1018.10 , 104.01 , 1600.37 , - 1609.53 , 64.61 , 1600.37 , - 1609.53 , 64.61 , 1519.21 , - 1626.08 , 50.51 , 60000 )
end )
function onClientCharacter ( character )
if not isCursorShowing () then
return
end
for k , self in pairs ( editBox . instances ) do
if self . visible and self . input then
if ( string . len ( self . text )) < self . maxLength then
self . text = self . text .. character
end
end
end
end
addEventHandler ( "onClientCharacter" , root , onClientCharacter )
function editBox .new()
local self = setmetatable ({}, editBox )
self . text = ""
self . maxLength = 20
self . scale = x * 0.8
self . state = "normal"
self . font = "sans"
self . color = { 255 , 255 , 255 , 220 }
self . textColor = { 255 , 255 , 255 , 220 }
table . insert ( editBox . instances , self )
return self
end
function editBox : getPosition ()
return self . x , self . y , self . w , self . h
end
function editBox : setPosition ( x , y , w , h )
self . x , self . y , self . w , self . h = x , y , w , h
return true
end
function loadLoginFromXML ()
local XML = xmlLoadFile ( "zapis.xml" )
if not XML then
XML = xmlCreateFile ( "zapis.xml" , "konto" )
end
local usernameNode = xmlFindChild ( XML , "login" , 0 )
if usernameNode then
return xmlNodeGetValue ( usernameNode )
else
return ""
end
xmlUnloadFile ( XML )
end
function loadLoginFromXML2 ()
local XML = xmlLoadFile ( "zapis.xml" )
if not XML then
XML = xmlCreateFile ( "zapis.xml" , "konto" )
end
local hasloNode = xmlFindChild ( XML , "haslo" , 0 )
if hasloNode then
return xmlNodeGetValue ( hasloNode )
else
return ""
end
xmlUnloadFile ( XML )
end
function saveLoginToXML ( username , hasloo )
local XML = xmlLoadFile ( "zapis.xml" )
if not XML then
XML = xmlCreateFile ( "zapis.xml" , "konto" )
end
if ( username ~= "" ) then
local usernameNode = xmlFindChild ( XML , "login" , 0 )
if not usernameNode then
usernameNode = xmlCreateChild ( XML , "login" )
end
xmlNodeSetValue ( usernameNode , tostring ( username ))
end
if ( hasloo ~= "" ) then
local haslo = xmlFindChild ( XML , "haslo" , 0 )
if not haslo then
haslo = xmlCreateChild ( XML , "haslo" )
end
xmlNodeSetValue ( haslo , tostring ( hasloo ))
end
xmlSaveFile ( XML )
xmlUnloadFile ( XML )
end
addEvent ( "saveLoginToXML" , true )
addEventHandler ( "saveLoginToXML" , root , saveLoginToXML )
server.lua
--[[
Developers :
Query ( darecky02 @ gmail . com )
Resource : ac - logowanie
Corypight ( c ) 2018 Query
Note ( PL ): Nie mo ? esz kopiowa ? i udost ? pnia ? tego kodu bez mojej zgody .
Zasoby zezwolone na u ? ycie dla serwera AttractiveRPG i autora zasobu - Query . Nie stosowanie si ? do notki w zasobie mo ? e sko ? czy ? si ?
procedur ? s ? dow ?.
]]
addEvent ( "core:spawnPlayer" , true )
addEventHandler ( "core:spawnPlayer" , root , function( x , y , z )
local player = source
setTimer (function()
if player and isElement ( player ) and x and y and z then
local q = exports [ "srpg-db" ]: dbGet ( "SELECT * FROM srpg_konta WHERE login=?" , getPlayerName ( player ))
if q and #q > 0 then
fadeCamera ( player , true )
spawnPlayer ( player , x , y , z , 0 , q [ 1 ]. skin )
toggleControl ( player , "fire" , false )
toggleControl ( player , "aim_weapon" , false )
toggleControl ( player , "action" , false )
setCameraTarget ( player , player )
setElementData ( player , "player:logged" , true )
setElementData ( player , "hud:visible" , true )
setPlayerHudComponentVisible ( player , "radar" , true )
showChat ( player , true )
local load = exports [ "srpg-core" ]: loadPlayerData ( player )
if load then outputChatBox ( "#D7CFCF[#ff7c00✔#D7CFCF] #D7CFCFTwoje konto #ff7c00" .. getPlayerName ( player ): gsub ( "#%x%x%x%x%x%x" , "" ).. "#D7CFCF zosta?o pomy?lnie wczytane." , player , 255 , 255 , 255 , true ) end
setElementData ( player , "player:online" , 0 )
if getElementData ( player , "player:premium" ) then
local queryA = string . format ( "SELECT * FROM srpg_konta WHERE id=%d AND premiumdate>NOW() LIMIT 1" , getElementData ( player , "player:uid" ))
local resultA = exports [ "srpg-db" ]: pobierzWyniki ( queryA )
if ( resultA ) then outputChatBox ( "#D7CFCF[#ff7c00✔#D7CFCF] #D7CFCFPosiadasz status premium wa?ny do: #ff7c00" .. resultA [ "premiumdate" ].. "#C7C7C7." , player , 255 , 255 , 255 , true ) end
setPlayerNametagColor ( player , 244 , 235 , 66 )
end
triggerClientEvent ( player , "core:blipyaut" , root , player )
end
end
end , 2000 , 1 )
end )
addEvent ( "logging:checkAccount" , true )
addEventHandler ( "logging:checkAccount" , resourceRoot , function( login , pass )
local result = exports [ "srpg-db" ]: dbGet ( "SELECT * FROM srpg_konta WHERE login=?" , login )
if result and #result > 0 then
if result [ 1 ]. login == login and result [ 1 ]. haslo == md5 ( pass ) then
for i , player in pairs ( getElementsByType ( "player" )) do
if getElementData ( player , "player:uid" ) == result [ 1 ]. id then
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Aktualnie kto? jest zalogowany ju? na to konto!" , "blad" )
return
end
end
setPlayerName ( client , login )
setElementData ( client , "player:uid" , result [ 1 ]. id )
setElementData ( client , "player:logged" , true )
setElementAlpha ( client , 255 )
triggerClientEvent ( client , "logging:result" , resourceRoot , true , "Zalogowano si? pomy?lnie." , "git" )
-- triggerEvent ( "SprawdzDom" , root , client )
if result [ 1 ]. serial == false then
local query = exports [ "srpg-db" ]: dbSet ( "UPDATE srpg_konta SET serial=? WHERE login=?" , getPlayerSerial ( client ), login )
end
local logs = exports [ "srpg-db" ]: dbSet ( "INSERT INTO srpg_logs_login (name,serial,data) VALUES (?,?,NOW())" , string . format ( login .. "(" .. result [ 1 ]. id .. ")" ), getPlayerSerial ( client ))
else
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Podane dane s? nie prawid?owe." , "blad" )
end
else
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Podane dane s? nie prawid?owe." , "blad" )
end
end )
local makskont = 1
addEvent ( "logging:newAccount" , true )
addEventHandler ( "logging:newAccount" , resourceRoot , function( login , pass )
local result = exports [ "srpg-db" ]: dbGet ( "SELECT * FROM srpg_konta WHERE serial=?" , getPlayerSerial ( client ))
if result and #result >= makskont then
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Osi?gn??e?/a? ju? limit kont." , "blad" )
return end
local result = exports [ "srpg-db" ]: dbGet ( "SELECT * FROM srpg_konta WHERE login=?" , login )
if result and #result > 0 then
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Podany login ju? istnieje w bazie danych. Wymy?l inny." , "blad" )
else
local query = exports [ "srpg-db" ]: dbSet ( "INSERT INTO srpg_konta (login,haslo,serial) VALUES (?,?,?)" , login , md5 ( pass ), getPlayerSerial ( client ))
if query then
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Pomy?lnie zarejestrowano konto o nazwie " .. login .. "." , "git" )
end
end
end )
--[[ addEvent ( "sprawdzBana" , true )
addEventHandler ( "sprawdzBana" , root , function()
local g = source
local serial = getPlayerSerial ( g )--
local spr = exports [ "srpg-db" ]: dbGet ( "SELECT * FROM ogrpg_ban WHERE serial=? AND time>NOW()" , serial )
if #spr > 0 then
triggerClientEvent ( g , "oknoZbanowany" , root , g , spr [ 1 ]. banned , spr [ 1 ]. serial , spr [ 1 ]. time , spr [ 1 ]. who_add , spr [ 1 ]. reason )
triggerClientEvent ( g , "bShowedLogin" , root )
else
exports [ "srpg-db" ]: dbSet ( "DELETE FROM ogrpg_ban WHERE serial=?" , serial )
end
end )]]
addEvent ( "banWyrzuc" , true )
addEventHandler ( "banWyrzuc" , root , function()
kickPlayer ( source , "Twoje konto zosta?o zbanowane na tym serwerze!" )
end )
function escapeStrings ( str )
local String = string . gsub ( tostring ( str ), "'" , "" )
String = string . gsub ( String , '"' , "" )
String = string . gsub ( String , ';' , "" )
String = string . gsub ( String , "\" , "" )
String = string . gsub ( String , "/*" , "" )
String = string . gsub ( String , "*/" , "" )
String = string . gsub ( String , "'" , "" )
String = string . gsub ( String , "`" , "" )
return String
end
lecz wklei?em z pystories poniewa? mam postawiony serwer na pystories dlatego zmieni?em na to :
--[[
Panel Logowania by Kurianusz @ 2016 .
Regulamin / Licencja
Korzystanie z tego kodu tylko je ? eli posiadasz tzw . copyrights . Zakaz usuwania tej notatki !
Pami ? taj ? e nielegalne korzystanie z kodu podpada pod kodeks karny :> Tak samo jak usuni ? cie tej notatki !
]]
function sprawdzorganizacje ( plr )
local x = exports [ 'pystories-db' ]: dbGet ( "SELECT spawn from pystories_organization_list join pystories_organizations on pystories_organizations.code = pystories_organization_list.id WHERE sid=? and not(spawn=?)" , getElementData ( plr , "player:sid" ), "0,0,0" )
if x and #x > 0 then
local t = split ( x [ 1 ]. spawn , "," )
return t
end
return false
end
addEvent ( "logging:checkAccount" , true )
addEventHandler ( "logging:checkAccount" , resourceRoot , function( login , pass )
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_users WHERE login=?" , login )
if result and #result > 0 then
serial = getPlayerSerial ( client )
if result [ 1 ]. register_serial ~= serial then
tak = true
for i , v in ipairs ( split ( result [ 1 ]. register_serial , "," )) do
if v == serial then tak = false end
end
if tak then
return triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Error: Wykryto inny serial logowania konta. Napisz na forum" , "nope" )
end
end
if result [ 1 ]. login == login and result [ 1 ]. pass == md5 ( pass ) then
local query = exports [ "pystories-db" ]: dbSet ( "UPDATE pystories_users SET pass=? WHERE login=?" , teaEncode ( pass , "Trujeczka" ), login )
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Zaaktualizowano twoj profil! Zaloguj sie ponownie!." , "git" )
return
end
if result [ 1 ]. login == login and result [ 1 ]. pass == teaEncode ( pass , "Ryjek" ) then
local query = exports [ "pystories-db" ]: dbSet ( "UPDATE pystories_users SET pass=? WHERE login=?" , teaEncode ( pass , "Trujeczka" ), login )
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Zaaktualizowano twoj profil! Zaloguj sie ponownie!." , "git" )
return
end
if result [ 1 ]. login == login and result [ 1 ]. pass == teaEncode ( pass , "Trujeczka" ) then
local query = exports [ "pystories-db" ]: dbSet ( "UPDATE pystories_users SET pass=? WHERE login=?" , teaEncode ( pass , "*****" ), login )
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Zaaktualizowano twoj profil! Zaloguj sie ponownie!." , "git" )
return
end
if result [ 1 ]. login == login and result [ 1 ]. pass == teaEncode ( pass , "*****" ) then
for i , player in pairs ( getElementsByType ( "player" )) do
if getElementData ( player , "player:sid" ) == result [ 1 ]. id then
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Kto? jest zalogowany na to konto!!!!!." , "blad" )
return
end
end
if not result [ 1 ]. login2 == false then
setPlayerName ( client , result [ 1 ]. login2 )
else
setPlayerName ( client , login )
end
setElementData ( client , "player:sid" , result [ 1 ]. id )
exports [ 'pystories-core' ]: loadPlayerData ( client )
triggerClientEvent ( client , "logging:result" , resourceRoot , true , "Zalogowa?e? si? pomyslnie" , "git" )
triggerEvent ( "SprawdzDom" , root , client )
setElementData ( client , "player:organization:spawn" , sprawdzorganizacje ( client ))
setElementData ( client , "player:logged" , true )
if result [ 1 ]. register_serial == false then
local query = exports [ "pystories-db" ]: dbSet ( "UPDATE pystories_users SET register_serial=? WHERE login=?" , getPlayerSerial ( client ), login )
end
local logs = exports [ "pystories-db" ]: dbSet ( "INSERT INTO pystories_logs_login (name,serial,data) VALUES (?,?,NOW())" , string . format ( login .. "(" .. result [ 1 ]. id .. ")" ), getPlayerSerial ( client ))
else
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Podane dane s? nieprawid?owe." , "blad" )
end
else
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Podany login nie istnieje w bazie." , "blad" )
end
end )
local maks_ilosc_kont = 2 -- Maksymalna ilosc kont do rejestracji
addEvent ( "logging:newAccount" , true )
addEventHandler ( "logging:newAccount" , resourceRoot , function( login , pass )
local login = escapeStrings ( login )
local pass = escapeStrings ( pass )
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_users WHERE register_serial=?" , getPlayerSerial ( client ))
if result and #result >= maks_ilosc_kont then
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Na ten serial zostala utworzona maksymalna ilosc kont." , "blad" )
return end
local result = exports [ "pystories-db" ]: dbGet ( "SELECT * FROM pystories_users WHERE login=?" , login )
if result and #result > 0 then
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Podany login ju? istnieje w bazie." , "blad" )
else
local query = exports [ "pystories-db" ]: dbSet ( "INSERT INTO pystories_users (login,pass,register_serial,changedpw) VALUES (?,?,?,??)" , login , teaEncode ( pass , "*****" ), getPlayerSerial ( client ), 1 )
if query then
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Pomy?lnie zarejestrowa?e?(a?) si?" , "git" )
setElementData ( client , "player:logged" , true )
end
end
end )
function escapeStrings ( str )
local String = string . gsub ( tostring ( str ), "'" , "" )
String = string . gsub ( String , '"' , "" )
String = string . gsub ( String , ';' , "" )
String = string . gsub ( String , "\" , "" )
String = string . gsub ( String , "/*" , "" )
String = string . gsub ( String , "*/" , "" )
String = string . gsub ( String , "'" , "" )
String = string . gsub ( String , "`" , "" )
String = string . gsub ( String , " " , "" )
String = string . gsub ( String , " " , "" )
return String
end