npс id

Hello, please help
Hi, I need to assign a specific id object. How can this be done?
Forgive me for my English I’m from Russia

If you want to give the entities some sort of… ID, which would be basically storing it inside of them you could do the following


ENTITY.CustomID = id

or if you want some type of custom identifier to be able to… search them easier i would use

Entity:SetName

Why are you doing this? What do you need the ID for?

I want to make spawn npc and give each of them its own identifier.
That he automatically after death again appeared under his own identifier

Can you explain more about what you’re doing – what kind of NPCs? Are they HL2 or Lua NPCs? What kind of identifier? Is it a “name” displayed to the player? Does it describe what weapon the NPC uses, or something unique about it that isn’t part of the NPC class?

If you just want to respawn NPCs when they’re killed, that’s simple enough:
[lua]
hook.Add(“OnNPCKilled”, “RespawnNPC”, function(npc, attacker, inflictor)
if npc.CanRespawn then
local npc2 = ents.Create(npc:GetClass())
npc2:SetPos(some_spawnpoint)
npc2:Spawn()
end
end)

– when you create the NPC
local npc = ents.Create(“npc_zombie”)
npc.CanRespawn = true
[/lua]