There's a map called nuclear winter resurgence on the workshop, and I wanted to use it, but there's alot of NPCs that randomly spawn on the map and i don't want them to spawn at all. Any way to prevent them with lua?
Unless they are spawned via an addon, the map most likely spawns npcs with inmap tools such as timers, triggers etc.
Basically, unless you have the maps vmf to be able to remove said stuff and recompile, probably not.
If you can identify what entities are responsible for the spawns, you can use a Lua script to remove them.
CreateConVar("disable_npcs", 1, FCVAR_ARCHIVE)
hook.Add( "OnEntityCreated", "RemoveNPCS", function( ent )
if CLIENT then return end
if GetConVar("disable_npcs"):GetNumber() <= 0 then return end
if IsValid(ent) and ent:IsNPC() then
timer.Simple(0, function()
ent:Remove()
end)
end
end )
This will remove all npcs spawned in map while disable_npcs convar is on
You can absolutely remove these using Lua, but it's just an issue of knowing what to remove; if you were to remove all timer and trigger entities in the map, your actions could bring unforeseen consequences.
Or that too ^, just have to be careful. You'd have to do this every map load and only on the wanted map, so a modified vmf would be ideal(however that most likely isn't an option since theres a small chance you have access to the vmf). Also make sure the creator of the map didn't already post a version of the map without said entities.
you can use entspy to modify entity data in the bsp, I would recommend renaming the map to prevent version mismatches or you could handle it through lua by finding the npc spawner entities and removing them.
Sorry, you need to Log In to post a reply to this thread.