Replacing all of a certain prop with an entity


Is is possible to repalce all of a certain prop with an entity? If so how do I do it?

Very possible, but be carefull how you use it, as it can cause some serious errors depending on the map, etc.

A simple hook that changes all physics props on the map into Manhack NPCs:
local function ReplaceWithManhack( )

-- Finds all prop_physics entities
for k, v in pairs( ents.FindByClass( "prop_physics" ) ) do

	-- Stores their position temporarily
	local spawnPos = v:GetPos( )

	-- Gets rid of the prop (The position was all we needed)
	SafeRemoveEntity( v )

	-- Creates a manhack in its place
	local npc = ents.Create( "npc_manhack" )
	npc:SetPos( spawnPos )
	npc:Spawn( )


– Called after all entities have been placed on the map (Directly after ‘Initialize’, I think.)
hook.Add( “InitPostEntity”, “replacewithmanhack”, ReplaceWithManhack )

This might help you, as there are many ways to decide which props to replace, etc.