I recently added a pointshop to my TTT server that gives or takes points when you kill enemies and allies respectively. I’ve run into some problems though. When the round ends, every surviving player tries to kill everyone else. Unfortunately, when you kill allies, you lose points. How can I change this so that it only gives/takes points when there is an active round?
hook.Add("DoPlayerDeath", "ShowKiller", function(victim, attacker)
if attacker:IsPlayer() then
victim:PrintMessage(HUD_PRINTTALK, "You have been killed by "..attacker:Nick()..". He was a "..attacker:GetRoleString()..".")
elseif not attacker:IsPlayer() then
victim:PrintMessage(HUD_PRINTTALK, "You were killed by some entity!")
end
if victim:IsPlayer() and attacker:IsPlayer() then
if attacker:GetRoleString() == "traitor" and victim:GetRoleString() ~= "traitor" then
attacker:PS_GivePoints(10)
attacker:PS_Notify("You've been given ", 10, " for killing "..victim:Nick().."!")
elseif attacker:GetRoleString() ~= "traitor" and victim:GetRoleString() == "traitor" then
attacker:PS_GivePoints(15)
attacker:PS_Notify("You've been given ", 15, " for killing "..victim:Nick().."!")
elseif attacker:GetRoleString() ~= "traitor" and victim:GetRoleString() ~= "traitor" and attacker:Nick() ~= victim:Nick() then
attacker:PS_GivePoints(-15)
attacker:PS_Notify("You've lost ", 15, " for killing "..victim:Nick().."!")
elseif attacker:GetRoleString() == "traitor" and victim:GetRoleString() == "traitor" and attacker:Nick() ~= victim:Nick() then
attacker:PS_GivePoints(-20)
attacker:PS_Notify("You've lost ", 20, " for killing "..victim:Nick().."!")
end
end
end)
hook.Add("DoPlayerDeath", "ShowKiller", function(victim, attacker)
if GetRoundState() ~= "ROUND_ACTIVE" then return false end
if attacker:IsPlayer() then
victim:PrintMessage(HUD_PRINTTALK, "You have been killed by "..attacker:Nick()..". He was a "..attacker:GetRoleString()..".")
elseif not attacker:IsPlayer() then
victim:PrintMessage(HUD_PRINTTALK, "You were killed by some entity!")
end
if victim:IsPlayer() and attacker:IsPlayer() then
if attacker:GetRoleString() == "traitor" and victim:GetRoleString() ~= "traitor" then
attacker:PS_GivePoints(10)
attacker:PS_Notify("You've been given ", 10, " for killing "..victim:Nick().."!")
elseif attacker:GetRoleString() ~= "traitor" and victim:GetRoleString() == "traitor" then
attacker:PS_GivePoints(15)
attacker:PS_Notify("You've been given ", 15, " for killing "..victim:Nick().."!")
elseif attacker:GetRoleString() ~= "traitor" and victim:GetRoleString() ~= "traitor" and attacker:Nick() ~= victim:Nick() then
attacker:PS_GivePoints(-15)
attacker:PS_Notify("You've lost ", 15, " for killing "..victim:Nick().."!")
elseif attacker:GetRoleString() == "traitor" and victim:GetRoleString() == "traitor" and attacker:Nick() ~= victim:Nick() then
attacker:PS_GivePoints(-20)
attacker:PS_Notify("You've lost ", 20, " for killing "..victim:Nick().."!")
end
end
end)
hook.Add("DoPlayerDeath", "ShowKiller", function(victim, attacker)
if attacker:IsPlayer() and GetRoundState() == "ROUND_ACTIVE" then
victim:PrintMessage(HUD_PRINTTALK, "You have been killed by "..attacker:Nick()..". He was a "..attacker:GetRoleString()..".")
elseif not attacker:IsPlayer() then
victim:PrintMessage(HUD_PRINTTALK, "You were killed by some entity!")
end
if victim:IsPlayer() and attacker:IsPlayer() and GetRoundState() == "ROUND_ACTIVE" then
if attacker:GetRoleString() == "traitor" and victim:GetRoleString() ~= "traitor" then
attacker:PS_GivePoints(10)
attacker:PS_Notify("You've been given ", 10, " for killing "..victim:Nick().."!")
elseif attacker:GetRoleString() ~= "traitor" and victim:GetRoleString() == "traitor" then
attacker:PS_GivePoints(15)
attacker:PS_Notify("You've been given ", 15, " for killing "..victim:Nick().."!")
elseif attacker:GetRoleString() ~= "traitor" and victim:GetRoleString() ~= "traitor" and attacker:Nick() ~= victim:Nick() then
attacker:PS_GivePoints(-15)
attacker:PS_Notify("You've lost ", 15, " for killing "..victim:Nick().."!")
elseif attacker:GetRoleString() == "traitor" and victim:GetRoleString() == "traitor" and attacker:Nick() ~= victim:Nick() then
attacker:PS_GivePoints(-20)
attacker:PS_Notify("You've lost ", 20, " for killing "..victim:Nick().."!")
end
end
end)