Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. function registerPlayer(username, pw1, pw2)
  2.     if source ~= client then return end
  3.     if username ~= "" and pw1 ~= "" and pw2 ~= "" and username ~= nil and pw1 ~= nil and pw2 ~= nil then
  4.         if isNameRegistered(username) then
  5.             triggerClientEvent("onLoginOrRegisterFailed", client, "This username is already registered")
  6.         elseif isSerialRegistered(getPlayerSerial(client)) == true then
  7.             triggerClientEvent("onLoginOrRegisterFailed", client, "Already registered an account with this serial!")
  8.         else
  9.             local password = md5(pw1)
  10.             local serial = getPlayerSerial(client)
  11.             local ip = getPlayerIP(client)
  12.             local name = getPlayerName(client)
  13.            
  14.             local b = _setAccountData(0, "player_accounts", "name,password,serial,ip,lastPlayerName", "'" .. username .. "','".. password .. "','" .. getPlayerSerial(client) .. "','" .. getPlayerIP(client) .. "','" .. getPlayerName(client) .. "'")
  15.             if b then
  16.                 local userID = getIDFromName(username)
  17.                 g_userIDs[client] = userID
  18.                 local b2 = _setAccountData(0, "player_datas", "ID", userID)
  19.                 local b3 = _setAccountData(0, "player_weapons", "ID", userID)
  20.                 local b4 = _setAccountData(0, "player_inventory", "ID", userID)
  21.                 local b5 = _setAccountData(0, "player_skills", "ID", userID)
  22.                 local b6 = _setAccountData(0, "player_achievements", "ID", userID)
  23.                 local b7 = _setAccountData(0, "player_settings", "ID", userID)
  24.                 if b2 and b3 and b4 and b5 and b6 and b7 then
  25.                     triggerClientEvent("onClientLoginSuccess", client)
  26.                     onLogin(client, userID)
  27.                 else
  28.                     triggerClientEvent("onLoginOrRegisterFailed", client, "Error while creating your account. Please contact an admin!")
  29.                 end
  30.             else
  31.                 triggerClientEvent("onLoginOrRegisterFailed", client, "Error while creating your account. Please contact an admin!")
  32.             end
  33.         end
  34.     else
  35.         triggerClientEvent("onLoginOrRegisterFailed", client, "Invalid username or password!")
  36.     end
  37. end
  38. addEvent("onClientRegister", true)
  39. addEventHandler("onClientRegister", root, registerPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement