Where do I put custom entity on my server?

Hey, I’ve created a custom entity and I’m not sure where I put it in my server files, I’ve tried garrysmod/lua/entities and the folder name is the entity’s name but it does not seem to be loading.

Can you post a picture of the layout of your files and folders. Could you also clarify what you mean by “not loading”. Is it not appearing in the spawn menu, or is it not spawning with the map, etc. If you could also post a console log then that might help.

The rule of thumb here is the more information you give, the faster it gets solved. You’ve not given any information other than “I put some files I’m not telling you about here” and “it doesn’t work”.

It does not seem to be appearing in the entity list, here are the images and console log:


Don’t put them into the default entities folder. You should go into your ‘addons’ folder and create a structure like so.

addons/addonname/lua/entities/entityclassname/ lua files go in here.lua

EDIT: A little clarification, that folder is where the default entities that Garry made is at. In that folder, the entity’s class name is determined by the lua file’s name and all of it is put into one file.

Okay, it still does not seem to show up in the entity menu.

Console output:

You are still not showing us the code, most likely your entity doesn’t have Spawnable field

The entity is spawned by a weapon, and when the script tries to spawn the entity, it doesn’t. It was working fine in single player and it does not print any errors

If you are not going to show any code, please avoid to keep asking for help here

Here is the code for the entity:
As mentioned before, it is spawned by a weapon. The weapon works fine but does not spawn the entity.

Shared.lua: https://i.imgur.com/3Q1piqg.png
Init.lua: https://i.imgur.com/hmVwy7q.png
Cl_Init.lua: https://i.imgur.com/kOCxXCG.png

Can we see your weapon code?

Weapon code: https://pastebin.com/ATKpfgZw

DrawShadow is a function and needs a ‘:’ and not a ‘.’

You don’t need to do self.Entity because you can use self which is a reference to the entity.

Thanks. The entity still does not spawn however.

Weapons works without it data as primary and base info? I don’t think so, can you copy weapon_flachette gun table info into your weapons with your settings and take a look if it works?

I’m sorta new to lua, how would I do that?

Weapons do not work without primary info or at least when you shoot, it shouldn’t. It needs info on what ammo does left click shoot, magazine size, default amount of ammo in gun, and whether the gun is automatic or not.

Put this up top in your weapon below AddCSLuaFile() and modify as needed.

SWEP.Primary.ClipSize		= -1
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= false
SWEP.Primary.Ammo		= "none"

All of that can be found on the wiki. Specifically here.

Yeah i’ve done that.

what happens ingame/console if you type ulx ent ent_test

It spawns the entity without any errors:

but does not spawn by the weapon.

Try remove
if (!IsValid(ent)) then return end
if (!IsValid( phys ) ) then ent:Remove() return end

then see what happens