Get the team a player is on ?

Im working with NPC’s and i want it to check what team a player is on and hate him if its team 1.
[lua]
AddEntityRelationship(<my problem is here>, 1, 100 )
[/lua]
What is the line to get player teams? is it like player.teamID(1). i couldn’t find it on the wiki :/.

Player:Team() is what you’re looking for.
Next time look under Player for player functions. :slight_smile:

I don’t think he’s asking how to get a certain player’s team. He’s asking what the teamID is or something. I think TeamID’s start on 1001 for some reason. shrug

I was looking for getteam i missed that, but can i do Player:Team(1), does that work for finding players on team 1 ?

Not quite, but why do you want to find all players on team 1? What you might want to do is run your code for all players and assign a value depending on their team. You’d do it this way :
[lua]
function DoStuff()
for k,v in pairs(player.GetAll( )) do
if v:Team() == 1 then
// Do stuff here.
end
end
end
[/lua]

Haha i just set it up like that and came back to tell you i figured it out, brain died back there, ended up doing this when i spawn the npc:
[lua]
function testnpc ( ply,cmd )
local tr = ply:GetEyeTrace(1000)
local ant = ents.Create(“npc_antlion”)
ant:SetPos(tr.HitPos + Vector(0,0,5))
for ,v in pairs(player.GetAll()) do
if v:Team() == 1 then
ant:AddEntityRelationship(player.GetByID(
), 1, 100 )
elseif v:Team() == 2 then
ant:AddEntityRelationship(player.GetByID(), 3, 100 )
elseif v:team() == 3 then
ant:AddEntityRelationship(player.GetByID(
), 2, 100 )
end
end
ant:Spawn()
Msg(“npc spawn”)
end
[/lua]