Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.54 KB | None | 0 0
  1. function registerPlayer(user, Senha, conf)
  2.     if user == "" then
  3.         outputLoginMsg(source, "Preencha todos os campos!", "error")
  4.     else
  5.         if Senha == "" then
  6.             outputLoginMsg(source, "Preencha todos os campos!", "error")
  7.         else
  8.             if conf == "" then
  9.                 outputLoginMsg(source, "Preencha todos os campos!", "error")
  10.             else
  11.                 if conf == Senha then
  12.                     addAccount(tostring(user),tostring(Senha))
  13.                     triggerClientEvent(source, "onRoyalRegister", source)
  14.                     local time = getRealTime()
  15.                     local days = tonumber(time.monthday)
  16.                     local months = tonumber(time.month)
  17.                     local years = tonumber(time.year)
  18.                     local Serial = getPlayerSerial(source)
  19.                     local query = db:query("SELECT * FROM RoyalLifeUsers WHERE Usuario=? LIMIT 1", user)
  20.                     local userCode = math.random(0,9)..""..math.random(0,9)..""..math.random(0,9)..""..math.random(0,9)
  21.                     local codeVerify = db:query("SELECT * FROM RoyalLifeUsers WHERE Codigo=?", userCode)
  22.                     if #query == 0 then
  23.                         while #codeVerify == 0 then
  24.                             local userCode = math.random(0,9)..""..math.random(0,9)..""..math.random(0,9)..""..math.random(0,9)
  25.                             local codeVerify = db:query("SELECT * FROM RoyalLifeUsers WHERE Codigo=?", userCode)
  26.                             db:exec("INSERT INTO RoyalLifeUsers VALUES (?, ?, ?, ?, ?, ?, ?)", countIDs(), getPlayerName(source):gsub("#%x%x%x%x%x%x", ""), user, Senha, days.."/"..months+(1).."/"..years-(100), Serial, userCode)      
  27.                             outputDebugString("Código da conta \""..user.."\", foram gravados em nosso banco de dados.", 0, 16, 102, 231)
  28.                             outputDebugString("Código da conta \""..user.."\", foi gerado ("..userCode..")"!", 0, 255, 255, 255)      
  29.                        end
  30.                    end
  31.                    outputLoginMsg(source, "Conta criada com sucesso! Aguarde...", "success")
  32.                    if not getAccount(user, Senha) then
  33.                        outputLoginMsg(source, "Esta conta já está sendo utilizada!", "error")
  34.                    end
  35.                else
  36.                    outputLoginMsg(source, "As senhas não estão iguais.", "error")
  37.                end
  38.            end
  39.        end
  40.    end
  41. end
  42. addEvent("onPlayerRequestRegister", true)
  43. addEventHandler("onPlayerRequestRegister", root, registerPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement