Static props spawning (Save the props)

Hello,

I want to spawn props in the server so the props aren’t player-based. (So the props remain on the server). How do I do it? Is it saved to map or is it a code parameter to the server to spawn a prop in a specified position? (X, Y, Z).

I’ve searched about this and I didn’t found anything on the net, maybe I am bad at finding things, who knows…

Anyways, If you got a tip how to do it, I happy to know.

Thanks In Advance

Charlie.

One option would be making a table for the model, position and angle for the props you want and then applying that into an ents.Create() code with the InitPostEntity hook. Give it a go, if you have any trouble just let me know, I’ll see what I can do.

Thank you for the tip ShadowRanger, but which Entity ID is the server using, because I can only manage to bind the prop to a player like:



local ply = Entity(1) //Player ID = 1


Or I am confused?

Lots of people are in need of a script that does this. I think I might consider releasing mine which does exactly what you want and is quite simple as well. Ill see what I can do later, I’m a bit busy today but this afternoon I should be able to help.

I’m definitely confused by that :v:

What ShadowRanger means by

is something like this
[lua]local MapData = {

gm_construct = {
	{model="models/hunter/plates/plate.mdl", pos=Vector(0,0,0), ang=Angle(0,90,0)},
	{model="models/hunter/plates/plate.mdl", pos=Vector(100,0,-100), ang=Angle(22,35,15)},
},

gm_flatgrass = {
	{model="models/hunter/plates/plate.mdl", pos=Vector(0,0,0), ang=Angle(0,90,0)},
	{type="weapon_smg1", pos=Vector(100,0,-100), ang=Angle(22,35,15),}, --We can set a 'type' to spawn an entity instead of a physics prop
},

}

local function AutospawnProps()

local mapName = game.GetMap()	--Get the name of the map
local mapData = MapData[mapName] --Check we have data for this map

if mapData then --If we have data for this map

	--Loop through the stuff
	for _,v in pairs(mapData) do
	
		--get the type of entity, or default to a physics prop
		local entType = v.type or "prop_physics"
		--spawn it
		local newEnt = ents.Create(entType)
		if v.model then newEnt:SetModel(v.model) end --set model
		if v.ang then newEnt:SetAngle(v.ang) end --set angle
		if v.pos then newEnt:SetPos(v.pos) end --set position
		newEnt:Spawn()
		newEnt:Activate()
	
	end --End of for-loop

end --End of check for map data

end

hook.Add(“InitPostEntity”, “Autospawn Props On Load”, AutospawnProps)[/lua]

Sweet. Yeah, that’s basically the sort of coding I meant but for world props I use prop_dynamic and set it as a solid along with disabling the ability to interact with it using a physun, gravity gun etc…