[PHP]function playershouldtakedamage( victim, attacker )
if attacker:Team() == TEAM_wehrmachtgranadier or attacker:Team() == TEAM_WRECRUIT or attacker:Team() == TEAM_VOLK and victim:Team() == TEAM_wehrmachtgranadier then
return false
elseif attacker:Team() == TEAM_wehrmachtgranadier or attacker:Team() == TEAM_WRECRUIT or attacker:Team() == TEAM_VOLK and victim:Team() == TEAM_VOLK then
return false
elseif attacker:Team() == TEAM_wehrmachtgranadier or attacker:Team() == TEAM_WRECRUIT or attacker:Team() == TEAM_VOLK and victim:Team() == TEAM_WRECRUIT then
return false
else
return true
end
end
hook.Add( "PlayerShouldTakeDamage", "playershouldtakedamage", playershouldtakedamag[/PHP]
sorry for posting this again.
well the problem is that i cant hurt the other teams that is not in this code :/, i have tried everything but it wont work.
//Thanks
[QUOTE=thejjokerr;24014317]Why are you doing all that? Just don't allow teamkilling by:
[lua]if victim:Team() == attacker:Team() then return false else return true end[/lua]
1 line is all you need.[/QUOTE]
yes but i have 3 teams that is in 1 team if you get what i mean.
Yeah, the teams are part of one faction. The way you're doing it will get really annoying if you add more teams to a faction. Try this simple faction thing - a table remembers what faction a team belongs to, and stops you damaging people in the same faction.
[lua]
FACTION_ALLIES = 1
FACTION_AXIS = 2
TeamFactions = {}
TeamFactions[TEAM_WRECRUIT] = FACTION_AXIS
TeamFactions[TEAM_VOLK] = FACTION_AXIS
--add all your teams in that fashion, TeamFactions[whatteam] = whatfaction
local function FactionNoFriendlyFire(victim, attacker)
return TeamFactions[victim:Team()] ~= TeamFactions[attacker:Team()]
end
hook.Add("PlayerShouldTakeDamage", "FactionNoFriendlyFire", FactionNoFriendlyFire)
[/lua]
thanks alot :)! so i just keep add like this ?
TeamFactions[TEAM_VOLK] = FACTION_AXIS
TeamFactions[TEAM_VOLK2] = FACTION_AXIS
TeamFactions[TEAM_VOLK3] = FACTION_AXIS
Exactly.
Normally, you would just bump your own thread and then edit the OP or something, instead of making 3 threads about the same thing.
[QUOTE=Busymonkey;24016309]Normally, you would just bump your own thread and then edit the OP or something, instead of making 3 threads about the same thing.[/QUOTE]
lmao, true :P
Indeed.
Sorry, you need to Log In to post a reply to this thread.