Make team_1 and team_3 friendly

Hello, I am now trying to make team_1 and team_3 not able to damage each other, i have searched this all day
I have searched numerous things all day, this is one of the things i was unable to find
if anyone has a few minutes to drop a code, that would be wonderful
Thanks! :slight_smile:



hook.Add("PlayerShouldTakeDamage", "PreventTheseTeamsFromHurtingEachhOther", function(victim, attacker)
	if attacker:IsPlayer() then
		if (attacker:Team() == 1 and victim:Team() == 3) or (attacker:Team() == 3 and victim:Team() == 1) then
			return false
		end
	end
end)


This will prevent players on team one from damaging players on team three and prevent players on team three from damaging players on team one. It does not however prevent players on the same team from attacking each other, I’m not sure if you wanted it to.

I’m not sure if it would be more appropriate to use GM:PlayerShouldTakeDamage since I’m returning something, tell me if it doesn’t seem to work. Either way it should give you an idea of how its done.



hook.Add("PlayerShouldTakeDamage", "porn", function(victim, attacker)
       if attacker:IsPlayer() then
       return !attacker:Team() == 1 and !victim:Team() == 3 or !attacker:Team() == 3 and !victim:Team() == 1
       end
end )


Thank you very much, i am working on a gamemode and i’m getting these last couple of bugs sorted out

Edit: Yeah, the friendly fire was easy to do, i just didn’t know how to do the other teams thing
Thanks!