Disable players hurting anyone-- completely?

I need a script that disabled players hurting eachother, if they’re on the same team or not. I’ve tried sbox_plpldamage set to 1 and 0, along with sbox_godmode set to 1 and 0. The gamemode is derived from base, and there isn’t anything changing how damage against players is handled.

tl;dr: Need a script that stops players from hurting eachother but still lets them die from objects, sbox_plpldamage and sbox_godmode don’t seem to work

Would probably be something like this:
[LUA]hook.Add(“EntityTakeDamage”, “NoPVPDamage”, function(ent, inf, att, amount, dinfo)
if ent:IsPlayer() and (ValidEntity(inf) and inf:IsPlayer() or ValidEntity(att) and att:IsPlayer()) then

My thoughts are
function NoMorePVP(victim, attacker)
if attacker:IsPlayer() or attacker:IsNPC() then
return false



hook.Add( “PlayerShouldTakeDamage”, “NoMorePVP”, NoMorePVP )

[editline]25th March 2011[/editline]

Oh, I got beat to the punch.

Why the IsNPC() check? I think he only wants PVP. But yeah, removed that his code is better suited for you.

Works perfectly, thanks! :love:

Who’s code?? And yay, I actually did something good in lua.

Grats you managed to edit an example from the wiki

Instead of making a longer, more useless and more laggy version? It works, anyways.