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 http://wiki.garrysmod.com/?title=Lua_Tutorial_Series or you can just look at the official guide to programming in lua (Not specifically for GMod, but much, much larger) at http://www.lua.org/pil/
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.
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.
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.
// More stuff here, probably about making it not move, etc.
self.Health = 1000
if dmgstats:IsExplosionDamage() then
self.Health = self.Health - dmgstats:GetDamage()
if self.Health < 0 and self.Entity:IsValid() then
// Do a particle effect here. http://wiki.garrysmod.com/?title=Util.Effect
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.