Relationship for NPC_TURRET_FLOOR

Hi. I am trying to set up an NPC floor turret and make it shoot zombies for a mod called Zombie Survival.
I spawned the turret with the following code:

[lua] local turret = ents.Create (“npc_turret_floor”)
turret:SetOwner (pl)
turret:SetPos (pl:GetPos())
turret:Spawn()

for k, humans in pairs (team.GetPlayers (TEAM_HUMAN)) do
turret:AddEntityRelationship (humans,3,99)
end

for k,zombies in pairs (team.GetPlayers( TEAM_UNDEAD ) ) do
turret:AddEntityRelationship (zombies,1,99)
end

[/lua]

I haven’t worked with NPCs so far, but it’s a non-movable turret. It doesn’t need a path to move on or something like that. I don’t know why this simple command doesn’t do its job right.
NOTE: I spawn the turret after I’ve spawned all the bots.
NOTE#2: Pl = Spawner
NOTE#3: If i erase all the ‘addentityrelationship’ functions, it attacks my teammates, but doesn’t attack zombie players.

  1. What is wrong with this?
  2. Is there anything missing? (I don’t know, probably a function that makes him ‘start on’, a spawnflag, etc)

If you’re sure that the zombies you have tested it on are human players and not npc’s, I have made a gun that does what you’re trying to do, and here’s the code I used to set the relationships:

[lua] for k,v in pairs(player.GetAll()) do
if v:Team() != self.Owner:Team() then
turret:AddEntityRelationship(v, D_HT, 999)
else
turret:AddEntityRelationship(v, D_LI, 999)
end
end

for k,v in pairs(ents.FindByClass("npc_*")) do
	if v:GetClass() != "npc_rollermine" && v:GetClass() != "npc_turret_floor" then
		turret:AddEntityRelationship(v, D_HT, 999)
	end
end[/lua]

This also gives it a bad relationship with all the npcs that are not turrets or rollermines.
Also make sure that this code is running serverside, (not/not only) clientside.

The code is serverside. I’ve tried with Bots and Humans. The actual zombies are Bots,not NPCs. Also, i’ve tried your code. It’s the same. The turret doesn’t attack my teammates, but doesn’t attack the enemy, either.

EDIT: I also tried spawning the turret on the Zombie Team with your code and it attacks the humans. (enemy in this case) But if you spawn it on Human team, it won’t attack the Zombie Players :<.

Wierd.

Also, I have the same problem with my code. It doesn’t work on bots. It works on players and npcs but not bots for some reason.