[PHP] function GM:PlayerHurt( player, attacker )
if player:Team() == TEAM_ARECRUIT and attacker:Team() == TEAM_ARECRUIT then
return false
end
end[/PHP]
why wont it work?
//Thanks :)
try this
[lua]
function GM:PlayerHurt( player, attacker )
if attacker:IsPlayer() && player:Team() == attacker:Team() then
return false
end
end
[/lua]
also if this is not inside a gamemode but a external script do this
[lua]
function AntiFriendlyFire( player, attacker )
if attacker:IsPlayer() && player:Team() == attacker:Team() then
return false
end
end
hook.Add("PlayerHurt", "FriendlyFire", AntiFriendlyFire).
[/lua]
Also depending on your gamemode
mp_friendlyfire = 0 may just work
Try this.
[lua]function NoTeamDamage( ply, atk, hr, dd )
if ( ply:Team() == YOURTEAM && atk:IsPlayer() && atk:Team() == YOURTEAM ) then
ply.SetHealth(hr + dd)
end
end
hook.Add( "PlayerHurt", "NoTeamDamage", NoTeamDamage )[/lua]
Untested but should work.
[QUOTE=ColdFusion;23995984]try this
[lua]
function GM:PlayerHurt( player, attacker )
if attacker:IsPlayer() && player:Team() == attacker:Team() then
return false
end
end
[/lua]
also if this is not inside a gamemode but a external script do this
[lua]
function AntiFriendlyFire( player, attacker )
if attacker:IsPlayer() && player:Team() == attacker:Team() then
return false
end
end
hook.Add("PlayerHurt", "FriendlyFire", AntiFriendlyFire).
[/lua]
Also depending on your gamemode
mp_friendlyfire = 0 may just work[/QUOTE]
what if i have multiple teams? , i mean i have 3 different teams in 1 team, like "sniper" "rifleman" etc..
Mine should work fine if you think it doesn't. I don't think you can return false on PlayerHurt to take no damage at all.
[QUOTE=TommieBoy;23996444]Mine should work fine if you think it doesn't. I don't think you can return false on PlayerHurt to take no damage at all.[/QUOTE]
but you can shoot your friend while a enemy doo it because your friends health will restore all the time, if im right.
[QUOTE=blown25;23996468]but you can shoot your friend while a enemy doo it because your friends health will restore all the time, if im right.[/QUOTE]
No. When the person is damaged by a team member, it takes the health remaining, and the health that was inflicted, and adds it together, and sets that player's health.
People can't use it to cheat.
[QUOTE=TommieBoy;23996527]No. When the person is damaged by a team member, it takes the health remaining, and the health that was inflicted, and adds it together, and sets that player's health.
People can't use it to cheat.[/QUOTE]
okay, i will try it :) Thanks.
[editline]10:38PM[/editline]
[QUOTE=TommieBoy;23996527]No. When the person is damaged by a team member, it takes the health remaining, and the health that was inflicted, and adds it together, and sets that player's health.
People can't use it to cheat.[/QUOTE]
dang it, it did not work :/
and it doesnt show any errors.
I'm not sure then. Try looking at this [b][url=wiki.garrysmod.com/?title=Gamemode.EntityTakeDamage]Gamemode.EntityTakeDamage [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b].
And try scaling the damage to 0 if they are on the same team.
Oh, come on. At least post the right hooks. All of the above are called [b]after[/b] dealing damage.
[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerShouldTakeDamage]Gamemode.PlayerShouldTakeDamage [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[QUOTE=blown25;23996344]what if i have multiple teams? , i mean i have 3 different teams in 1 team, like "sniper" "rifleman" etc..[/QUOTE]
That would make a lot of statements then
PS flapjack is right
[QUOTE=|FlapJack|;23997812]Oh, come on. At least post the right hooks. All of the above are called [b]after[/b] dealing damage.
[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerShouldTakeDamage]Gamemode.PlayerShouldTakeDamage [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b][/QUOTE]
I was looking for a hook like this but I couldn't find it XD.
ty
Sorry, you need to Log In to post a reply to this thread.