Disable pointshop during end of round

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)


thanks.

If GetRoundState() is not equal to ROUND_ACTIVE then return 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)

Try that

well, it ended up making us stuck in spectator mode with weapons and no arms, but I changed it around a bit, and it worked. Thanks guys.

The nice thing to do is to post how you solved it so anyone who stumbles upon this in the future knows what to do :slight_smile:

GetRoundState() doesn’t return a string, it returns a integer.
ROUND_ACTIVE is just a ENUM that returns a integer.

[lua]
if GetRoundState() ~= ROUND_ACTIVE then return false end
[/lua]

I was gonna say the same thing lol ;]

Oh, apologies.


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)