Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function registerPlayer(username, pw1, pw2)
- if source ~= client then return end
- if username ~= "" and pw1 ~= "" and pw2 ~= "" and username ~= nil and pw1 ~= nil and pw2 ~= nil then
- if isNameRegistered(username) then
- triggerClientEvent("onLoginOrRegisterFailed", client, "This username is already registered")
- elseif isSerialRegistered(getPlayerSerial(client)) == true then
- triggerClientEvent("onLoginOrRegisterFailed", client, "Already registered an account with this serial!")
- else
- local password = md5(pw1)
- local serial = getPlayerSerial(client)
- local ip = getPlayerIP(client)
- local name = getPlayerName(client)
- local b = _setAccountData(0, "player_accounts", "name,password,serial,ip,lastPlayerName", "'" .. username .. "','".. password .. "','" .. getPlayerSerial(client) .. "','" .. getPlayerIP(client) .. "','" .. getPlayerName(client) .. "'")
- if b then
- local userID = getIDFromName(username)
- g_userIDs[client] = userID
- local b2 = _setAccountData(0, "player_datas", "ID", userID)
- local b3 = _setAccountData(0, "player_weapons", "ID", userID)
- local b4 = _setAccountData(0, "player_inventory", "ID", userID)
- local b5 = _setAccountData(0, "player_skills", "ID", userID)
- local b6 = _setAccountData(0, "player_achievements", "ID", userID)
- local b7 = _setAccountData(0, "player_settings", "ID", userID)
- if b2 and b3 and b4 and b5 and b6 and b7 then
- triggerClientEvent("onClientLoginSuccess", client)
- onLogin(client, userID)
- else
- triggerClientEvent("onLoginOrRegisterFailed", client, "Error while creating your account. Please contact an admin!")
- end
- else
- triggerClientEvent("onLoginOrRegisterFailed", client, "Error while creating your account. Please contact an admin!")
- end
- end
- else
- triggerClientEvent("onLoginOrRegisterFailed", client, "Invalid username or password!")
- end
- end
- addEvent("onClientRegister", true)
- addEventHandler("onClientRegister", root, registerPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement