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

function spawns()
local npc_spawn = ents.Create(“npc_zombie”)
hook.Add( “Initialize”, “spawnit”, spawns)

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
hook.Add(“PlayerSpawnedNPC”, “Npcthing”, npc_spawn)

thx :smiley:

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

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

Perfectly, absolut perfectly :smiley: