Entity Creation Help

Hey everyone, I currently have a automatic prop spawn system that I’m messing around with that is made to create world props on server start up. Anyways, I have been trying to make the prop like how it is when you persist props in Garry’s Mod (Solid, doesn’t move, can’t be moved with physgun… etc) but I can’t seem to do it. The code is under the InitPostEntity hook and the main bit of the code I have right now is below.

local Prop = ents.Create("prop_physics")

Some help would be much appreciated, thanks in advance!

Hello ShadowRanger!

If I was you, I would make a for k, v in pairs function. This makes you enable to make alot of spawns :slight_smile:

Like this:

local MyAwesomeTable = {}

local MyAwesomeTable[ 1 ] = { }
MyAwesomeTable.Ang[ 1 ] = Vector(0,0,0) -- Your angel, type getpos in console to get it
MyAwesomeTable.pos[ 1 ] = Vector(0,0,0) -- Your postion, type getpos in console to get it
MyAwesomeTable.Entity[ 1 ] = superball -- Your entity name
MyAwesomeTable.Model[ 1 ] = model/sdadas/dssd/something -- Your modelname

local MyAwesomeTable[ 2 ] = { }
MyAwesomeTable.Ang[ 2 ] = Vector(0,0,0) -- Your angel, type getpos in console to get it
MyAwesomeTable.pos[ 2 ] = Vector(0,0,0) -- Your postion, type getpos in console to get it
MyAwesomeTable.Entity[ 2 ] = "superball" -- Your entity name
MyAwesomeTable.Model[ 2 ] = model/sdadas/dssd/something -- Your modelname

for k, v in pairs(MyAwesomeTable) do
	local Prop = ents.Create(MyAwesomeTable.Entity[ k ])
	Prop:SetModel(MyAwesomeTable.Model[ k ])
	Prop:SetPos(MyAwesomeTable.pos[ k ])
	Prop:SetAngles(MyAwesomeTable.Ang[ k ])

Let me know if it helps you.

There might bee some errors, I didn’t test it fully out. :slight_smile:
Locate it in the init.lua file :slight_smile:

[editline]19th May 2013[/editline]

I think I missunderstod something…

Thanks Errolight for the feedback but I think you misunderstood me or I just didn’t explain what I needed help with. Anyways, I already have the tables set up and the code works and spawns the props BUT they aren’t how I want them. The spawned props are not frozen and collide with players and move when collided with. I don’t want that. I want them to be world props that are frozen in place and solid. Basically just to make a map look better by adding extra props that aren’t already there.

Oooohh! Wait a sec. I makes maps aswell. Your looking for a func_detail?

[editline]19th May 2013[/editline]

Okay, I found this at the wiki, have you seen it?

Well I was looking for a good way to add props to maps through lua coding when a server starts and I was only able to find what I’m using now. I went to the link you sent me and as you can see in my post I’m using that but even with that the props aren’t frozen. Right now the props are spawned and are solid but they aren’t frozen like I want them to be.

Ohhh… Hmm

[editline]19th May 2013[/editline]

Have you tried this:


Nope, doesn’t work.

This is a script from a entity NPC I made a half year back, that npc can’t be moved, and has a box around it that does so you basicly can’t move it. It’s frozen aswell. I don’t know if you can dig something up with this

function ENT:SpawnFunction( ply, tr )
	if ( !tr.Hit ) then return end
	local SpawnPos = tr.HitPos + tr.HitNormal * 16
	local ent = ents.Create( "seller" )
	ent:SetPos( SpawnPos + Vector(0, 0, 5) )
	ent:SetAngles(Angle(0, 0, 0))
	ent:SetSolid( SOLID_BBOX ) -- <----------------------------------------------- What about this?????
	return ent

function ENT:Initialize( )
	self:SetModel( "models/humans/group01/male_08.mdl" )
	self:SetHullType( HULL_HUMAN )
	self:SetHullSizeNormal( )
	self:SetNPCState( NPC_STATE_IDLE )
	self:SetSolid( SOLID_BBOX ) -- <----------------------------------------------- What about this?????
	self:CapabilitiesAdd( CAP_ANIMATEDFACE, CAP_TURN_HEAD )
	self:SetUseType( SIMPLE_USE )
	self:SetMaxYawSpeed( 90 )

Okay I’ve finally got it to spawn frozen which is great but now I need to make it so you can’t move it with your physgun or any tool for that matter. Here’s the code:

local Prop = ents.Create("prop_physics")
	local phys = Prop:GetPhysicsObject()
	if IsValid( phys ) then phys:EnableMotion(false) end

Use falcos prop protection? It’s a world prop, so you can just do so people can’t touch world props, witch is pretty bad if they could, because you would never know who killd you with a world prop…

Thanks for the help, I’ve gotten the information I need to sort out the code. Thanks again :slight_smile: