try this:
local levels = {
[200] = "1",
[500] = "2",
[600] = "3",
[1000] = "4",
[2000] = "5",
[3000] = "6",
[4000] = "7",
[5000] = "8",
[9000] = "9"
}
addEventHandler( "onPlayerWasted",root, function(_, killer)
if (killer and killer ~= source) then
local Rep = tonumber(getElementData(killer, "Reputation")) or 0
local kName = getPlayerName(killer)
local sName = getPlayerName(source)
setElementData(killer, "Reputation", Rep + math.random ( 20, 50 ) )
if levels[Rep] then
setElementData(killer, "Rank", ":Reputation/Reputation/Rank/Lvl".. levels[Rep] ..".png") -- :Reputation/Reputation/Rank/Lvl1.png
triggerClientEvent ( killer, "playSound", killer )
end
end
local Rep = tonumber(getElementData ( source, "Reputation" )) or 0
setElementData ( source, "Reputation", Rep - math.random ( 20, 50 ) )
end)
addEventHandler ("onPlayerLogin", root, function (_,curAcc)
setElementData(source, "Rank", getAccountData(curAcc, "Rank") or "0")
setElementData(source, "Reputation", getAccountData(curAcc, "Rep") or 0)
end)
function saveData(source, acc)
if not acc or isGuestAccount(acc)then return end
setAccountData (acc, "Rnk", getElementData(source, "Rank"))
setAccountData (acc, "Rep", getElementData(source, "Reputation"))
end
addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end)
addEventHandler ("onPlayerLogout", root, function (acc) saveData(source, acc) end)
And please tell me if there's an error or why it's not working!