Hi i have this in my karma settings KARMA.cv.persist = CreateConVar("ttt_karma_persist", "1") Yet my karma still resets every time theres a level change,what is it im doing wrong?
We need to see code to know what you're doing wrong?
edit:
You should try putting it in your server.cfg: ttt_karma_persist 1
That value is only the default value when used in CreateConVar. Because you already have this set on the server it won't override it.
THIS IS ALL THATS IN KARMA.LUA
---- Karma system stuff
KARMA = {}
-- ply uid -> karma table for disconnected players who might reconnect
KARMA.RememberedPlayers = {}
-- Convars, more convenient access than GetConVar bla bla
KARMA.cv = {}
KARMA.cv.enabled = CreateConVar("ttt_karma", "1", FCVAR_ARCHIVE)
KARMA.cv.strict = CreateConVar("ttt_karma_strict", "1")
KARMA.cv.starting = CreateConVar("ttt_karma_starting", "1000")
KARMA.cv.max = CreateConVar("ttt_karma_max", "10000")
KARMA.cv.ratio = CreateConVar("ttt_karma_ratio", "0.001")
KARMA.cv.killpenalty = CreateConVar("ttt_karma_kill_penalty", "15")
KARMA.cv.roundheal = CreateConVar("ttt_karma_round_increment", "5")
KARMA.cv.clean = CreateConVar("ttt_karma_clean_bonus", "30")
KARMA.cv.tbonus = CreateConVar("ttt_karma_traitorkill_bonus", "40")
KARMA.cv.tratio = CreateConVar("ttt_karma_traitordmg_ratio", "0.0003")
KARMA.cv.debug = CreateConVar("ttt_karma_debugspam", "0")
KARMA.cv.persist = CreateConVar("ttt_karma_persist", "1")
KARMA.cv.falloff = CreateConVar("ttt_karma_clean_half", "0.25")
KARMA.cv.autokick = CreateConVar("ttt_karma_low_autokick", "1")
KARMA.cv.kicklevel = CreateConVar("ttt_karma_low_amount", "500")
KARMA.cv.autoban = CreateConVar("ttt_karma_low_ban", "1")
KARMA.cv.bantime = CreateConVar("ttt_karma_low_ban_minutes", "120")
local config = KARMA.cv
local function IsDebug() return config.debug:GetBool() end
local math = math
function KARMA.InitState()
SetGlobalBool("ttt_karma", config.enabled:GetBool())
end
function KARMA.IsEnabled()
return GetGlobalBool("ttt_karma", false)
end
-- Compute penalty for hurting someone a certain amount
function KARMA.GetHurtPenalty(victim_karma, dmg)
return victim_karma * math.Clamp(dmg * config.ratio:GetFloat(), 0, 1)
end
-- Compute penalty for killing someone
function KARMA.GetKillPenalty(victim_karma)
-- the kill penalty handled like dealing a bit of damage
return KARMA.GetHurtPenalty(victim_karma, config.killpenalty:GetFloat())
end
-- Compute reward for hurting a traitor (when innocent yourself)
function KARMA.GetHurtReward(dmg)
return config.max:GetFloat() * math.Clamp(dmg * config.tratio:GetFloat(), 0, 1)
end
-- Compute reward for killing traitor
function KARMA.GetKillReward()
return KARMA.GetHurtReward(config.tbonus:GetFloat())
end
function KARMA.GivePenalty(ply, penalty)
ply:SetLiveKarma(math.max(ply:GetLiveKarma() - penalty, 0))
end
function KARMA.GiveReward(ply, reward)
reward = KARMA.DecayedMultiplier(ply) * reward
ply:SetLiveKarma(math.min(ply:GetLiveKarma() + reward, config.max:GetFloat()))
return reward
end
function KARMA.ApplyKarma(ply)
local df = 1
-- any karma at 1000 or over guarantees a df of 1, only when it's lower do we
-- need the penalty curve
if ply:GetBaseKarma() < 1000 then
local k = ply:GetBaseKarma() - 1000
if config.strict:GetBool() then
-- this penalty curve sinks more quickly, less parabolic
df = 1 + (0.0007 * k) + (-0.000002 * (k^2))
else
df = 1 + -0.0000025 * (k^2)
end
end
ply:SetDamageFactor(math.Clamp(df, 0.1, 1.0))
if IsDebug() then
print(Format("%s has karma %f and gets df %f", ply:Nick(), ply:GetBaseKarma(), df))
end
end
-- Return true if a traitor could have easily avoided the damage/death
local function WasAvoidable(attacker, victim, dmginfo)
local infl = dmginfo:GetInflictor()
if attacker:IsTraitor() and victim:IsTraitor() and IsValid(infl) and infl.Avoidable then
return true
end
return false
end
-- Handle karma change due to one player damaging another. Damage must not have
-- been applied to the victim yet, but must have been scaled according to the
-- damage factor of the attacker.
function KARMA.Hurt(attacker, victim, dmginfo)
if not IsValid(attacker) or not IsValid(victim) then return end
if attacker == victim then return end
if not attacker:IsPlayer() or not victim:IsPlayer() then return end
-- Ignore excess damage
local hurt_amount = math.min(victim:Health(), dmginfo:GetDamage())
if attacker:GetTraitor() == victim:GetTraitor() then
if WasAvoidable(attacker, victim, dmginfo) then return end
local penalty = KARMA.GetHurtPenalty(victim:GetLiveKarma(), hurt_amount)
KARMA.GivePenalty(attacker, penalty)
attacker:SetCleanRound(false)
if IsDebug() then
print(Format("%s (%f) attacked %s (%f) for %d and got penalised for %f", attacker:Nick(), attacker:GetLiveKarma(), victim:Nick(), victim:GetLiveKarma(), hurt_amount, penalty))
end
elseif (not attacker:GetTraitor()) and victim:GetTraitor() then
local reward = KARMA.GetHurtReward(hurt_amount)
reward = KARMA.GiveReward(attacker, reward)
if IsDebug() then
print(Format("%s (%f) attacked %s (%f) for %d and got REWARDED %f", attacker:Nick(), attacker:GetLiveKarma(), victim:Nick(), victim:GetLiveKarma(), hurt_amount, reward))
end
end
end
-- Handle karma change due to one player killing another.
function KARMA.Killed(attacker, victim, dmginfo)
if not IsValid(attacker) or not IsValid(victim) then return end
if attacker == victim then return end
if not attacker:IsPlayer() or not victim:IsPlayer() then return end
if attacker:GetTraitor() == victim:GetTraitor() then
-- don't penalise attacker for stupid victims
if WasAvoidable(attacker, victim, dmginfo) then return end
local penalty = KARMA.GetKillPenalty(victim:GetLiveKarma())
KARMA.GivePenalty(attacker, penalty)
attacker:SetCleanRound(false)
if IsDebug() then
print(Format("%s (%f) killed %s (%f) and gets penalised for %f", attacker:Nick(), attacker:GetLiveKarma(), victim:Nick(), victim:GetLiveKarma(), penalty))
end
elseif (not attacker:GetTraitor()) and victim:GetTraitor() then
local reward = KARMA.GetKillReward()
reward = KARMA.GiveReward(attacker, reward)
if IsDebug() then
print(Format("%s (%f) killed %s (%f) and gets REWARDED %f", attacker:Nick(), attacker:GetLiveKarma(), victim:Nick(), victim:GetLiveKarma(), reward))
end
end
end
local expdecay = math.ExponentialDecay
function KARMA.DecayedMultiplier(ply)
local max = config.max:GetFloat()
local start = config.starting:GetFloat()
local k = ply:GetLiveKarma()
if config.falloff:GetFloat() <= 0 or k < start then
return 1
elseif k < max then
-- if falloff is enabled, then if our karma is above the starting value,
-- our round bonus is going to start decreasing as our karma increases
local basediff = max - start
local plydiff = k - start
local half = math.Clamp(config.falloff:GetFloat(), 0.01, 0.99)
-- exponentially decay the bonus such that when the player's excess karma
-- is at (basediff * half) the bonus is half of the original value
return expdecay(basediff * half, plydiff)
end
return 1
end
-- Handle karma regeneration upon the start of a new round
function KARMA.RoundIncrement()
local healbonus = config.roundheal:GetFloat()
local cleanbonus = config.clean:GetFloat()
for _, ply in pairs(player.GetAll()) do
local bonus = healbonus + (ply:GetCleanRound() and cleanbonus or 0)
KARMA.GiveReward(ply, bonus)
if IsDebug() then
print(ply, "gets roundincr", incr)
end
end
-- player's CleanRound state will be reset by the ply class
end
-- When a new round starts, Live karma becomes Base karma
function KARMA.Rebase()
for _, ply in pairs(player.GetAll()) do
if IsDebug() then
print(ply, "rebased from", ply:GetBaseKarma(), "to", ply:GetLiveKarma())
end
ply:SetBaseKarma(ply:GetLiveKarma())
end
end
-- Apply karma to damage factor for all players
function KARMA.ApplyKarmaAll()
for _, ply in pairs(player.GetAll()) do
KARMA.ApplyKarma(ply)
end
end
function KARMA.NotifyPlayer(p
Did you restart your server? "exec server" in console may work(?).
Type ttt_karma_persist and see if it returns "ttt_karma_persist" = "1"
I typed karma persist in console and this came up
"ttt_karma_persist" = "1" ( def. "" )
game clientcmd_can_execute
[editline]9th August 2014[/editline]
*bump* anyone?
[QUOTE=Excelsior;45639088]I typed karma persist in console and this came up
"ttt_karma_persist" = "1" ( def. "" )
game clientcmd_can_execute
[editline]9th August 2014[/editline]
*bump* anyone?[/QUOTE]
That indicates that it is already 1.
Please use [code] tags around text. But, if you didn't change anything in the file, it won't be relevant...
In your server-console window type in: ttt_karma_persist[enter] and see if it responds with 1, or 0... If it is 0, type: ttt_karma_persist 1[enter]
Even if you change the persist convar in the file from 0 to 1, the server may cache that convar so it would need to be changed via server console window or via server.cfg ( although some of the custom convars aren't created before server.cfg is created, so game.ConsoleCommand or game.ConCommand( "ttt_karma_persist 1\n" ); could be used in a hook.Add( "Initialize" or InitPostEntity
Edit: Whoops, left window open while I typed something else up...
So ttt_karma_persist is 1, and it isn't working?
Open your sv.db on your server using SQLite Manager ( a plugin for Firefox ); see if it is possible to read the data. Alternatively, you could run this: https://dl.dropboxusercontent.com/u/26074909/tutoring/database/converting_sv_db_to_mysql.lua.html -- and see if it outputs the PData for the karma.....
your sv.db may be corrupt; if you don't store important information, try deleting it ( or rename it during a map-change / shutdown, and let the server create a new one )
Sorry, you need to Log In to post a reply to this thread.