KayBay
Wiek: 26 Na forum: 2887 dni Posty: 12
Nick w MP: ...
Piwa : 35
Kod: -- Variables
local authorization = {}
local authorization_textures = {}
local music = nil
-- Functions
function isMouseInPosition(position_x, position_y, size_x, size_y)
if not isCursorShowing() then return end
local screen_x, screen_y = guiGetScreenSize()
local cursor_x, cursor_y = getCursorPosition()
local cursor_x, cursor_y = (screen_x * cursor_x), (screen_y * cursor_y)
if (cursor_x >= position_x and cursor_x <= position_x + size_x) and (cursor_y >= position_y and cursor_y <= position_y + size_y) then
return true
end
return nil
end
local function isValidMail( mail )
assert( type( mail ) == "string", "Bad argument @ isValidMail [string expected, got " .. tostring( mail ) .. "]" )
return mail:match( "[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?" ) ~= nil
end
function fadeOutMusic()
if not music then return nil end
local volume = getSoundVolume(music)
volume = volume - 0.10
if volume <= 0 then
stopSound(music)
music = nil
return nil
end
setSoundVolume(music, volume)
setTimer(fadeOutMusic, 500, 1)
end
local function create_gui(type)
if not type then return nil end
if type == 'login' then
local gui = exports['og-gui_system']
if gui then
gui:dx_input_create('authorization.login', 'username', {-screen['x'], 0}, {400, 50}, 'Nazwa u?ytkownika ...', 'normal', false)
gui:dx_input_create('authorization.login', 'password', {-screen['x'], 0}, {400, 50}, 'Has?o ...', 'password', false)
-- Check
local file = xmlLoadFile('@:'.. getResourceName(getThisResource()) ..'/user.xml')
if file then
local child_username = xmlFindChild(file, 'username', 0)
local child_password = xmlFindChild(file, 'password', 0)
if child_username and child_password then
local username = xmlNodeGetValue(child_username, 'username')
local password = xmlNodeGetValue(child_password, 'password')
if username and password then
gui:dx_input_set_value('authorization.login', 'username', {'text', username})
gui:dx_input_set_value('authorization.login', 'password', {'text', base64Decode(teaDecode(password, 'Vmu4Z033m0'))})
end
end
gui:dx_check_create('authorization.login', 'save', {-screen['x'], 0}, 'on')
else
gui:dx_check_create('authorization.login', 'save', {-screen['x'], 0}, 'off')
end
gui:dx_text_create('authorization.login', 'save', {-screen['x'], 0}, {180, 30}, 'Zapami?taj mnie', tocolor(255, 255, 255, 255), 15, {'left', 'center'})
gui:dx_button_create('authorization.login', 'login', {-screen['x'], 0}, {400, 50}, 'Zaloguj si?')
end
elseif type == 'register' then
local gui = exports['og-gui_system']
if gui then
gui:dx_input_create('authorization.register', 'username', {-screen['x'], 0}, {320, 50}, 'Nazwa u?ytkownika ...', 'normal', false)
gui:dx_input_create('authorization.register', 'referral_username', {-screen['x'], 0}, {320, 50}, 'Polecaj?ca osoba ...', 'normal', false)
gui:dx_input_create('authorization.register', 'email', {-screen['x'], 0}, {320, 50}, 'Adres e-mail ...', 'email', false)
gui:dx_input_create('authorization.register', 'repeat_email', {-screen['x'], 0}, {320, 50}, 'Powt?rz adres e-mail ...', 'email', false)
gui:dx_input_create('authorization.register', 'password', {-screen['x'], 0}, {320, 50}, 'Has?o ...', 'password', false)
gui:dx_input_create('authorization.register', 'repeat_password', {-screen['x'], 0}, {320, 50}, 'Powt?rz has?o ...', 'password', false)
gui:dx_check_create('authorization.register', 'rules', {-screen['x'], 0}, 'off')
gui:dx_text_create('authorization.register', 'rules', {-screen['x'], 0}, {320, 30}, 'Akceptuj? regulamin serwera.', tocolor(255, 255, 255, 255), 15, {'left', 'center'})
gui:dx_button_create('authorization.register', 'register', {-screen['x'], 0}, {400, 50}, 'Zarejestruj si?')
end
end
end
local function destroy_gui(type)
if not type then return nil end
if type == 'login' then
local gui = exports['og-gui_system']
if gui then
gui:dx_destroy('authorization.login')
end
elseif type == 'register' then
local gui = exports['og-gui_system']
if gui then
gui:dx_destroy('authorization.register')
end
end
end
addEventHandler('onClientRender', root,
function()
if not authorization['toggled'] then return nil end
-- Camera
local position = {
{-2006.41, 907.58, 68.82},
{-1960.26, 883.36, 41.81}
}
if not count then
count = 0
end
if stop and count > 1 then
count = count - 0.05
else
stop = nil
end
if not stop and count < 100 then
count = count + 0.05
else
stop = true
end
setCameraMatrix(position[1][1], position[1][2] - count, position[1][3], position[2][1], position[2][2], position[2][3])
if authorization['toggled']['navigation'] then
local alpha = 255
if authorization['animation']['navigation']['navigation'] then
local progress = (getTickCount() - authorization['animation']['navigation']['navigation']) / 2000
alpha = interpolateBetween(0, 0, 0, 255, 0, 0, progress, 'Linear')
if progress > 1 then
showCursor(true)
authorization['selected_item'] = 'info'
authorization['new_selected_item'] = nil
-- Animation
authorization['animation']['navigation']['navigation'] = nil
authorization['animation']['navigation']['info'] = {
['start'] = getTickCount(),
['stop'] = nil,
}
end
end
-- Navigation
dxDrawImage(scale_x(30), scale_y(240), scale_x(180), scale_y(600), authorization_textures['navigation']['background'], 0, 0, 0, tocolor(255, 255, 255, alpha), false)
if authorization['selected_item'] ~= 'info' and not isMouseInPosition(scale_x(60), scale_y(270), scale_x(120), scale_x(120)) then
dxDrawImage(scale_x(60), scale_y(270), scale_x(120), scale_x(120), authorization_textures['navigation']['info'], 0, 0, 0, tocolor(255, 255, 255, alpha), false)
else
dxDrawImage(scale_x(60), scale_y(270), scale_x(120), scale_x(120), authorization_textures['navigation']['info_hover'], 0, 0, 0, tocolor(255, 255, 255, alpha), false)
end
-- Rules
if authorization['selected_item'] ~= 'rules' and not isMouseInPosition(scale_x(60), scale_y(410), scale_x(120), scale_x(120)) then
dxDrawImage(scale_x(60), scale_y(410), scale_x(120), scale_x(120), authorization_textures['navigation']['rules'], 0, 0, 0, tocolor(255, 255, 255, alpha), false)
else
dxDrawImage(scale_x(60), scale_y(410), scale_x(120), scale_x(120), authorization_textures['navigation']['rules_hover'], 0, 0, 0, tocolor(255, 255, 255, alpha), false)
end
-- Login
if authorization['selected_item'] ~= 'login' and not isMouseInPosition(scale_x(60), scale_y(560), scale_x(120), scale_x(120)) then
dxDrawImage(scale_x(60), scale_y(560), scale_x(120), scale_x(120), authorization_textures['navigation']['login'], 0, 0, 0, tocolor(255, 255, 255, alpha), false)
else
dxDrawImage(scale_x(60), scale_y(560), scale_x(120), scale_x(120), authorization_textures['navigation']['login_hover'], 0, 0, 0, tocolor(255, 255, 255, alpha), false)
end
-- Register
if authorization['selected_item'] ~= 'register' and not isMouseInPosition(scale_x(60), scale_y(700), scale_x(120), scale_x(120)) then
dxDrawImage(scale_x(60), scale_y(700), scale_x(120), scale_x(120), authorization_textures['navigation']['register'], 0, 0, 0, tocolor(255, 255, 255, alpha), false)
else
dxDrawImage(scale_x(60), scale_y(700), scale_x(120), scale_x(120), authorization_textures['navigation']['register_hover'], 0, 0, 0, tocolor(255, 255, 255, alpha), false)
end
-- Panel
local position_default = scale_x(560)
local position = position_default
local selected_item = authorization['selected_item']
local new_selected_item = authorization['new_selected_item']
if selected_item then
if authorization['animation']['navigation'][selected_item]['start'] then
local progress = (getTickCount() - authorization['animation']['navigation'][selected_item]['start']) / 1000
position = interpolateBetween(screen['x'] + position_default, 0, 0, position_default, 0, 0, progress, 'OutBack')
if progress >= 1 then
-- Animation
authorization['animation']['navigation'][selected_item] = {
['start'] = nil,
['stop'] = nil,
}
end
elseif authorization['animation']['navigation'][selected_item]['stop'] then
local progress = (getTickCount() - authorization['animation']['navigation'][selected_item]['stop']) / 1000
position = interpolateBetween(position_default, 0, 0, screen['x'] + position_default, 0, 0, progress, 'InBack')
if progress >= 1 then
-- Animation
authorization['animation']['navigation'][selected_item] = {
['start'] = nil,
['stop'] = nil,
}
destroy_gui(selected_item)
if new_selected_item then
authorization['selected_item'] = new_selected_item
-- Animation
authorization['animation']['navigation'][authorization['selected_item']] = {
['start'] = getTickCount(),
['stop'] = nil,
}
authorization['new_selected_item'] = nil
create_gui(authorization['selected_item'])
end
end
end
end
if selected_item then
dxDrawImage(position, scale_y(240), scale_x(800), scale_y(600), authorization_textures['background'], 0, 0, 0, tocolor(255, 255, 255, alpha), false)
if selected_item ~= 'rules' then
-- Logo
dxDrawImage(position + scale_x(200), scale_y(150), scale_x(400), scale_y(200), authorization_textures['logo'], 0, 0, 0, tocolor(255, 255, 255, alpha), false)
end
if selected_item == 'info' then
local text = [[
Witamy na ourGame!
Serwer jest tworzony z pasj? dla mi?osnik?w trybu RPG.
Tylko u nas znajdziesz tak innowacyjne pomys?y i pliki tworzone od zera. Wspania?a przygoda na naszym serwerze czeka na Ciebie!
Je?li po?wi?cisz naszemu projektowi troch? wi?cej czasu, to zauwa?ysz r??nic? mi?dzy naszymi oryginalnymi skryptami a innymi "pseudolami" tworzonymi na gamemodach z internetu.
Nasza ekipa sk?ada si? z os?b bardzo do?wiadczonych w swoich dziedzinach. Wiemy czego gracze oczekuj? od nas - administracji.
Wys?uchamy Was wszystkich, aby?cie to Wy mogli tworzy? now? histori? w spo?eczno?ci MTA!
Wasze pomys?y na pewno zostan? przeanalizowane i poddane dyskusjom przez zarz?d serwera.
]]
dxDrawText(text, position + scale_x(50), scale_y(325), (position - scale_x(50)) + scale_x(800), scale_y(325 + 525), tocolor(255, 255, 255, alpha), 1, authorization['font'][1], 'center', 'center', true, true, false)
elseif selected_item == 'rules' then
local text = [[
* Jakie Twoje dane przetwarzamy ?
- Przetwarzamy takie dane jak: adres e-mail oraz adres IP.
* Jaki jest cel przetwarzania Twoich danych osobowych ?
- Przetwarzamy Twoje dane osobowe w celu weryfikacji Twojego konta w razie gdy zapomnisz do niego has?a oraz w trakcie skarg b?d? apelacji o odwieszenie wirtualnych kar nadanych na serwerze.
* Jakie masz uprawnienia w zakresie przetwarzanych danych ?
- Dost?p do swoich danych, edycja, usuni?cie oraz przenoszenie.
* Jak d?ugo przechowujemy Twoje dane osobowe ?
- Twoje dane osobowe przechowujemy do czasu usuni?cia przez Ciebie konta oraz do czasu dzia?ania serwera.
* Kto jest administratorem Twoich danych osobowych ?
- Administratorem Twoich danych osobowych s? osoby prywatne "Szymon Orze?, adres e-mail: szymon.lua@gmail.com", "Kamil Pitera, adres e-mail: kamilpitera1@gmail.com" oraz "Damian Michalak, adres e-mail: dami9908@onet.pl".
Rejestruj?c si? zgadzasz si? na przetwarzanie Twoich danych osobowych.
]]
dxDrawText(text, position + scale_x(50), scale_y(240), (position - scale_x(50)) + scale_x(800), scale_y(240 + 600), tocolor(255, 255, 255, alpha), 1, authorization['font'][2], 'left', 'center', true, true, false)
elseif selected_item == 'login' then
if authorization['animation']['navigation'][selected_item]['start'] or authorization['animation']['navigation'][selected_item]['stop'] then
local gui_position = (position / screen['x']) * 1920 -- unscale
local gui = exports['og-gui_system']
gui:dx_input_set_value('authorization.login', 'username', {'position', {gui_position + 200, 400 + 30}})
gui:dx_input_set_value('authorization.login', 'password', {'position', {gui_position + 200, 500 + 30}})
gui:dx_check_set_value('authorization.login', 'save', {'position', {gui_position + 200, 600 + 40}})
gui:dx_text_set_value('authorization.login', 'save', {'position', {gui_position + 250, 600 + 40}})
gui:dx_button_set_value('authorization.login', 'login', {'position', {gui_position + 200, 730}})
end
elseif selected_item == 'register' then
if authorization['animation']['navigation'][selected_item]['start'] or authorization['animation']['navigation'][selected_item]['stop'] then
local gui = exports['og-gui_system']
local gui_position = (position / screen['x']) * 1920 -- unscale
gui:dx_input_set_value('authorization.register', 'username', {'position', {gui_position + 50, 360 + 30}})
gui:dx_input_set_value('authorization.register', 'referral_username', {'position', {gui_position + 430, 360 + 30}})
gui:dx_input_set_value('authorization.register', 'email', {'position', {gui_position + 50, 440 + 30}})
gui:dx_input_set_value('authorization.register', 'repeat_email', {'position', {gui_position + 430, 440 + 30}})
gui:dx_input_set_value('authorization.register', 'password', {'position', {gui_position + 50, 520 + 30}})
gui:dx_input_set_value('authorization.register', 'repeat_password', {'position', {gui_position + 430, 520 + 30}})
gui:dx_check_set_value('authorization.register', 'rules', {'position', {gui_position + 50, 620 + 30}})
gui:dx_text_set_value('authorization.register', 'rules', {'position', {gui_position + 100, 620 + 30}})
gui:dx_button_set_value('authorization.register', 'register', {'position', {gui_position + 200, 730}})
end
end
end
end
end
)
addEventHandler('onClientClick', root,
function(button, state)
if button ~= 'left' or state ~= 'down' then return nil end
if authorization['toggled'] then
if authorization['animation']['navigation']['navigation'] then return nil end
if authorization['animation']['navigation']['info']['start'] or authorization['animation']['navigation']['info']['stop'] then return nil end
if authorization['animation']['navigation']['rules']['start'] or authorization['animation']['navigation']['rules']['stop'] then return nil end
if authorization['animation']['navigation']['login']['start'] or authorization['animation']['navigation']['login']['stop'] then return nil end
if authorization['animation']['navigation']['register']['start'] or authorization['animation']['navigation']['register']['stop'] then return nil end
-- Navigation
local item = nil
if isMouseInPosition(scale_x(60), scale_y(270), scale_x(120), scale_x(120)) then item = 'info'
elseif isMouseInPosition(scale_x(60), scale_y(410), scale_x(120), scale_x(120)) then item = 'rules'
elseif isMouseInPosition(scale_x(60), scale_y(560), scale_x(120), scale_x(120)) then item = 'login'
elseif isMouseInPosition(scale_x(60), scale_y(700), scale_x(120), scale_x(120)) then item = 'register' end
if item and isMouseInPosition(scale_x(60), scale_y(270), scale_x(120), scale_x(120)) or isMouseInPosition(scale_x(60), scale_y(410), scale_x(120), scale_x(120)) or isMouseInPosition(scale_x(60), scale_y(560), scale_x(120), scale_x(120)) or isMouseInPosition(scale_x(60), scale_y(700), scale_x(120), scale_x(120)) then
local selected_item = authorization['selected_item']
local new_selected_item = authorization['new_selected_item']
if not selected_item or selected_item ~= item then
if selected_item then
authorization['new_selected_item'] = item
-- Animation
authorization['animation']['navigation'][authorization['selected_item']] = {
['start'] = nil,
['stop'] = getTickCount(),
}
return nil
end
authorization['selected_item'] = item
-- Animation
authorization['animation']['navigation'][item] = {
['start'] = getTickCount(),
['stop'] = nil,
}
create_gui(item)
end
end
end
end
)
addEventHandler('gui_system:button_click', root,
function(window_id, button_id)
if window_id == 'authorization.login' then
if button_id == 'login' then
local username = exports['og-gui_system']:dx_input_get_value('authorization.login', 'username', 'text')
local password = exports['og-gui_system']:dx_input_get_value('authorization.login', 'password', 'text')
if username and password then
if username:len() == 0 or password:len() == 0 then
triggerEvent('alerts:create', root, 'information', 'Uzupe?nij wymagane pola formularza. Pola oznaczone * s? wymagane.')
return nil
end
triggerServerEvent('authorization:check_account', resourceRoot, username, password)
end
end
elseif window_id == 'authorization.register' then
if button_id == 'register' then
local username = exports['og-gui_system']:dx_input_get_value('authorization.register', 'username', 'text')
local referral_username = exports['og-gui_system']:dx_input_get_value('authorization.register', 'referral_username', 'text')
local email = exports['og-gui_system']:dx_input_get_value('authorization.register', 'email', 'text')
local repeat_email = exports['og-gui_system']:dx_input_get_value('authorization.register', 'repeat_email', 'text')
local password = exports['og-gui_system']:dx_input_get_value('authorization.register', 'password', 'text')
local repeat_password = exports['og-gui_system']:dx_input_get_value('authorization.register', 'repeat_password', 'text')
local rules = exports['og-gui_system']:dx_check_get_value('authorization.register', 'rules', 'selected')
if username and email and repeat_email and password and repeat_password then
if username:len() == 0 or email:len() == 0 or repeat_email:len() == 0 or password:len() == 0 or repeat_password:len() == 0 then
triggerEvent('alerts:create', root, 'information', 'Uzupe?nij wymagane pola formularza. Pola oznaczone * s? wymagane.')
return nil
end
if username:len() < 3 then
triggerEvent('alerts:create', root, 'information', 'Nazwa u?ytkownika musi mie? minimum 5 znak?w.')
return nil
end
if username:len() >= 20 then
triggerEvent('alerts:create', root, 'information', 'Nazwa u?ytkownika mo?e mie? maksymalnie 10 znak?w.')
return nil
end
if not isValidMail(email) then
triggerEvent('alerts:create', root, 'information', 'Adres e-mail ma nieprawid?owy format.')
return nil
end
if email ~= repeat_email then
triggerEvent('alerts:create', root, 'information', 'Adresy e-mail nie s? takie same.')
return nil
end
if password:len() < 5 then
triggerEvent('alerts:create', root, 'information', 'Has?o musi mie? minimum 5 znak?w.')
return nil
end
if password:len() >= 20 then
triggerEvent('alerts:create', root, 'information', 'Has?o mo?e mie? maksymalnie 20 znak?w.')
return nil
end
if password ~= repeat_password then
triggerEvent('alerts:create', root, 'information', 'Has?a nie s? takie same.')
return nil
end
if rules == 'off' then
triggerEvent('alerts:create', root, 'information', 'Nie zaakceptowa?e?(a?) regulaminu serwera.')
return nil
end
triggerServerEvent('authorization:new_account', resourceRoot, username, email, password, referral_username)
end
end
end
end
)
addEvent('authorization:show', true)
addEventHandler('authorization:show', root,
function()
if getElementData(localPlayer, 'player:logged') then return nil end
fadeCamera(true)
setPlayerHudComponentVisible('all', false)
setTimer(showChat, 100, 1, false)
authorization = {
['toggled'] = {
['navigation'] = true,
},
['selected_item'] = nil,
['new_selected_item'] = nil,
-- Animation
['animation'] = {
['navigation'] = {
['navigation'] = getTickCount(),
['info'] = {
['start'] = nil,
['stop'] = nil,
},
-- Rules
['rules'] = {
['start'] = nil,
['stop'] = nil,
},
-- Login
['login'] = {
['start'] = nil,
['stop'] = nil,
},
-- Register
['register'] = {
['start'] = nil,
['stop'] = nil,
},
},
},
-- Font
['font'] = {
exports['og-files']:load_font(1, 15),
exports['og-files']:load_font(1, 14),
},
}
authorization_textures = {
['navigation'] = {
['info'] = dxCreateTexture('i/navigation/navigation_1/navigation_1.png', 'dxt5', true, 'clamp'),
['info_hover'] = dxCreateTexture('i/navigation/navigation_1/navigation_1_hover.png', 'dxt5', true, 'clamp'),
-- Rules
['rules'] = dxCreateTexture('i/navigation/navigation_2/navigation_2.png', 'dxt5', true, 'clamp'),
['rules_hover'] = dxCreateTexture('i/navigation/navigation_2/navigation_2_hover.png', 'dxt5', true, 'clamp'),
-- Login
['login'] = dxCreateTexture('i/navigation/navigation_3/navigation_3.png', 'dxt5', true, 'clamp'),
['login_hover'] = dxCreateTexture('i/navigation/navigation_3/navigation_3_hover.png', 'dxt5', true, 'clamp'),
-- Register
['register'] = dxCreateTexture('i/navigation/navigation_4/navigation_4.png', 'dxt5', true, 'clamp'),
['register_hover'] = dxCreateTexture('i/navigation/navigation_4/navigation_4_hover.png', 'dxt5', true, 'clamp'),
-- Background
['background'] = dxCreateTexture('i/navigation/navigation.png', 'dxt5', true, 'clamp'),
},
['logo'] = dxCreateTexture(':og-files/i/logo.png', 'dxt5', true, 'clamp'),
['background'] = dxCreateTexture('i/authorization.png', 'dxt5', true, 'clamp'),
}
-- Start - music
music = playSound('s/music.mp3', true)
-- Stop - music
setElementData(localPlayer, 'player:logged', false)
setElementData(localPlayer, 'player:blur', true)
end
)
addEvent('authorization:hide', true)
addEventHandler('authorization:hide', resourceRoot,
function()
showCursor(false)
fadeOutMusic()
-- Start - save
local gui = exports['og-gui_system']
if gui then
local status = gui:dx_check_get_value('authorization.login', 'save', 'selected')
if status then
local path = '@:'.. getResourceName(getThisResource()) ..'/user.xml'
if status == 'on' then
-- Load
local file = xmlLoadFile(path)
if not file then
local create = xmlCreateFile(path, 'root')
if create then
xmlSaveFile(create)
xmlUnloadFile(create)
end
end
-- Set
local username = gui:dx_input_get_value('authorization.login', 'username', 'text')
local password = gui:dx_input_get_value('authorization.login', 'password', 'text')
if username and password then
local file = xmlLoadFile(path)
if file then
xmlNodeSetValue(xmlCreateChild(file, 'username'), username)
xmlNodeSetValue(xmlCreateChild(file, 'password'), teaEncode(base64Encode(password), 'Vmu4Z033m0'))
-- Save
xmlSaveFile(file)
xmlUnloadFile(file)
end
end
elseif status == 'off' then
local file = xmlLoadFile(path)
if file then
fileDelete(path)
end
end
end
end
-- Stop - save
for key, value in ipairs(authorization) do
if isElement(value) then
destroyElement(value)
end
end
authorization = {}
for key, value in ipairs(authorization_textures) do
if isElement(value) then
destroyElement(value)
end
end
authorization_textures = {}
-- Destroy gui
destroy_gui('login')
destroy_gui('register')
triggerEvent('loading:start', root, 'Trwa wyszukiwanie miejsc pocz?tkowych ...', 3000)
-- Show map
setTimer(
function()
triggerServerEvent('authorization-zones:result', root)
end,
3000, 1)
end
)
addEventHandler('onClientResourceStop', resourceRoot,
function()
if getElementData(localPlayer, 'player:logged') then return nil end
-- Destroy gui
destroy_gui('login')
destroy_gui('register')
end
)