How can I check if someone killed another person, if they were a traitor/innocent/detective and give people points in the pointshop?

  1. How can i check if someone kills another player

  2. How can i check if soemone is inno/traitor/detective

  3. How can i give someone points in the pointshop

Please and thank you


//lua/autorun/server
//Code by brandonj4

hook.Add("Initialize", "Points.Initialize", function()
	if !ROLE_INNOCENT then return end
	
	local RolePoints = {
		[ROLE_DETECTIVE] = {
			[ROLE_DETECTIVE] = -30,
			[ROLE_INNOCENT] = -10,
			[ROLE_TRAITOR] = 200
		},
		[ROLE_INNOCENT] = {
			[ROLE_DETECTIVE] = -50,
			[ROLE_INNOCENT] = -20,
			[ROLE_TRAITOR] = 50
		},
		[ROLE_TRAITOR] = {
			[ROLE_DETECTIVE] = 200,
			[ROLE_INNOCENT] = 25,
			[ROLE_TRAITOR] = -30
		}
	}
	
	local function NotifyPlayer(ply, killer)
		local num = RolePoints[killer:GetRole()][ply:GetRole()]
		local bool = string.find(num, "-")
		if bool then
			killer:PrintMessage(HUD_PRINTTALK, "[TTT] Shop: You had "..num.." points taken away for killing "..ply:Nick()..", they were a(n) "..ply:GetRoleString()..".")
		else
			killer:PrintMessage(HUD_PRINTTALK, "[TTT] Shop: You were awarded "..num.." points for killing "..ply:Nick()..", they were a(n) "..ply:GetRoleString()..".")
		end
		
		 killer:PS_GivePoints(num)
	end

	hook.Add("DoPlayerDeath", "PS.GivePointsOnDeath", function(ply, killer, dmginfo)
		if !IsValid(killer) or !killer:IsPlayer() or !IsValid(ply) or !ply:IsPlayer() or (ply == killer) or !ply:Alive() then return end
		if GetRoundState() == ROUND_ACTIVE then
			NotifyPlayer(ply, killer)
		end
	end)
end)

  1. Using a hook
  2. ply:IsTraitor(), ply:IsInnocent(), ply:IsDetective()
  3. PS_GivePoints() – might be wrong