Zastosuj sprawdzanie rekord?w poprzez p?tle while.
while true do
local row = mysql:fetch_assoc(account)
if (not row) then break end
local loginm = v["Login"]
local haslom = v["Haslo"]
if (username == loginm) and (password == haslom) then
outputChatBox("Zalogowa?e? si? poprawnie.", player)
end
W jakim miejscu mam to w klei? ? Bo z robi?em to tak:
function loginRequest(player, username, password)
local account = mysql_query(MySQLConnect, "SELECT * FROM Konto")
for k, v in mysql_rows_assoc(account) do
while true do
local row = mysql_fetch_assoc(account)
if (not row) then break end
local loginm = v["Login"]
local haslom = v["Haslo"]
if (username == loginm) and (password == haslom) then
outputChatBox("Zalogowa?e? si? poprawnie.", player)
triggerEvent("onGraczZalogowany", getRootElement())
triggerClientEvent(player, "hideLoginWindow", getRootElement())
setElementData(player, "Zalogowany", 1)
return
end
outputChatBox("Nie poprawne has?o.", player)
return false
end
end
end
local result = mysql_query(connection, "SELECT * FROM Konto WHERE Login="..username.." Haslo="..password)
if mysql_num_rows(result) > 0 then
-- jak konto istnieje
else
-- jak nie istnieje
end
Zapewne dla tego, ?e Jacob da? Ci jako nazw? po??czenia connection a w Twoim kodzie masz MySQLConnect. Zmie? to connection na MySQLConnect i powinno ?miga?.
Zauwa?y?em to przed tob? i zamieni?em dawno ;D
Nie dzia?a nawet z zamienionym
[ Dodano: 2013-03-28, 14:48 ]
Odkry?em ?e co? jest z result jaki? b??d.
Otoczy?em funkcje if'em sprawdzaj?cym result
local result = mysql_query(MySQLConnect, "SELECT * FROM Konto WHERE Login='"..username.."' Haslo='"..password.."'")
if result then
outputChatBox("Test result.", player)
if (mysql_num_rows(result) > 0) then
I gdy klikam zaloguj, nie pokazuje si? 'Test result.'
local hostname = get("hostname") or "maxrate.pl"
local username = get("username") or "rg2_s4971"
local password = get("password") or "********"
local database = get("database") or "rg2_s4971"
local port = tonumber(get("port")) or 3306
local MySQLConnect = nil
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),
function(res)
MySQLConnect = mysql_connect(hostname, username, password, database, port)
if (not MySQLConnect) then
if (res == getThisResource()) then
cancelEvent(true, "Nieuda?o si? po??czy? z baz? danych")
end
return nil
end
return nil
end
)
addEventHandler("onResourceStop", getResourceRootElement(getThisResource()),
function ()
if (not MySQLConnect) then
return nil
end
mysql_close(MySQLConnect)
return nil
end
)
function loginRequest(player, username, password)
local result = mysql_query(MySQLConnect, "SELECT * FROM Konto WHERE Login=".. username .." Haslo=".. password)
if (mysql_num_rows(result) > 0) then
outputChatBox("Zalogowa?e? si? poprawnie.", player)
triggerEvent("onGraczZalogowany", getRootElement())
triggerClientEvent(player, "hideLoginWindow", getRootElement())
setElementData(player, "Zalogowany", 1)
else
outputChatBox("Nie poprawny Login lub Has?o", player)
end
end
Kolumny na ss:
Ostatnio zmieniony przez vipSEBOvip 2013-03-28, 15:35, w całości zmieniany 1 raz
function loginRequest(player, username, password)
local result = mysql_query(MySQLConnect, "SELECT * FROM Konto WHERE Login=".. username .." AND Haslo=".. password)
if (mysql_num_rows(result) > 0) then
outputChatBox("Zalogowa?e? si? poprawnie.", player)
triggerEvent("onGraczZalogowany", getRootElement())
triggerClientEvent(player, "hideLoginWindow", getRootElement())
setElementData(player, "Zalogowany", 1)
else
outputChatBox("Nie poprawny Login lub Has?o", player)
end
end
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