lol i was bored so i made this

no matter what damage an entity takes it will violently explode (including you, unless ur in god mode)
its so simple but funny

i didnt want to make a full addon out of this but had some kind of need to share it
so here you go
have fun with life

put this in garrysmod/lua/autorun/server

explodeath.lua



hook.Add( "EntityTakeDamage", "explodeath", function(target, inf)
	local loc = target:GetPos()
	local isplayer = target:IsPlayer()
	if !explodeath_pgo(target) then
	target:Remove()
	timer.Simple( 0.05, function()
	if explodeath_pgo(target) then return end
	local explosion = ents.Create( "env_explosion" )
	explosion:SetPos( loc )
	explosion:SetOwner( inf:GetAttacker() )
	explosion:Spawn()
	explosion:SetKeyValue( "iMagnitude", "220" )
	explosion:Fire( "Explode", 0, 0 )
	explosion:EmitSound( "weapon_AWP.Single", 400, 400 )
	if isplayer then
		target:Spectate(OBS_MODE_DEATHCAM)
		target:StripWeapons()
		timer.Simple( 2, function()
			if target:IsValid() then
				target:UnSpectate()
				target:Spawn()
			end
		end )
	end
	end )
	end
end )

function explodeath_pgo(ent)
	local ret = false;
	if !ent:IsValid() then return false end
	if ent:IsPlayer() then
		if ent:HasGodMode() then
			ret = true;
		end
	end
	return ret;
end


lol, sorry if this is the wrong thread or something, but by my experience Facepunch is a pretty open place so idc


(User was banned for this post ("Undescriptive thread title + crap thread" - Kiwi))

You should really space out your code. Other than that, I can’t really see anything wrong.

thanks i guess