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
dinfo:ScaleDamage(0)
end
end)[/LUA]
My thoughts are
[lua]
function NoMorePVP(victim, attacker)
if attacker:IsPlayer() or attacker:IsNPC() then
return false
end
end
hook.Add( "PlayerShouldTakeDamage", "NoMorePVP", NoMorePVP )
[/lua]
[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.
[QUOTE=cis.joshb;28807965]Who's code?? And yay, I actually did something good in lua.[/QUOTE]
Grats you managed to edit an example from the wiki
Instead of making a longer, more useless and more laggy version? It works, anyways.
Sorry, you need to Log In to post a reply to this thread.