Destroying breakable functions

How would I go about adding points whenever a player breaks a brush? This should add to the team’s score.

I’m pretty sure that it’d be a coding thing, not mapping.


Tis indeed coding, but easily done with the Lua_Run entity.

If you have the garrysmod.fgd file good, if not pull it from your garrysmod root folder.

Create a lua run entity and have it run the following code:
[lua]team.AddScore(TRIGGER_PLAYER:Team(), 1)[/lua]

Then configure the onBreak output of your breakable entities to target the lua_run entity and run the code.

Or if you want a much easier way you could run this script by placing it in your lua/autorun/server directory (create it if it doesn’t exist) which may need to be tweaked so to not trigger on all breakable entities.
hook.Add(“EntityTakeDamage”, “breakpoints”, function(ent, inflictor, attacker, amount, dmginfo)
if (ent:GetClass() == “func_breakable” && amount >= ent:Health()) then
team.AddScore(attacker:Team(), 1);

However the first approach will not require any external lua scripts, and will function with the map alone.



Thanks, this worked.

Not necessarily