Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function changeAccountPassword(thePlayer, commandName, accountUsername, newPass, newPassConfirm)
- if exports.integration:isPlayerSeniorAdmin(thePlayer) then
- if not accountUsername or not newPass or not newPassConfirm then
- outputChatBox("SYNTAX: /" .. commandName .. " [Account Username] [New Password] [Confirm Pass]", thePlayer, 125, 125, 125)
- else
- if (newPass ~= newPassConfirm) then
- triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "The passwords do not match.")
- elseif (string.len(newPass)<6) then
- triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "Your password is too short. \n You must enter 6 or more characters.")
- elseif (string.len(newPass)>=30) then
- triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "Your password is too long. \n You must enter less than 30 characters.")
- elseif (string.find(newPass, ";", 0)) or (string.find(newPass, "'", 0)) or (string.find(newPass, "@", 0)) or (string.find(newPass, ",", 0)) then
- triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "Your password cannot contain ;,@'.")
- else
- local accountData
- local account = exports.mysql:query("SELECT id, salt FROM accounts WHERE username ='"..exports.mysql:escape_string(accountUsername).."' LIMIT 1")
- if (mysql:num_rows(account) > 0) then
- accountData = mysql:fetch_assoc(account)
- mysql:free_result(account)
- else
- triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "No account with that username was found.")
- return
- end
- local encryptionRule = accountData["salt"]
- local password = string.lower(md5(string.lower(md5(newPass))..encryptionRule))
- local escapedPass = exports.mysql:escape_string(password)
- local query = exports.mysql:query_free("UPDATE accounts SET password = '" .. escapedPass .. "' WHERE id = '" .. accountData["id"] .. "'")
- if query then
- triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, accountUsername.." a fost schimbată cu succes.")
- else
- triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "MySQL error please try again later.")
- end
- end
- end
- end
- end
- addCommandHandler("setaccountpassword", changeAccountPassword, false, false)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement