Weird OnEntityCreated Delay

It seems it’s only happens when NPC is created.
[lua] hook.Add(“OnEntityCreated”, “mob.random”, function(ent)
if !ent:IsNPC() then
return
end

	for k, v in ipairs(mob.ranks) do
		local dice = math.Rand(0, 100)
		if dice <= v.chance then
			ent.rank = k
			AddRanked(ent, k)


			return
		end
	end
end)

[/lua]

Delay it by a frame, “timer.Simple(0, function() end)”

Doesn’t work.
I tested this code in the video.
[lua]hook.Add(“OnEntityCreated”, “mob.random”, function(ent) print(ent) end)[/lua]

[editline]9th March 2014[/editline]

It seems it’s not working well if entity is spawned on far away from the player.

That sounds like a PVS issue then

It’s not that far away. It’s like 256 units from the player.

Try and debugging it make sure it’s the OnEntityCreated hook that is the problem.

Just remove everything in the hook and use a simple print with the entity’s index.

I can sure OnEntityCreated is the problem.

[editline]9th March 2014[/editline]

Oh, I see…
OnEntityCreated is fired when the entity have shown it’s the first signal(any kind of signal/manipulation) since it’s spawned.