c_tKillsD = CreateConVar("ttt_rewards_tkillsd", "20", FCVAR_NOTIFY, "The amount of points a player gets when they kill a Detective as Traitor.") c_tKillsT = CreateConVar("ttt_rewards_tkillst", "-10", FCVAR_NOTIFY, "The amount of points a player gets when they kill their Traitor friend.") c_tKillsI = CreateConVar("ttt_rewards_tkillsi", "10", FCVAR_NOTIFY, "The amount of points a player gets when they kill an Innocent as Traitor.") c_iKillsT = CreateConVar("ttt_rewards_ikillst", "10", FCVAR_NOTIFY, "The amount of points a player gets when they kill a Traitor as an Innocent.") c_iKillsI = CreateConVar("ttt_rewards_ikillsi", "-10", FCVAR_NOTIFY, "The amount of points a player gets when they kill an Innocent as an Innocent.") c_iKillsD = CreateConVar("ttt_rewards_ikillsd", "-20", FCVAR_NOTIFY, "The amount of points a player gets when they kill a Detective as an Innocent.") c_dKillsT = CreateConVar("ttt_rewards_dkillst", "10", FCVAR_NOTIFY, "The amount of points a player gets when they kill a Traitor as a Detective.") c_dKillsI = CreateConVar("ttt_rewards_dkillsi", "-10", FCVAR_NOTIFY, "The amount of points a player gets when they kill an Innocent as a Detective.") c_dKillsD = CreateConVar("ttt_rewards_dkillsd", "-20", FCVAR_NOTIFY, "The amount of points a player gets when they kill a Detective as a Detective.") c_tStaysAlive = CreateConVar("ttt_rewards_tstaysalive", "10", FCVAR_NOTIFY, "The amount of points a player gets when they stay alive the whole round as a Traitor.") c_iStaysAlive = CreateConVar("ttt_rewards_istaysalive", "10", FCVAR_NOTIFY, "The amount of points a player gets when they stay alive the whole round as an Innocent.") c_dStaysAlive = CreateConVar("ttt_rewards_dstaysalive", "10", FCVAR_NOTIFY, "The amount of points a player gets when they stay alive the whole round as a Detective.") c_iWinsRound = CreateConVar("ttt_rewards_iwinsround", "10", FCVAR_NOTIFY, "The amount of points a player gets when they win a round as an Innocent.") c_tWinsRound = CreateConVar("ttt_rewards_twinsround", "10", FCVAR_NOTIFY, "The amount of points a player gets when they win a round as an Traitor.") c_dWinsRound = CreateConVar("ttt_rewards_dwinsround", "10", FCVAR_NOTIFY, "The amount of points a player gets when they win a round as an Detective.") c_bodyIdentified = CreateConVar("ttt_rewards_bodyidentified", "10", FCVAR_NOTIFY, "The amount of points a player gets when they identify a body as an Innocent or Detective.") c_amountNeededToActivate = CreateConVar("ttt_rewards_playersneeded", "4", FCVAR_NOTIFY, "The amount of players needed at the start of a round for the players to get their points.") local playerM = FindMetaTable("Player") local pointsCount = false function playerM:TTTRewards_GivePoints(points) if not pointsCount then return end if(self.points == nil) then self.points = points else self.points = self.points + points end end function playerM:TTTRewards_GetPoints() if self.points == nil then self.points = 0 end return self.points end function playerM:TTTRewards_ResetPoints() self.points = 0 end function PrintToChat(msg) for i,v in pairs(player.GetAll()) do v:PrintMessage(HUD_PRINTTALK, msg) end end hook.Add("TTTBeginRound", "TTTRewards_TTTBeginFound", function() pointsCount = (#player.GetAll() >= c_amountNeededToActivate:GetInt()) if not pointsCount then PrintToChat("[TTT REWARDS] You will not get points for this round.") end end) hook.Add("TTTBodyFound", "TTTRewards_TTTBodyFound", function(ply) if(ply:GetRole() == ROLE_INNOCENT or ply:GetRole() == ROLE_TRAITOR) then ply:TTTRewards_GivePoints(c_bodyIdentified:GetInt()) end end) hook.Add("PlayerDeath", "TTTRewards_PlayerDeath", function(victim, inflictor, attacker) if(victim:IsPlayer() and attacker:IsPlayer()) then if(attacker:GetRole() == ROLE_TRAITOR) then if(victim:GetRole() == ROLE_INNOCENT) then attacker:TTTRewards_GivePoints(c_tKillsI:GetInt()) elseif(victim:GetRole() == ROLE_DETECTIVE) then attacker:TTTRewards_GivePoints(c_tKillsD:GetInt()) elseif(victim:GetRole() == ROLE_TRAITOR) then attacker:TTTRewards_GivePoints(c_tKillsD:GetInt()) end elseif(attacker:GetRole() == ROLE_INNOCENT) then if(victim:GetRole() == ROLE_TRAITOR) then attacker:TTTRewards_GivePoints(c_iKillsT:GetInt()) elseif(victim:GetRole() == ROLE_INNOCENT) then attacker:TTTRewards_GivePoints(c_iKillsI:GetInt()) elseif(victim:GetRole() == ROLE_DETECTIVE) then attacker:TTTRewards_GivePoints(c_iKillsD:GetInt()) end elseif(attacker:GetRole() == ROLE_DETECTIVE) then if(victim:GetRole() == ROLE_TRAITOR) then attacker:TTTRewards_GivePoints(c_dKillsD:GetInt()) elseif(victim:GetRole() == ROLE_INNOCENT) then attacker:TTTRewards_GivePoints(c_dKillsI:GetInt()) elseif(victim:GetRole() == ROLE_DETECTIVE) then attacker:TTTRewards_GivePoints(c_dKillsD:GetInt()) end end end end) hook.Add("TTTEndRound", "TTTRewards_RoundEnd", function(result) if not pointsCount then PrintToChat("[TTT REWARDS] Nobody got points for this round.") return end for i,v in pairs(player.GetAll()) do points = v:TTTRewards_GetPoints() v:TTTRewards_ResetPoints() if(v:GetRole() == ROLE_INNOCENT) then v:TTTRewards_GivePoints(c_iStaysAlive:GetInt()) if(result == WIN_INNOCENT) then v:TTTRewards_GivePoints(c_iWinsRound:GetInt()) end elseif(v:GetRole() == ROLE_TRAITOR) then v:TTTRewards_GivePoints(c_tStaysAlive:GetInt()) if(result == WIN_TRAITOR) then v:TTTRewards_GivePoints(c_tWinsRound:GetInt()) end elseif(v:GetRole() == ROLE_DETECTIVE) then v:TTTRewards_GivePoints(c_dStaysAlive:GetInt()) if(result == WIN_INNOCENT) then v:TTTRewards_GivePoints(c_dWinsRound:GetInt()) end end local notification = "notification.AddLegacy('You " if(points > 0) then notification = notification.."earned "..tostring(points) else notification = notification.."lost "..string.sub(tostring(points), 1) end notification = notification.." points for your actions during this round!', NOTIFY_GENERIC, 5)" print(notification) v:SendLua(notification) v:PS_GivePoints(points) end end) hook.Add("PlayerDisconnected", "TTTRewards_PlayerDisconnect", function(ply) ply:PS_Save() end)