custom entity

Hey guys, after making my own custom entity, I cant spawn it through the Q menu.
I can see the object in the Q menu, but when i press on it, it doesn’t show the model, and nothing happens.
this is the init:

this is the cl_init:

the shared is fine :stuck_out_tongue:

Why, if you don’t mind me asking, is the model set to a player model? Why not use something like

a model of a barrel for testing. I figured that using something like a player’s model would be screwy

when setting up your first entity.

edit: Just realized while reading through that this is supposed to be a shop npc. Also, something you could try doing

would be to maybe use:


GM:InitPostEntity( )

For things like npc’s that will always be placed in the same spot on your map in your server, the function can place entities

on server start-up.

So an example would be:


function GM:InitPostEntity()
	local ent = ents.Create("myentity")
	ent:SetPos(Vector(196.558533, 363.780579, -87.084175))
	ent:Spawn()
end

And to get the position on the map, I think you type something like getpos into console.

haha a job npc, yeah.
but i’ll try another model.

You could use a console model from half life 2 as a console to buy from, I’d imagine another

smarter member will give some information on how to get npc’s to spawn, and give a menu

on pressing e. I wanna say you have to use nextbot?

Well, i already got a fimctopn where it should be spawning, but it doesn’t.
and the thing is that when go to the Q menu > Entities > Other > and i press on it, nothing happens.

Kind of a dumb question but, is your ent called jobsnpc? Or did you call the folder it’s in something else?


local ent = ents.Create("jobsnpc")

If it’s not, then that is why it’s not spawning I think.

I suggest you learn more of the Lua basics and make some simple stuff before making this gamemode you are trying, just put it aside and practice a bit and read some peoples code to see how they do stuff.

[editline]23rd May 2014[/editline]

Also, you aren’t including shared in your init

Trial and error. But I would agree, start making small stuff before a gamemode. But then again isn’t

and entity like what he’s making soemthing simple?

Also, there should be a thread for problems that don’t need their own thread I would highly

suggest using at http://forum.facepunch.com/showthread.php?t=1348923

This is all I have for my entity for spawning



function ENT:Initialize()
	self:SetModel("models/hunter/plates/plate1x1.mdl")
	self:PhysicsInit(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)
	self:SetSolid(SOLID_VPHYSICS)
	self:SetUseType(SIMPLE_USE)
	local phys = self:GetPhysicsObject()
	phys:Wake()
	self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
	local phys = self:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Sleep()
	end
	
end


Also, for his part where it pops up a menu, doesn’t he need to include a net.Receive? Otherwise how
is the client receiving the net message of the job selection? Or would he put that in his gamemode?

Yes, he should add it to the cl_init of the entity.
Not the gamemode, he could, but I recommend on the entity, because it would be rather pointless having it on the gamemode.
Having everything related to the entity in the entity files is best.

Emm, i am putting it in the gamemode it self.
Why is it that problomatic to put it there?

Why are you managing stuff that is related to the entity in the gamemode, it depends what code is in the gamemode, is the entire client code in gamemode and the entity init is on it’s own, calling the gamemode client code?

no no, i got the jobs from a shared file, the client stuff are there.
I just wanted to make sure that the entity is working, which it is now.
i’ve put the client data back there, just moved it to another part so i can start designing everything.

Anything that is made for the entity, an example being a menu when you press e on the entity will go in the entities client side file, if you have jobs in gamemode then are accessing the jobs, that is fine :smile:

Good :slight_smile: