hook a spawning NPC

Hey all,
at the moment im trying to write a small gamemode for the stargate_worlds v3 map. It divides players in goauld and tauri and spawn them on there homeworlds(temple/desert world and SGC) instead on the normal starterworld.
Now i want to add something more.
If someone spawns an Jaffa NPC i want to set thisone friendly for goauld and unfriendly for tauri. The code to set the relationship i got already.
My problem is how to “hook” the spawning NPC in my init.lua of my gamemode.

In short for all. I want to know how i can hook a spawning npc in the init.lua of my gamemode.

Greeting Obstsalat

[lua]
function spawns()
local npc_spawn = ents.Create(“npc_zombie”)
npc_spawn:SetPos(Vector(0,0,0))
npc_spawn:Spawn()
hook.Add( “Initialize”, “spawnit”, spawns)
[/lua]

list of entities here too

ok thats not what i meant.
With this code you spawn a npc.
But i want to execute some other code if some players spawn a npc.

oh sorry use this hook
[lua]
hook.Add(“PlayerSpawnedNPC”, “Npcthing”, npc_spawn)
[/lua]

thx :smiley:

Edit:
Ok, 1 small question left.
Can i use GetClass on it to get something like “npc_zombie”?
With “it” i mean the NPC class

[lua]
local function ClassCheck( Player, NPC )
if ( NPC:GetClass() == “npc_zombie” ) then
NPC:Remove()
end
end
hook.Add(“PlayerSpawnedNPC”, “random_hook_name”, ClassCheck);
[/lua]
Will automaticly remove “npc_zombie” when ever one is spawned.
Hope it helps.

Perfectly, absolut perfectly :smiley: