Hook doesn't seem to work with TTT

This is cl_rdmmanager.lua


include("player_ext_shd.lua")

function PlayerTookDamage(victim, attacker)
        if attacker:IsPlayer() and victim:IsPlayer() and IsValid(victim) and IsValid(attacker) then
                if attacker:GetRole() == ROLE_INNOCENT and victim:GetRole() == ROLE_INNOCENT then
                        attacker:ChatPrint( "You RDM'd " .. victim:Nick() )
                        victim:ChatPrint( attacker:Nick() .. " RDM'd you and has been warned." )
                end
        end
end

hook.Add("PlayerHurt", "PlayerTookDamage", PlayerTookDamage)

cl_rdmmanager.lua is located in “gamemodes errortown\gamemode” along with init.lua.

In init.lua, I have AddCSLuaFile(“cl_rdmmanager.lua”)

I’ve tried everything and can’t seem to get it to work. The basic idea is to warn the attacker if he is innocent and shoots another innocent. I only have it print the message for now so I can see if it works. Once it actually works I’m removing the message and utilizing the hook to the servers advantage so the server will handle RDM’s on its own. Anyone know what I’m doing wrong here?

Why wouldn’t you just slap the code in autorun? You would still have access to the TTT functions you are using.

But either way it isn’t working so whats the issue?

Here ya go. This goes in literally any serverside file. No need for Initialize hooks, including files, or literally anything else other than this code.

[LUA]
hook.Add( “PlayerHurt”, “shitty_rdm_detection_but_whatever_if_you_wanna_fuck_up_your_server_im_not_gunna_say_no”, function( vict, att )

if IsValid( att ) and att:IsPlayer() then
	
	local vict_role = vict:GetRole()
	local att_role = att:GetRole()

	if vict_role == ROLE_INNOCENT or vict_role = ROLE_DETECTIVE then
		
		if att_role == ROLE_INNOCENT or att_role == ROLE_DETECTIVE then
			
			-- do whatever shitty anti-rdm that you want to do.
			-- go ahead, let them know that they're hitting a non traitor.
			-- I hope you realize this will cause people to shoot eachother in the foot with pistols in order to prove their innocence.
			-- This is a really dumb anti-rdm method.

		end

	end

end

end )
[/LUA]

edit:

Am I in a business meeting? “Utilizing the hook to the servers advantage” … lol. Next you’re going to promote team synergy and aggressively negotiate for positive gains in the resource department.

Look, dude. These kinds of automatic RDM detection systems are ALWAYS ( read: ALWAYS ) shit. Please don’t try to write one yourself, it will not work. Purchase an RDM manager from coderhire or pay a guy to write on for you, just please don’t put this on whatever unlucky bastards happen to join your server.