exports.scoreboard:scoreboardAddColumn("ExP")
exports.scoreboard:scoreboardAddColumn("Level")
local levels = {[1] = 1, [50] = 2, [75] = 3, [240] = 4, [950] = 5, [1200] = 6, [2000] = 7, [5000] = 8, [9963] = 9, [20000] = 10, [100000] = 11}
function win(ammo, killer, weapon, bodypart)
if (killer and killer ~= source) then
local H = getElementData(killer, "ExP")
local S = getElementData(killer, "Level")
local killer1 = getPlayerName(killer)
local noob = getPlayerName(source)
setElementData(killer, "ExP", tonumber(H)+math.random ( 5, 35 ) )
if levels[tonumber(H)] then
setElementData(killer, "Level", "Lvl ".. tostring(levels[tonumber(H)]) .." !")
triggerClientEvent ( killer, "playSound", killer )
end
end
local H = getElementData ( source, "ExP" ) or 0
setElementData ( source, "ExP", tonumber ( H ) - math.random ( 5, 35 ) )
end
addEventHandler( "onPlayerWasted", getRootElement(), win)
function onLogin (_,account)
setElementData(source, "Level", getAccountData(account, "lvl") or "Level 0 ")
setElementData(source, "ExP", getAccountData(account, "exp") or "0")
end
addEventHandler ("onPlayerLogin", root, onLogin)
function saveData(thePlayer, theAccount)
if (theAccount and not isGuestAccount(theAccount)) then
setAccountData (theAccount, "lvl", getElementData(thePlayer, "Level"))
setAccountData (theAccount, "exp", getElementData(thePlayer, "ExP"))
end
end
addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end)
addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end)