Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2020-05-03, 08:47


NiczeQ







Wiek: 28
Na forum: 2611 dni
Posty: 2



Respekt: 40

Witajcie,

Mam logowanie, kt?re jest pod ACL a chcia?bym aby by?o pod pysa lub baze danych SQL.

Server.lua

function PlayerLogin(usernamepasswordchecksave)
    if not (username == ""then
        if not (password == ""then
            local account getAccount usernamepassword )
            if ( account ~= false then
                if checksave == true then
                    triggerClientEvent(source"saveLoginToXML"getRootElement(), usernamepassword)
                else
                    triggerClientEvent(source"resetSaveXML"getRootElement(), usernamepassword)
                end
                local chek logIn(sourceaccountpassword)
                if chek then 
                    triggerClientEvent(source"setLoginPanelVisible"getRootElement(), false)
                else
                    triggerClientEvent(source"showWarning"getRootElement(), 1false"Konto jest ju? zarejestrowane.")
                end
            else
                triggerClientEvent(source"showWarning"getRootElement(), 1false"B??d! Niepoprawne has?o lub login.")
                triggerClientEvent(source"showWarning"getRootElement(), 2false"B??d! Niepoprawne has?o lub login.")
            end
        else
            triggerClientEvent(source"showWarning"getRootElement(), 2false"Wpisz has?o")
        end
    else    
        triggerClientEvent(source"showWarning"getRootElement(), 1false"    Wpisz login")

    end
end
addEvent("onRequestLogin"true)
addEventHandler("onRequestLogin"getRootElement(), PlayerLogin)

function outputChatBox (msgpl)
exports.dpChat:message (pl"global"msg)
end

function registerPlayer(usernameemailpassword)
    if not (username == ""then
        if not (password == ""then
            if not (email == ""then
                local account getAccount (usernamepassword)
                if (account == falsethen
                    if getEmailFromAllAccount(emailthen
                        local accountID #getAccounts() + 1
                        local accountAdded addAccount(tostring(username),tostring(password))
                        if (accountAddedthen
                            triggerEvent("rmta_save.createNewAccount"rootaccountAddedaccountIDemail)
                            triggerClientEvent(source"onAccountCreate"getRootElement())
                        else
                            triggerClientEvent(source"showWarning"getRootElement(), 3false"Wypr?buj inne dane")
                            triggerClientEvent(source"showWarning"getRootElement(), 4false"Wypr?buj inne dane")
                            triggerClientEvent(source"showWarning"getRootElement(), 5false"Wypr?buj inne dane")
                        end
                    else
                        triggerClientEvent(source"showWarning"getRootElement(), 4false"Ten e-mail jest ju? w u?yciu")
                
                    end
                else
                    triggerClientEvent(source"showWarning"getRootElement(), 3false"Ten login jest w u?yciu")
                end
            else
                triggerClientEvent(source"showWarning"getRootElement(), 4false"Wpisz email, przyk?ad: [email protected]")
            end
        else
            triggerClientEvent(source"showWarning"getRootElement(), 5false"Wpisz has?o")
        end
    else
        triggerClientEvent(source"showWarning"getRootElement(), 3false"Wpisz login")
    end
end
addEvent("onRequestRegister",true)
addEventHandler("onRequestRegister",getRootElement(),registerPlayer)

function getEmailFromAllAccount(email) 
    local accountTable getAccounts ()
    for _account in ipairs(accountTable) do
        if getAccountData(account"account.email") == email then 
            return false 
        end
    end
    return true
end

function loggedOut()
    cancelEvent()
end
addEventHandler("onPlayerLogout",getRootElement(),loggedOut)


Login.lua

local screenXscreenY guiGetScreenSize()

login = {}

login.font = {
    ["RB"] = guiCreateFont("RB.ttf"12),
    ["RL"] = guiCreateFont("RL.ttf"11),
    ["RR"] = guiCreateFont("RR.ttf"10),
    ["chek_r"] = guiCreateFont("RR.ttf"10),
    ["chek_b"] = guiCreateFont("RB.ttf"10),
    ["RL_warning"] = guiCreateFont("RL.ttf"10),
    ["RR_editbox"] = guiCreateFont("RR.ttf"12)
}

function outputChatBox (msgpl)
exports.dpChat:message (pl"global"msg)
end

login.back_ground1 guiCreateStaticImage(00screenXscreenY"assets/main.png"false)
login.back_ground guiCreateStaticImage(screenX/2-600/2screenY/2-360/2600360"assets/bg.png"false,login.back_ground1)
--login.logo guiCreateStaticImage(00240360"assets/logo.png"falselogin.back_ground)

login.label_nickname guiCreateLabel(2903010020"LOGIN"falselogin.back_ground)
guiSetFont(login.label_nicknamelogin.font["RB"] )
guiLabelSetColor(login.label_nickname153156175)
createEditBox(129050""login.back_groundfalse)

login.label_password guiCreateLabel(29010010020"HAS?O"falselogin.back_ground)
guiSetFont(login.label_passwordlogin.font["RB"] )
guiLabelSetColor(login.label_password153156175)
createEditBox(2290120""login.back_groundtrue)

login.button_login guiCreateStaticImage(28020028050"assets/button_login.png"falselogin.back_ground)

login.label_first guiCreateLabel(34026020020"Nie posiadasz konta?"falselogin.back_ground)
guiSetFont(login.label_firstlogin.font["RL"] )
guiLabelSetColor(login.label_first153156175)

guiCreateStaticImage(4152901510"assets/iarrow.png"falselogin.back_ground)
login.button_reg guiCreateLabel(37531010020"Zarejestruj"falselogin.back_ground)
guiSetFont(login.button_reglogin.font["RB"] )
guiLabelSetColor(login.button_reg153156175)

createChekBox(1290170login.back_ground)
login.label_chek guiCreateLabel(31017020020"Zapami?taj!"falselogin.back_ground)
guiSetFont(login.label_cheklogin.font["chek_r"] )
guiLabelSetColor(login.label_chek153156175)
--login.label_chek_two guiCreateLabel(38517020020"никнейм и пароль"falselogin.back_ground)
--guiSetFont(login.label_chek_twologin.font["chek_b"] )
--guiLabelSetColor(login.label_chek_two25518541)

guiSetVisible(login.back_groundfalse)
guiSetVisible(login.back_ground1false)

addEventHandler("onClientMouseEnter"getRootElement(), function()
    if (source == login.button_regthen
        guiLabelSetColor(login.button_reg25518541)
    elseif (source == login.button_loginthen
        guiStaticImageLoadImage(source"assets/button_login_a.png")
    end
end)
    
addEventHandler("onClientMouseLeave"getRootElement(), function()
    if (source == login.button_regthen
        guiLabelSetColor(login.button_reg153156175)
    elseif (source == login.button_loginthen
        guiStaticImageLoadImage(source"assets/button_login.png")
    end
end)

addEventHandler ("onClientGUIClick"getRootElement(), function(button)
    if button == "left" then
        if source == login.button_login then
            triggerServerEvent("onRequestLogin"getLocalPlayer(), editBox[1].texteditBox[2].textchekBox[1].active)
        elseif source == login.button_reg then
            guiSetVisible(login.back_groundfalse)
            guiSetVisible(reg.back_groundtrue)
        end
    end 
end)

local function showWarning(idchekmessage)
    setEditBoxWarning(idmessagechek)
end
addEvent("showWarning"true)
addEventHandler("showWarning"getRootElement(), showWarning)


state true
guiSetVisible(login.back_groundstate)
guiSetVisible(login.back_ground1state)
local sound playSound("assets/loading.mp3") --Play wasted.mp3 from the sounds folder
setSoundVolume(sound0.3) -- set the sound volume to 50%
showCursor(state)

function onSoundStopped reason )
    if ( reason == "finished" ) and source == sound then
        sound playSound("assets/loading.mp3")
        setSoundVolume(sound0.3)
    end
end
addEventHandler "onClientSoundStopped"getRootElement(), onSoundStopped )

local function loginPanelVisible(state) 
    guiSetVisible(login.back_groundstate)
    guiSetVisible(login.back_ground1state)
    if state == false then
        stopSound(sound)
    end
    showCursor(state)
end
addEvent ("setLoginPanelVisible"true)
addEventHandler "setLoginPanelVisible"getRootElement(), loginPanelVisible)

-- Загрузка данных
function loadLoginFromXML() --Загрузка логина и пароля из XML
    local xml_save_log_File xmlLoadFile ("files/xml/userdata.xml")
    if not xml_save_log_File then
        xml_save_log_File xmlCreateFile("files/xml/userdata.xml""login")
    end
    local usernameNode xmlFindChild (xml_save_log_File"username"0)
    local passwordNode xmlFindChild (xml_save_log_File"password"0)
    if usernameNode and passwordNode then
        return xmlNodeGetValue(usernameNode), xmlNodeGetValue(passwordNode)
    else
        return """"
    end
    xmlUnloadFile xml_save_log_File )
end

function saveLoginToXML(usernamepassword) --Сохрание логина и пароля в XML
    local xml_save_log_File xmlLoadFile ("files/xml/userdata.xml")
    if not xml_save_log_File then
        xml_save_log_File xmlCreateFile("files/xml/userdata.xml""login")
    end
    if (username ~= ""then
        local usernameNode xmlFindChild (xml_save_log_File"username"0)
        if not usernameNode then
            usernameNode xmlCreateChild(xml_save_log_File"username")
        end
        xmlNodeSetValue (usernameNodetostring(username))
    end
    if (password ~= ""then
        local passwordNode xmlFindChild (xml_save_log_File"password"0)
        if not passwordNode then
            passwordNode xmlCreateChild(xml_save_log_File"password")
        end        
        xmlNodeSetValue (passwordNodetostring(password))
    end
    xmlSaveFile(xml_save_log_File)
    xmlUnloadFile (xml_save_log_File)
end
addEvent("saveLoginToXML"true)
addEventHandler("saveLoginToXML"getRootElement(), saveLoginToXML)

function resetSaveXML() --Сохрание логина и пароля в XML
    local xml_save_log_File xmlLoadFile ("files/xml/userdata.xml")
    if not xml_save_log_File then
        xml_save_log_File xmlCreateFile("files/xml/userdata.xml""login")
    end
    if (username ~= ""then
        local usernameNode xmlFindChild (xml_save_log_File"username"0)
        if not usernameNode then
            usernameNode xmlCreateChild(xml_save_log_File"username")
        end
    end
    if (password ~= ""then
        local passwordNode xmlFindChild (xml_save_log_File"password"0)
        if not passwordNode then
            passwordNode xmlCreateChild(xml_save_log_File"password")
        end        
        xmlNodeSetValue (passwordNode"")
    end
    xmlSaveFile(xml_save_log_File)
    xmlUnloadFile(xml_save_log_File)
end
addEvent("resetSaveXML"true)
addEventHandler("resetSaveXML"getRootElement(), resetSaveXML)

local usernamepassword loadLoginFromXML()
if notusername == "" or password == ""then
    setChekBoxActive(1true)
    setEditBoxText(1tostring(username))
    setEditBoxText(2tostring(password))
else
    setChekBoxActive(1false)
end



Register.lua

local screenXscreenY guiGetScreenSize()

reg = {}

reg.back_ground guiCreateStaticImage(screenX/2-600/2screenY/2-360/2600360"assets/bg.png"falselogin.back_ground1)
--reg.logo guiCreateStaticImage(00240360"assets/logo.png"falsereg.back_ground)


reg.label_nickname guiCreateLabel(2903010020"LOGIN"falsereg.back_ground)
guiSetFont(reg.label_nicknamelogin.font["RB"] )
guiLabelSetColor(reg.label_nickname153156175)
createEditBox(329050""reg.back_groundfalse)

reg.label_email guiCreateLabel(29010020020"E-MAIL"falsereg.back_ground)
guiSetFont(reg.label_emaillogin.font["RB"] )
guiLabelSetColor(reg.label_email153156175)
createEditBox(4290120""reg.back_groundfalse)

reg.label_password guiCreateLabel(29017010020"HAS?O"falsereg.back_ground)
guiSetFont(reg.label_passwordlogin.font["RB"] )
guiLabelSetColor(reg.label_password153156175)
createEditBox(5290190""reg.back_groundfalse)

reg.button_reg guiCreateStaticImage(28023528050"assets/button_reg.png"falsereg.back_ground)

reg.label_first guiCreateLabel(32029020020"Masz ju? konto?"falsereg.back_ground)
guiSetFont(reg.label_firstlogin.font["RL"])
guiLabelSetColor(reg.label_first153156175)
guiLabelSetHorizontalAlign(reg.label_first"center")

reg.button_login guiCreateLabel(32031520020"Powr?t"falsereg.back_ground)
guiSetFont(reg.button_loginlogin.font["RB"] )
guiLabelSetColor(reg.button_login153156175)
guiLabelSetHorizontalAlign(reg.button_login"center")

guiSetVisible(reg.back_groundfalse)

addEventHandler("onClientMouseEnter"getRootElement(), function()
    if (source == reg.button_loginthen
        guiLabelSetColor(reg.button_login25518541)
    elseif (source == reg.button_regthen
        guiStaticImageLoadImage(source"assets/button_reg_a.png")
    end
end)
    
addEventHandler("onClientMouseLeave"getRootElement(), function()
    if (source == reg.button_loginthen
        guiLabelSetColor(reg.button_login153156175)
    elseif (source == reg.button_regthen
        guiStaticImageLoadImage(source"assets/button_reg.png")
    end
end)

function outputChatBox (msgpl)
exports.dpChat:message (pl"global"msg)
end

function onAccountCreate()
    guiSetVisible(reg.button_regfalse)
    
    guiCreateStaticImage(4153001510"assets/iarrow.png"falsereg.back_ground)
    local xguiGetPosition (reg.label_firstfalse) 
    guiSetPosition (reg.label_firstxy-20false)
    
    guiSetText(reg.label_first"Konto utworzone!")
    guiSetFont(reg.label_firstlogin.font["RB"])
    guiLabelSetColor(reg.label_first2551680)
    
    guiSetText(reg.button_login"Powr?t")
    
    setEditBoxWarning(3""true)
    setEditBoxWarning(4""true)
    setEditBoxWarning(5""true)
end
addEvent("onAccountCreate"true)
addEventHandler("onAccountCreate"getRootElement(), onAccountCreate)


addEventHandler ("onClientGUIClick"getRootElement(), function(button)
    if button == "left" then
        if source == reg.button_login then -- назад
            guiSetVisible(reg.back_groundfalse)
            guiSetVisible(login.back_groundtrue)
        elseif source == reg.button_reg then
            -- Никнейм
            local errorChek false
            
            local nickname guiGetText(editBox[3].label_text)
            local email guiGetText(editBox[4].label_text)
            local password guiGetText(editBox[5].label_text)
            
            local nicknameLen nickname:len()
            local passwordLen password:len()
            
            if (nicknameLen and nicknameLen 11then
                if not string.find(nickname"^%w+$"then
                    errorChek true
                    setEditBoxWarning(3"Erro! Caracteres inv?lidos digitados."false)
                end
            else
                errorChek true
                setEditBoxWarning(3"B??d! Minimalne znaki: 2, maksymalne: 10"false)
            end
            
            if not string.find(email"^%w+@%w+.%w+$"then
                errorChek true
                setEditBoxWarning(4"B??d! Czy e-mail jest poprawny?."false)
            end
            
            if (passwordLen 6then
                errorChek true
                setEditBoxWarning(5"B??d! Minimalna liczba znak?w: 6"false)
            end
            
            if not errorChek then
                triggerServerEvent("onRequestRegister"getLocalPlayer(), editBox[3].texteditBox[4].texteditBox[5].text)
            end
        end
    end 
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-05-03, 11:28


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Wykonujesz zapytanie do bazy danych, w kt?rym weryfikujesz wprowadzone dane. Wtedy ustawiasz jak?? element dat? okre?laj?c? zalogowanie.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-05-03, 11:48


NiczeQ







Wiek: 28
Na forum: 2611 dni
Posty: 2



Respekt: 40

"Wilq" napisał/a:

Wykonujesz zapytanie do bazy danych, w kt?rym weryfikujesz wprowadzone dane. Wtedy ustawiasz jak?? element dat? okre?laj?c? zalogowanie.



A pom?g?by? z tym ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-05-03, 12:22


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Szukasz osoby, kt?ra wykona tak? konwersj?? Pisz ?mia?o do mnie na PW - zerknij do podpisu.
Natomiast je?li szukasz gotowego skryptu, musisz posili? si? tym dzia?em: https://gtao.pl/szukam-skryptu-modelu-mta-vt5443,3330.htm

Postaw piwo autorowi tego posta
 

 
Tagi: jak :: zrobić :: aby :: acl :: było :: mysql?
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku