Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function serverLoginAttempt(username, password, hashStr, player)
- if not player then player = client end
- local account = helper:getAccount(username)
- if not account then
- triggerClientEvent(player, "showInfoBox", player, "Ismeretlen felhasználónév.")
- return
- elseif account["banned"] == 1 then
- triggerClientEvent(player, "showInfoBox", player, "Ez az account le van tiltva! Indok: " .. account["banreason"])
- return
- elseif isElement(loggedInAccounts[account["id"]]) then
- triggerClientEvent(player, "showInfoBox", player, "Az accountba már bejelentkeztek!")
- return
- end
- if hashStr then
- if string.lower(account["loginhash"]) ~= string.lower(hashStr) then
- triggerClientEvent(player, "showInfoBox", player, "Hibás hitelesítő kód, kérlek írd be a jelszavad ismét.")
- return
- end
- else
- if string.lower(account["password"]) ~= string.lower(password) then
- triggerClientEvent(player, "showInfoBox", player, "Hibás jelszó.")
- return
- end
- end
- dbQuery(function(qh, player, accid, username, password--[[, christmas_gift--]])
- local res, rows, err = dbPoll(qh, 0)
- if rows > 0 then
- setElementData(player, "char:gameaccountid", accid)
- sendCharacterData[player] = {}
- tempCharacterCache[player] = {}
- local checkedAccount = false
- for k, v in pairs(res) do
- if not checkedAccount then
- checkedAccount = true
- tempAccountCache[player] = {v["accJailData"]}
- setElementData(player, "user:adminlevel", v["accAdminLevel"])
- if not v["accAdminNick"] or v["accAdminNick"] == "" then
- v["accAdminNick"] = "Ismeretlen admin"
- end
- setElementData(player, "user:adminnick", v["accAdminNick"])
- loggedInAccounts[accid] = player
- playerAccountIDs[player] = accid
- end
- v["accAdminNick"] = nil
- v["accAdminLevel"] = nil
- local id = v["id"]
- if id and id ~= "NULL" then
- tempCharacterCache[player][id] = v
- sendCharacterData[player][id] = {}
- table.insert(sendCharacterData[player][id], v["id"])
- table.insert(sendCharacterData[player][id], v["charactername"])
- table.insert(sendCharacterData[player][id], v["skin"])
- table.insert(sendCharacterData[player][id], {v["x"],v["y"],v["z"],v["dimension_id"]})
- table.insert(sendCharacterData[player][id], v["lastLoginTimestamp"])
- end
- end
- tempPlayerData[player] = {username, hash("sha1", math.random(1000,9000)..password)--[[, christmas_gift--]]}
- triggerClientEvent(player, "receiveCharacters", player, sendCharacterData[player], true)
- else
- triggerClientEvent(player, "showInfoBox", player, "Ismeretlen hiba történt a bejelentkezéskor.")
- end
- end, {player, account["id"], username, password--[[, account["christmas_gift"]--]]}, mysql:getConnection(), "SELECT account.jaildata AS accJailData, account.admin AS accAdminLevel, account.adminnick AS accAdminNick, karakterek.*, (CASE WHEN karakterek.lastado < CURDATE() THEN 0 ELSE 1 END) AS adolevonas, DATEDIFF(NOW(), karakterek.lastlogin) as lastLoginTimestamp FROM account LEFT JOIN karakterek ON account.id=karakterek.account WHERE account.id = ?", account["id"])
- end
- addEvent("serverLoginAttempt", true)
- addEventHandler("serverLoginAttempt", getRootElement(), function(username, password, hashStr, player)
- local co = coroutine.create(serverLoginAttempt)
- coroutine.resume(co, username, password, hashStr, player)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement