Advertisement
Cherro

Login

Jun 2nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1. function onSubmitLogin(username, password)
  2.     if username and password then
  3.         player = source
  4.         if string.len(username)<2 then
  5.             return exports.rp_notifications:showBox (player,"Twój login musi zawierać minimum 2 znaki!")
  6.         elseif string.len(password)<2 then
  7.             return exports.rp_notifications:showBox (player,"Twoje hasło musi zawierać minimum 2 znaki!")
  8.         end
  9.        
  10.         callRemote("http://fg.cherro.pl/mtalogin/loginAuth.php", function(bool)
  11.             if bool ~= "ERROR" then
  12.                 --tab = fromJSON(bool)
  13.                 if bool[1] == true then
  14.                     local res = exports.rp_database:pobierzWyniki("SELECT * FROM FG_core_members WHERE name = ?", username)
  15.                     if res.bantime == nil or res.bantime < getRealTime().timestamp then
  16.                         setElementData(player,"accountID", res.member_id)
  17.                         if tonumber(res.premium) == nil or res.premium < getRealTime().timestamp then
  18.                             setElementData(player, "premiumPlayer", false)
  19.                         else
  20.                             setElementData(player, "premiumPlayer", true)
  21.                         end
  22.                         --setElementData(player, "k:premium", res.premium > getRealTime().timestamp and true or false)
  23.                         local ip = getPlayerIP(player)
  24.                         local serial = getPlayerSerial(player)
  25.                         triggerClientEvent(player,"l:hide",root)
  26.                         triggerClientEvent(player,"l:cursor",root)
  27.                         exports.rp_logs:addLog(player,"[LOGIN_ACCOUNTS] Logowanie na konto (sukces).")
  28.                         setElementData(player, "loggedIn", 1)
  29.                     else
  30.                         return exports.rp_notifications:showBox(player, "Twoje konto jest zbanowane.")
  31.                     end
  32.                 elseif bool[1] == false then
  33.                     return exports.rp_notifications:showBox(player, string.format("%s", bool[2]))
  34.                 else
  35.                     return exports.rp_notifications:showBox(player, "Błąd w trakcie logowania. Skontaktuj się z administratorem.")
  36.                 end
  37.             else
  38.                 return exports.rp_notifications:showBox(source, "Błąd w trakcie logowania. Skontaktuj się z administratorem.")
  39.             end
  40.         end, username, password)
  41.     end
  42. end
  43. addEvent("l:trylogin", true)
  44. addEventHandler("l:trylogin", getRootElement(), onSubmitLogin)
  45.  
  46. addEventHandler("onPlayerJoin", root, function()
  47. setPlayerName(source, string.format("Niezalogowany_%s", string.upper(exports.rp_utils:generateString(5))))
  48. setElementData(source, "loggedIn", 0)
  49. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement