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 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 password = md5("wedorp" .. newPass)
- 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.."'s password was sussesfully changed.")
- else
- triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "MySQL error please try again later.")
- end
- end
- end
- end
- end
- addCommandHandler("setaccountpassword", changeAccountPassword, false, false)
- function changePlayerPassword(thePlayer, commandName, newPass, newPassConfirm)
- if getElementData(thePlayer, "loggedin") then
- if not newPass or not newPassConfirm then
- outputChatBox("SYNTAX: /" .. commandName .. " [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 dbid = getElementData(thePlayer, "account:id")
- local escapedID = exports.mysql:escape_string(dbid) -- Pointless, I know -Tam
- local password = md5("wedorp" .. newPass)
- local escapedPass = exports.mysql:escape_string(password)
- local query = exports.mysql:query_free("UPDATE accounts SET password = '" .. escapedPass .. "' WHERE id = '" .. escapedID .. "'")
- if query then
- triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "Your password was sussesfully changed.")
- else
- triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "MySQL error please try again later.")
- end
- end
- end
- end
- end
- addCommandHandler("changeaccountpassword", changePlayerPassword, false, false)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement