Setting up a sENT

So, I’m trying to create a Scripted Entity addon for DarkRP.

Nothing too special, just something that appears at random across the map in areas an admin sets with chat commands, and can be collected for money.

This is my first attempt at anything Garry’s Mod Lua related, and I found that Garry’s Mod Lua is much more complex and workable than conventional Lua, so I’m completely lost. I know I need these three files to set up a working sENT:


But I don’t know what headers go in them and whatnot. Any help on where I can find a skeleton sENT, or how to set one up myself?

Lua scripting -> Articles -> Scripted entities -> Jumping bathtub

Thanks. That clarified alot. My only question is… what do I take out to avoid my entity having active physics? By that, I mean… I want it to have a collision box, but it can’t be picked up with the gravity gun
Basically, a prop_static.

I know this goes under self:SetModel()
But what do I remove/add to achieve “Prop_static” properties?

You’ll want to set the entity’s movetype to none with **[Entity.SetMoveType](**.

If it’s still possible to pick it up with the physics gun, you might want to create a **[Gamemode.PhysgunPickup](** -hook to prevent your entity class from being picked up.

Alright. I think I’m to the point where I can spawn my sENT just as sort of a dummy prop. I just want to make sure it can be spawned without errors so far, but it isn’t being added to the spawnlist…
Here’s the “shared” lua file, where it seems the spawn data is stored.

print(“Nevermind, I figured it out.”)

**Edit: New issue

In the self:SetModel() parameter I’m having trouble making the sENT spawn with a random model from a series of models provided. How would I go about this?

Just create a table with wanted models, then pick one random. Example:

RModel = {"models/../model_1.mdl","models/../model_2.mdl","models/../model_3.mdl"} -- You can add as many as you want

And when you want to set the model use:


That makes perfect sense. I tried something along the lines of that, I physically put a table inside the parameter. That didn’t work well.

Why not? It should work perfectly if you used it like this: