Advertisement
Guest User

asd

a guest
Jul 28th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.35 KB | None | 0 0
  1. function serverLoginAttempt(username, password, hashStr, player)
  2.     if not player then player = client end
  3.    
  4.     local account = helper:getAccount(username)
  5.     if not account then
  6.         triggerClientEvent(player, "showInfoBox", player, "Ismeretlen felhasználónév.")
  7.         return
  8.     elseif account["banned"] == 1 then
  9.         triggerClientEvent(player, "showInfoBox", player, "Ez az account le van tiltva! Indok: " .. account["banreason"])
  10.         return
  11.     elseif isElement(loggedInAccounts[account["id"]]) then
  12.         triggerClientEvent(player, "showInfoBox", player, "Az accountba már bejelentkeztek!")
  13.         return
  14.     end
  15.    
  16.     if hashStr then
  17.         if string.lower(account["loginhash"]) ~= string.lower(hashStr) then
  18.             triggerClientEvent(player, "showInfoBox", player, "Hibás hitelesítő kód, kérlek írd be a jelszavad ismét.")
  19.             return
  20.         end
  21.     else
  22.         if string.lower(account["password"]) ~= string.lower(password) then
  23.             triggerClientEvent(player, "showInfoBox", player, "Hibás jelszó.")
  24.             return
  25.         end
  26.     end
  27.    
  28.     dbQuery(function(qh, player, accid, username, password--[[, christmas_gift--]])
  29.         local res, rows, err = dbPoll(qh, 0)
  30.         if rows > 0 then
  31.             setElementData(player, "char:gameaccountid", accid)
  32.             sendCharacterData[player] = {}
  33.             tempCharacterCache[player] = {}
  34.             local checkedAccount = false
  35.             for k, v in pairs(res) do
  36.                 if not checkedAccount then
  37.                     checkedAccount = true
  38.                     tempAccountCache[player] = {v["accJailData"]}
  39.                     setElementData(player, "user:adminlevel", v["accAdminLevel"])
  40.                     if not v["accAdminNick"] or v["accAdminNick"] == "" then
  41.                         v["accAdminNick"] = "Ismeretlen admin"
  42.                     end
  43.                     setElementData(player, "user:adminnick", v["accAdminNick"])
  44.                     loggedInAccounts[accid] = player
  45.                     playerAccountIDs[player] = accid
  46.                 end
  47.                
  48.                 v["accAdminNick"] = nil
  49.                 v["accAdminLevel"] = nil
  50.                
  51.                 local id = v["id"]
  52.                 if id and id ~= "NULL" then
  53.                     tempCharacterCache[player][id] = v
  54.                     sendCharacterData[player][id] = {}
  55.                     table.insert(sendCharacterData[player][id], v["id"])
  56.                     table.insert(sendCharacterData[player][id], v["charactername"])
  57.                     table.insert(sendCharacterData[player][id], v["skin"])
  58.                     table.insert(sendCharacterData[player][id], {v["x"],v["y"],v["z"],v["dimension_id"]})
  59.                     table.insert(sendCharacterData[player][id], v["lastLoginTimestamp"])
  60.                 end
  61.             end
  62.             tempPlayerData[player] = {username, hash("sha1", math.random(1000,9000)..password)--[[, christmas_gift--]]}
  63.             triggerClientEvent(player, "receiveCharacters", player, sendCharacterData[player], true)
  64.         else
  65.             triggerClientEvent(player, "showInfoBox", player, "Ismeretlen hiba történt a bejelentkezéskor.")
  66.         end
  67.     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"])
  68. end
  69.  
  70. addEvent("serverLoginAttempt", true)
  71. addEventHandler("serverLoginAttempt", getRootElement(), function(username, password, hashStr, player)
  72.     local co = coroutine.create(serverLoginAttempt)
  73.     coroutine.resume(co, username, password, hashStr, player)
  74. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement