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
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 ( pass ) then
setPlayerName ( client , login )
setElementData ( client , "player:uid" , result [ 1 ]. id )
triggerClientEvent ( client , "logging:result" , resourceRoot , true , nil )
else
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Podane dane s?… nieprawid?‚owe." )
end
else
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "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" , resourceRoot , false , "Podany login ju?? istnieje w bazie." )
else
local query = exports [ "ML-db" ]: dbSet ( "INSERT INTO ML-Users (login,pass) VALUES (?,?)" , login , md5 ( pass ))
if query then
triggerClientEvent ( client , "logging:result" , resourceRoot , false , "Pomy?›lnie zalogowa?‚e?›(a?›) si?™" )
end
end
end )
Doda?em znaczniki code//Emm
Ostatnio zmieniony przez Emm 2016-06-05, 11:48, w całości zmieniany 1 raz
Wysłany: 2016-06-05, 14:41
Jurandovsky
Kurdebele
Wiek: 17 Na forum: 4838 dni Posty: 915
Piwa : 2697
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
Tagi: logowanie :: mysql
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: