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

Wysłany: 2016-06-04, 19:45


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4045 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

Mam problem bo nie mog? zrobi? konta
ps logowanie z Our Life

Plik ML-DB
Kod:


-- Settings
SQL_HANDLER=nil
SQL_HOST="tajne"
SQL_DBNAME="tajne"
SQL_DBUSER="tajne"
SQL_DBPASS="tajne"

-- Functions
local function onConnect()
SQL_HANDLER=dbConnect("mysql", "dbname="..SQL_DBNAME..";host="..SQL_HOST.."", SQL_DBUSER, SQL_DBPASS, "share=1");
if SQL_HANDLER then
outputDebugString("<ml-db> Connecting to MYSQL...");
else
outputDebugString("<ml-db> No Connecting to MYSQL...");
end
end

function setRekord(...)
if not {...} then return end
local query=dbExec(SQL_HANDLER, ...)
return query
end

function getRekord(...)
if not {...} then return end
local query=dbQuery(SQL_HANDLER, ...)
local result=dbPoll(query, -1)
return result
end

function zapytanie(...) -- zostaw to lepiej
local h=dbQuery(SQL_HANDLER,...)
local result,numrows=dbPoll(h,-1)
return numrows
end

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onConnect)


Plik ML-Logowanie

addEvent("logging:checkAccount"true)
addEventHandler("logging:checkAccount"resourceRoot, function(login,pass)
    local result=exports["ML-db"]:dbGet("SELECT * FROM ML-Users WHERE login=?"login)
    if result and #result > 0 then
        if result[1].login == login and result[1].pass == md5(passthen
            setPlayerName(clientlogin)
            setElementData(client"player:uid"result[1].id)
            triggerClientEvent(client"logging:result"resourceRoottruenil)
        else
            triggerClientEvent(client"logging:result"resourceRootfalse"Podane dane s?&#8230; nieprawid?&#8218;owe.")
        end
    else
        triggerClientEvent(client"logging:result"resourceRootfalse"Podany login nie istnieje w bazie.")
    end
end)

addEvent("logging:newAccount"true)
addEventHandler("logging:newAccount"resourceRoot, function(login,pass)
    local result=exports["ML-db"]:dbGet("SELECT * FROM ML-Users WHERE login=?"login)
    if result and #result > 0 then
        triggerClientEvent(client"logging:result"resourceRootfalse"Podany login ju?? istnieje w bazie.")
    else
        local query=exports["ML-db"]:dbSet("INSERT INTO ML-Users (login,pass) VALUES (?,?)"loginmd5(pass))
        if query then
            triggerClientEvent(client"logging:result"resourceRootfalse"Pomy?&#8250;lnie zalogowa?&#8218;e?&#8250;(a?&#8250;) si?&#8482;")
        end
    end
end)


Doda?em znaczniki code//Emm

Ostatnio zmieniony przez Emm 2016-06-05, 11:48, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-05, 14:41


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4838 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3

Na pewno kolumny w bazie to login, pass a tabela si? nazywa ML-Users?

Podpis
Jedyny kontakt ze mną to PW forum

Kod:


local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Postaw piwo autorowi tego posta
 

 
Tagi: logowanie :: 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 » logowanie mysql Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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