Creating "Objective Entities"?

I’m working on coding a team/class based mod, which is based on what I can only describe as “Objective Entities.” These “entities” are 5 buildings each team has on their base. The objective of the game is to destroy all five of the opposing team’s Objective Entities before they destroy yours. When all of one team’s “Objective Entities” are destroyed, that team looses, the round is over, and the game restarts. How would I go about scripting to identify these entities, how far each is from being destroyed (some form of health I suppose), which ones are destroyed, and the winners of the game?

I am a complete noob to lua, so feel free to phrase things as if you were speaking a 4 year old.

Do you want an item inside the map-placed building that is destroyable (A control console or something), or do you want the entire building to be destroyable? I think you can guess which one is more difficult.

In time I would like to make it a whole building, but I suppose something such as a control console would be the best place to start. The only thing is that I want to make it quite difficult to destroy (hence the concept of having to destroy an entire building).

The reason I ask is whether you would like to destroy the building in pieces or just all at once.

Regardless, it would be best to create the autorun files governing the gamemode first. Just set up some basic functions to register a building destroyed, how many buildings are left, along with the gamemode structure. Sorry, I’ve never bothered with a gamemode and its structures. There are certainly plenty of guides for that. Once you’ve got that down, it’s just a fairly straightforward SENT. A good first one, in my opinion. Go look at other existing SENTs by the way, it’s extremely useful.

I’m assuming you know some of the language so far. If that’s the problem, there are loads of tutorials at or you can just look at the official guide to programming in lua (Not specifically for GMod, but much, much larger) at

  1. Create a SENT base. There is a base in the gamemode base if you need it, although you might want to grab an entity from another mod and clean out some of the code. There are usually functions that you’ll want to run every time you create an entity, although the SENT base works reasonably well. (I say this because you’ll probably want to disable movement and such, which are functions likely available in other SENTs, to save you having to look up the functions.) Most of the functions at the top in other entities are fairly self-explanatory, such as SetModel.

  2. Hook into ENT:OnTakeDamage(), if you want it to be damageable by default weapons. If you just want it to be damaged by explosive weapons, that’s easy too.

  3. Very simple. Just have it decrease a self.Health variable by however much damage it takes. Alternatively, you could use the built-in source damage system. I can’t say I’m a fan, though. Not enough options for me.

function ENT:Initialize()
// More stuff here, probably about making it not move, etc.
self.Health = 1000
function ENT:OnTakeDamage(dmgstats)
if dmgstats:IsExplosionDamage() then
self.Health = self.Health - dmgstats:GetDamage()
if self.Health < 0 and self.Entity:IsValid() then
// Do a particle effect here.

There are more efficient ways of doing that, but that’s the simplest method possible. You might find this post completely useless. It focusses on the destructable entity part, rather than the control console part. That’d take too much time to explain, so you should really contact me, or someone else. I’m XMorcamX on Steam.