Dealer npc hated by zombies

Currently have a bought script that has an npc dealer in it
i am trying to use it on a zombierp server but all the zombies hate it (more so than even the players)

i have tried adding this to the entities think function
local enemy = ents.FindByClass( “npc_*” )
for _, x in pairs( enemy ) do
if !x:IsNPC() then return end
if x:GetClass() != self:GetClass() then
x:AddEntityRelationship( self, D_NU, 99 )
self:AddEntityRelationship( x, D_NU, 99 )

but it seems to be a useless piece of code.

Any ideas on making these entity npcs less hated (i have noticed this with other ones as well)

Modify the zombie code.
Disable targeting of the NPC with GetClass() in the Think Hook.

I am supposing you have a custom Zombie NPC installed which can be modified.

no just default hl2 zombies (custom skin but thats it) might be able to get the zombie when it spawns and set its relationship instead

Just look through the gamemode code where it spawns the zombie, or run an for loop every 5 seconds or so.

Try running something this

for k,v in pairs(ents.FindByClass(zombie name here)) do
   if ents.FindInSphere(v:GetPos(), some number) then
     turn off ai for zombie or teleport them or something

Pseudo-code obviously

Default HL2 Zombies for Zombie RP Gamemode…
Hm… Let me think…

There is basically not much you can do.
Try to edit the NPC so it doesnt get attacked.

Theres some way Zombies ignore you In sandbox so In DarkRP it should work the same, just find that codepiece :wink: in gamemodes/sandbox/whateverfile

You’re wrong, you can fully edit the default HL2 zombie, just search the entity, get its object, and then run your functions on it.


local Zombies = {
npc_zombie = true,
npc_fastzombie = true,
npc_zombine = true,
npc_poisonzombie = true,
local function IsaZombie(class)
return Zombies[class] or false

function onentcreate( ent )
timer.Simple( 0, function( )
if( IsValid (ent) and ent:IsNPC() and IsaZombie(ent:GetClass()) ) then
for k, v in pairs( ents.FindByClass(“neths_car_dealer”) ) do
ent:AddEntityRelationship( v , D_NU, 99 )

hook.Add(“OnEntityCreated”, “enttities”, onentcreate)


Taken and edited from my workshop addon

Derp tried to set relationship to a table of entities XD fixed and working :slight_smile: