Spawning clientside entities?

It seems I can’t do it. I want to create an entity to indicate where you will spawn stuff (Gamemaster) but it keeps saying that it can’t find the factory for the entity. Already put InitializeAsClientEntity() in the init thingy from the entity, but still doesn’t work. Any ideas?

Use prop_physics.

Here’s what I’m currently using…

// function for spawning clientside entities
function ENT:SpawnCL( data )

local ent = ents.Create( data.class or "prop_physics" )
if( !ent:IsValid() ) then return NULL end
	ent:SetColor( unpack( data.color or {255,255,255,255} ) )
	ent:SetPos( self:GetPos() + ( data.pos or Vector(0) ) )
	ent:SetModelScale( data.scale or Vector( 1,1,1 ) )
	ent:SetAngles( data.ang or Angle(0) )
	ent:SetMaterial( data.mat or '' )
	ent:SetModel( data.model )
	ent:SetParent( self )
	table.insert( self.clientents, ent )
return ent


My prop data is stored in a seperate table, but you needn’t do this…
local parts = {
BODY = {
model = Model(‘models/props/sphere.mdl’),
color = {30,30,30,255},
mat = ‘models/debug/debugwhite’
STUB = {
model = Model(‘models/props_c17/oildrum001.mdl’),
pos = Vector( 0,0,14 ),
color = {50,50,50,255},
scale = Vector( 0.25,0.25,0.25 )



I prefer to use my own entity since it has a draw hook with some additional render stuff, so I can’t use prop_physics (unless I can somehow change the drawing hook of it)

Oh, you want to make a clientside SEnt, I misunderstood.
I’ve never done this so have no experience with it.

As you’ve probably noticed there’s no documentation for the InitializeAsClientEntity function, and it’s not currently used anywhere in gmod.
I guess that leaves it down to trial & error, or hope that someone has done the trial & error thing before and knows how it works.

If this helps here’s how it’s used by Valve :

 InitializeAsClientEntity( pszModelName, RENDER_GROUP_OPAQUE_ENTITY )

We can probably safely assume InitializeAsClientEntity is simply a binding for it’s C++ equivalent, it apparently returns a boolean too.

Here’s how it’s defined :